I have five values, A, B, C, D and E.
Given the constraint A + B + C + D + E = 1, and five functions F(A), F(B), F(C), F(D), F(E), I need to solve for A through E such that F(A) = F(B) = F(C) = F(D) = F(E).
What's the best algorithm/approach to use for this? I don't care if I have to write it myself, I would just like to know where to...
atan2(y,x) has that discontinuity at 180° where it switches to -180°..0° going clockwise.
How do I map the range of values to 0°..360°?
here is my code:
CGSize deltaPoint = CGSizeMake(endPoint.x - startPoint.x, endPoint.y - startPoint.y);
float swipeBearing = atan2f(deltaPoint.height, deltaPoint.width);
I'm calculating the direction...
I know that it is possible to calculate the mean of a list of numbers in O(n). But what about the median? Is there any better algorithm than sort (O(n log n)) and lookup middle element (or mean of two middle elements if an even number of items in list)?
...
Say I'm inserting a 64 bit floating point double into a DECIMAL(17,5) field. Does the value get rounded or truncated?
...
How many possible words of length 6 can I generate from the English lower case alphabet, if each word starts with a random consonant, and after that vowels and consonants alternate?
What if I add digits to my alphabet?
See also this question.
...
I am doing a Monte Carlo experiment to calculate an approximation of PI. From SICP:
The Monte Carlo method consists of
choosing sample experiments at random
from a large set and then making
deductions on the basis of the
probabilities estimated from
tabulating the results of those
experiments. For example, we can
approx...
Hello,
I have a triangle ABC,
I know all points' coordinates A(x1, y1), B(x2, y2), C(x3, y3)
I want to draw a vertical edge from A to [BC]
How can i calculate?
Thanks your advance
...
I'd like to get an idea what kind of math is typically necessary for 3D game engine programming? Any specific math (such as vector geometry) or calculation algorithms (such as fast fourier transforms), or is this all abstracted away with DirectX/OpenGL so that highly complex math isn't really necessary any more?
...
I'm writing iPhone code that fuzzily recognizes whether a swiped line is straight-ish. I get the bearing of the two end points and compare it to 0, 90, 180 and 270 degrees with a tolerance of 10 degrees plus or minus. Right now I do it with a bunch of if blocks, which seems super clunky.
How to write a function that, given the bearing 0...
Given two different messages, A and B (maybe 20-80 characters of text, if size matters at all), what is the probability that the MD5 digest of A is the same as the MD5 digest of B and the SHA1 digest of A is the same as the SHA1 digest of B? That is:
(MD5(A) == MD5(B)) && (SHA1(A) == SHA1(B))
Assume no malicious intent, i.e., that th...
I have a friend that needs to compute the following:
In the complete graph Kn (k<=13), there are k*(k-1)/2 edges.
Each edge can be directed in 2 ways, hence 2^[(k*(k-1))/2] different cases.
She needs to compute P[A !-> B && C !-> D] - P[A !-> B]*P[C !-> D]
X !-> Y means "there is no path from X to Y", and P[ ] is the probability.
So ...
I have two 2d circles in 3d space (defined by a center, normal, and radius) and I'm trying to come up with a pair of points that is one of the set of closest pairs of points. I know that there are anywhere from 1 to an infinite number of point pairs, I just need a single matching pair.
Is there a simple way to do that? Precision is no...
Hi Everyone - I am trying to translate this statement into Actionscript:
"Sally is 5 years old. Jenny is 4 years old. The combined age of Sally and Jenny is 9 years."
This is what I have so far:
function getAges (sallyAge:Number,jennyAge:Number,combinedAge:Strin g)
{
trace("Sally's Age:" + sallyAge);
trace("Jenny's Age:" + jennyAge);
...
I plan on having to split up the Geometry object into a series of simpler shapes, and combine their centroids using this formula:
Mathematical details of this formula can be found in this Wikipedia article.
NOTICE: Don't be suprised if my view of the mathematics is incorrect. I haven't done any complex math past trigonometry, and I'v...
Duplicate
Best algorithm for evaluating a mathematical expression?
Is there a built-in Delphi function which would convert a string such as '2*x+power(x,2)' or any equation to float? StrToFloat raises an exception because of the char X and power.
Thanks.
...
Duplicate
Best algorithm for evaluating a mathematical expression?
mathematical expression parser in Delphi?
I need a program in Delphi that get one variable equation from Edit1 such as "F(x)=4*X+2*log(x)+4*power(X,2)"and get X value variable from Edit2 then show the result F(X) in Edit3. Please help me.
Thanks.
...
I have to display ratings and for that i need increments as follows:
If the number is 1.0 it should be equal to 1
If the number is 1.1 should be equal to 1
If the number is 1.2 should be equal to 1
If the number is 1.3 should be equal to 1.5
If the number is 1.4 should be equal to 1.5
If the number is 1.5 should be equal to 1.5
If...
I am new to Ruby on Rails and have been using Scaffolding. On one of the forms I want to be able to have two fields and then have the difference between the two submitted to the database.
Instead of :pickupamount, I want (Ending Amount - Starting Amount) to be calculated and entered into the pickupamount column of my database.
Thanks ...
The basic table schema looks something like this (I'm using MySQL BTW):
integer unsigned vector-id
integer unsigned fk-attribute-id
float attribute-value
primary key (vector-id,fk-attribute-id)
The vector is represented as multiple records in the table with the same vector-id
I need to build a separate table with the dot product (al...
I am trying to determine the volatility of a rank.
More specifically, the rank can be from 1 to 16 over X data points (the number of data points varies with a maximum of 30).
I'd like to be able to measure this volatility and then map it to a percentage somehow.
I'm not a math geek so please don't spit out complex formulas at me :)
I...