math

C# Math Problem

I have been working on this for the greater part of the day and I cant seem to make this part of my code work. The intent of the code is to allow the user to input a set of values in order to calculate the missing value. As an additional feature I placed a CheckBox on the form to allow the user to do further calculation. That is where my...

Open source C++ library for vector mathematics

I would need some basic vector mathematics constructs in an application. Dot product, cross product. Finding the intersection of lines, that kind of stuff. I can do this by myself (in fact, have already) but isn't there a "standard" to use so bugs and possible optimizations would not be on me? Boost does not have it. Their mathematics ...

Find a "best fit" equation

It's been a while since I was in college and knew how to calculate a best fit line, but I find myself needing to. Suppose I have a set of points, and I want to find the line that is the best of those points. What is the equation to determine a best fit line? How would I do that with PHP? ...

calculate distance between 2 gps coordinates

How do I calculate distance between two gps coordinates (lang,long) ...

how to determine the period of a function

Hi,if i have a function A,which can apply a certain rule on a given matrix to generate a another matrix which i call it the next state of the origin matrix,also the function can determine the the final state of the matrix by given times N(apply the rule on origin,and apply the rule on the next state of the origin matrix again,and apply r...

Error in Flash addition

Make a new AS3 Document in Flash, paste in the following code and run it: var a:Number=0; trace(a) // 0 a+=0.3; trace(a) // 0.3 a+=0.3; trace(a) // 0.6 a+=0.3; trace(a) // 0.8999999999999999 a+=0.3; trace(a) // 1.2 a+=0.3; trace(a) // 1.5 a+=0.3; trace(a) // 1.8 a+=0.3; trace(a) // 2.1 a+=0.3; // ^ This is th...

Mathematical Derivation with C#?

How can I do some more advanced function. I see that I can do function with public double myFunction(double myParameter) but what if I do want to derive that function? ...

Computing a 95% confidence interval on the sum of n i.i.d. exponential random variables.

Let's in fact generalize to a c-confidence interval. Let the common rate parameter be a. (Note that the mean of an exponential distribution with rate parameter a is 1/a.) First find the cdf of the sum of n such i.i.d. random variables. Use that to compute a c-confidence interval on the sum. Note that the max likelihood estimate (MLE...

Round a double to x significant figures after decimal point

If I have a double (234.004223) etc. I would like to round this to x significant digits after the decimal places in C# So far I can only find ways to round to x decimal places but this simply removes the precision if there are any 0s in the number. e.g. 0.086 to 1 decimal place becomes 0.1 but I would like it to stay 0.08. Thanks ...

MATLAB: Using ODE solvers?

This is a really basic question but this is the first time I've used MATLAB and I'm stuck. I need to simulate a simple series RC network using 3 different numerical integration techniques. I think I understand how to use the ode solvers, but I have no idea how to enter the differential equation of the system. Do I need to do it via an m-...

Is F# really better than C# for math?

Unmanaged languages notwithstanding, is F# really better than C# for implementing math? And if that's the case, why? ...

Fitting polynomials to data

Is there a way, given a set of values (x,f(x)), to find the polynomial of a given degree that best fits the data? I know polynomial interpolation, which is for finding a polynomial of degree n given n+1 data points, but here there are a large number of values and we want to find a low-degree polynomial (find best linear fit, best quadr...

What are some good books on the theory of probability?

I am planning to study theory of probability. I studied it when i was in high school. I was trying to solve a problem and i felt that i have forgotten most of it. Can anyone suggest any an easy to read book on it. ...

Intersection of two lines defined in (rho/theta ) parameterization

Have created a c++ implementation of the Hough transform for detecting lines in images. Found lines are represented using rho, theta, as described on wikipedia: "The parameter r represents the distance between the line and the origin, while θ is the angle of the vector from the origin to this closest point " How can i find the inte...

How do you do *integer* exponentiation in C#?

The built-in Math.Pow() function in .NET raises a double base to a double exponent and returns a double result. What's the best way to do the same with integers? Added: It seems that one can just cast Math.Pow() result to (int), but will this always produce the correct number and no rounding errors? ...

Efficient maths algorithm to calculate intersections

For a game I am developing I need an algorithm that can calculate intersections. I have solved the problem, but the way I have done it is really nasty and I am hoping someone here might have a more elegant solution. A pair of points represent the end points of a line drawn between them. Given two pairs of points, do the drawn lines inte...

Finding Integers With A Certain Property - Project Euler Problem 221

I've become very addicted to Project Euler recently and am trying to do this one next! I've started some analysis on it and have reduced the problem down substantially already. Here's my working: A = pqr and 1/A = 1/p + 1/q + 1/r so pqr/A = pq + pr + qr And because of the first equation: pq+pr+qr = 1 Since...

how to implement eigenvalue calculation with MapReduce/Hadoop?

It is possible because PageRank was a form of eigenvalue and that is why MapReduce introduced. But there seems problems in actual implementation, such as every slave computer have to maintain a copy of the matrix? ...

How many candles are in the box?

For the holiday currently described as [ck]?hann?ukk?ah? or thereabouts, 1 candle is lit on the first day, increasing up to a final 8 candles on day 8. However, there is an extra candle each day that is used to light the others. So, when you buy that box in the store, how many candles do you get? ...

Turn while loop into math equation?

I have two simple while loops in my program that I feel ought to be math equations, but I'm struggling to convert them: float a = someValue; int b = someOtherValue; int c = 0; while (a <= -b / 2) { c--; a += b; } while (a >= b / 2) { c++; a -= b; } This code works as-is, but I feel it could be simplified into math equ...