问题
I know I can use Mathematica, but sadly I dont have one. I just want to find the A,B,C,D form matrix
| X1^3 x1^2 X1 1 | |A| |y0|
| X2^3 x2^2 X2 1 | |B| |y1|
| X3^3 x3^2 X3 1 | X |C| = |y2|
| X4^3 x4^2 X4 1 | |D| |y3|
I just want to find the simplified equations for A, B, C and D.
Actually I am trying to do a program in arduino that requires curve fitting using 4 points, so that I can predict the future points. I have seen this post , but parabola isn't accurate enough for my need.
I have already tried http://www.wolframalpha.com/.
linearSolve [{{(x1)^3, (x1)^2, x1, 1},
{(x2)^3, (x2)^2, x2, 1},
{(x3)^3, (x3)^2, x3, 1},
{(x4)^3, (x4)^2, x4, 1}}, {{y1},{y2},{y3},{y4}}]
It returns a long result, which can be simplified. But, I cannot enter the full result in the search bar for simplifying (It gives me the error :Input Too Long!).
Any Ideas? Well I guess it would be possible in desktop versions.
Even after that, if the result is quite long, please substitute x1 = 0 and let me know the simplified result.
回答1:
// Input data: arrays x[] and y[]
// x[1],x[2],x[3],x[4] - X values
// y[1],y[2],y[3],y[4] - Y values
// Calculations
A = 0
B = 0
C = 0
D = 0
S1 = x[1] + x[2] + x[3] + x[4]
S2 = x[1]*x[2] + x[1]*x[3] + x[1]*x[4] + x[2]*x[3] + x[2]*x[4] + x[3]*x[4]
S3 = x[1]*x[2]*x[3] + x[1]*x[2]*x[4] + x[1]*x[3]*x[4] + x[2]*x[3]*x[4]
for i = 1 to 4 loop
C0 = y[i]/(((4*x[i]-3*S1)*x[i]+2*S2)*x[i]-S3)
C1 = C0*(S1 - x[i])
C2 = S2*C0 - C1*x[i]
C3 = S3*C0 - C2*x[i]
A = A + C0
B = B - C1
C = C + C2
D = D - C3
end-loop
// Result: A, B, C, D
回答2:
If you don't have Mathematica you can use wolframalpha
Your equation
来源:https://stackoverflow.com/questions/16883005/can-sombody-simplify-this-equation-for-me