I was following this thread and copied the code in my project. Playing around with it turns out that it seems not to be very precise.
Recall the formula: y = ax^2 + bx +c
Since the first given point I have is at x1 = 0, we already have c=y1 . We just need to find a and b. Using:
y2 = ax2^2 + bx2 +c y3 = ax3^2 + bx3 +c
Solving the equations for b yields:
b = y/x - ax - cx
Now setting both equations equal to each other so b falls out
y2/x2 - ax2 - cx2 = y3/x3 - ax3 - cx3
Now solving for a gives me:
a = ( x3*(y2 - c) + x2*(y3 - c) ) / ( x2*x3*(x2 - x3) )
(is that correct?!)
And then using again b = y2/x2 - ax2 - cx2 to find b. However so far I haven't found the correct a and b coeffs. What am I doing wrong?
Edit
Ok I figured out, but had to use a CAS because I don't know how to invert symbolic matrices by hand. (Gauss algo doesn't seem to work)
Writing it down in Matrix form:
| 0 0 1 | |a|
| x2^2 x2 1 | * |b| = Y
| x3^2 x3 1 | |c|
Let's call the Matrix M and multiply from the left with M^(-1)
|a|
|b| = M^(-1)*Y
|c|
Then I got out of maple:
a = (-y1 * x2 + y1 * x3 - y2 * x3 + y3 * x2) / x2 / x3 / (-x2 + x3)
Guess I did a stupid mistake somewhere above.
Which gives me the same result as the formula in the thread quoted above.