Here is the query in Oracle I was trying to remove the redundant math operation from:
SELECT name,
CASE
when nvl(num1,0) + nvl(num2,0) - nvl(num3,0) > 0
THEN nvl(num1,0) + nvl(num2,0) - nvl(num3,0)
ELSE 0
END
as result,
.... from ....
How do I not repeat the summation above?
The 'result...
I recently was part of a small java programming competition at my school. My partner and I have just finished our first pure oop class and most of the questions were out of our league so we settled on this one (and I am paraphrasing somewhat): "given an input integer n return the next int that is prime and its reverse is also prime for e...
How can I programatically detect whether or not two triangles touch each other, given their vertices on a 2D coordinate plane? This includes touching points or edges, as well as if one triangle is completely "inside" the other one.
...
I am looking for a decent fractal based compression algorithm for images. So far I only find dead links to the FIF image format and dead links pointing to Iterated Systems Inc which then became MediaBin which then became nothing from what I can see.
...
I have some points in 3D which are in a single plane. I want to arrange them in clock wise or counter clockwise order.
The points can create a concave or convex polygon in a single plane.
Can any body give any suggestions?
...
We know that the inverse of tan is Math.Atan, what about the inverse of cot? cot(x) is defined as
cot(x)=1/tan(x)
...
Whats the mathematical formulae to calculate the MIN and MAX value of an integral type using your calculator. I know you can use Integer.Max or Integer.Min etc or look it up on msdn however I want to know how to calculate it.
...
Hi all.
I have a rectangle in .NET in which I draw an ellipse.
I know the width, height and center point of that rectangle.
Of course the center point of the rectangle is also the center point of the ellipse.
I know how to calculate a point on a circle, however I have no clue about an ellipse.
I have those parameters and an angle, i...
Hi,
Take for example the list (L):
John, John, John, John, Jon
We are to presume one item is to be correct (e.g. John in this case), and give a probability it is correct.
First (and good!) attempt: MostFrequentItem(L).Count / L.Count (e.g. 4/5 or 80% likelihood)
But consider the cases:
John, John, Jon, Jonny
John, John, Jon, Jon
I w...
We have a collection of sets A_1,..,A_n. The goal is to find new sets for each of the old sets.
newA_i = {a_i in A_i such that there exist (a_1,..,a_n) in (A1,..,An) with no a_k = a_j for all k and j}
So in words this says that we remove all the elements from A_i that can't be used to form a tuple (a_1,..a_n) from the sets (A_1,..,A_n...
Google doesn't want to help!
I'm able to calculate z-scores, and we are trying to produce a function that given a z-score gives us a percent of the population in a normal distribution that would be under that z-score. All I can find are references to z-score to percentage tables.
Any pointers?
...
Hi all,
I have a direction vector that applied to a position gives me the point at which the camera should look. How can I get from that yaw, pitch and roll in order to use glRotatef properly?
Thanks in advance
...
I'd like to estimate the number of leaves in a large tree structure for which I can't visit every node exhaustively. Is this algorithm appropriate? Does it have a name? Also, please pedant if I am using any terms improperly.
sum_trials = 0
num_trials = 0
WHILE time_is_not_up
bits = 0
ptr = tree.root
WHILE count(ptr.children)...
Hi All
I am setting up a set of computers where to run math programs on top of MPI.
Do you know whether exist some library doing PCA - Principal Component Analysis using MPI so to use all the resources of the networked pcs?
I will have a look at Scalapack, but do you know other libraries?
My language is C++ on linux but if there is a go...
I have a set of items, for example: {1,1,1,2,2,3,3,3}, and a restricting set of sets, for example {{3},{1,2},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{2,3},{2,3}. I am looking for permutations of items, but the first element must be 3, and the second must be 1 or 2, etc.
One such permutation that fits is:
{3,1,1,1,2,2,3}
Is there an algorithm ...
I have a sample of some kind that can create somewhat noisy output. The sample is the result of some image processing from a camera, which indicates the heading of a blob of a certain color. It is an angle from around -45 to +45, or a NaN, which means that the blob is not actually in view.
In order to combat the noisy data, I felt that ...
The most efficient way to code powers of two is by bit shifting of integers.
1 << n gives me 2^n
However, if I have a number that is larger than the largest value allowed in an int or a long, what can I use to efficiently manipulate powers of 2?
(I need to be able to perform addition, multiplication, division and modulus operations on...
Hi All,
I was in need of a little math help that I can't seem to find the answer to, any links to documentation would be greatly appreciated.
Heres my situation, I have no idea where I am in this maze, but I need to move around and find my way back to the start. I was thinking of implementing a waypoint list of places i've been offset ...
i have here a device which can give me gps coordinates. the time intervall i can define. i want to use it to calculate the average speed during driving or travelling by car. actually i used a orthodrome formula to calculate the distance between two points and then divided it by the given time intervall. by the implemenation i followed th...
I want to display LaTeX math in the gmail messages that I receive, so that for example $\mathbb P^2$ would show as a nice formula. Now, there are several Javascripts available (for example, this one, or MathJax which would do the job, I just need to call them at the right time to manipulate the gmail message.
I know that this is possibl...