4 ms·
It's just ax1^3 + bx1^2 + cx1 + d = y1 ax2^3 + bx2^2 + cx2 + d = y2 ax3^3 + bx3^2 + cx3 + d = y3 ax4^3 + bx4^2 + cx4 + d = y4 As a matrix:
by thomasahle 4y ago
It's just
ax1^3 + bx1^2 + cx1 + d = y1
ax2^3 + bx2^2 + cx2 + d = y2
ax3^3 + bx3^2 + cx3 + d = y3
ax4^3 + bx4^2 + cx4 + d = y4
As a matrix:
[x1^3 + x1^2 + x1 + 1] [a] = [y1]
[x2^3 + x2^2 + x2 + 1] [b] = [y2]
[x3^3 + x3^2 + x3 + 1] [c] = [y3]
[x4^3 + x4^2 + x4 + 1] [d] = [y4]
If the matrix is M, we just want to find M^(-1)y.
I think hackers should know enough linear algebra to do that, without "having to go asking the maths gods".
- chewbaxxa 4y agoSee also (M^T M)^-1 M^T
- thomasahle 4y agoSure, if you have more equations the degree, but that doesn't seem to be the case in the article.
- thomasahle 4y agoEdit: Should of course be without plusses in the matrix form: [x1^3, x1^2, x1, 1] [a] = [y1] [x2^3, x2^2, x2, 1] [b] = [y2] [x3^3, x3^2, x3, 1] [c] = [y3] [x4^3, x4^2, x4, 1] [d] = [y4]
- wnkrshm 4y agoIf there is a way of doing it without inversion it's probably more accurate - some people go out of their way to formulate methods without inversion to reduce inaccuracies.
- thomasahle 4y agoFor sure. I just wanted to point out the approach that arguably required "the least math knowledge". Also, OP was solving a degree four problem and wanted a closed form. For better stability just use `x = np.linalg.solve(M, y)`, or whichever linear solver you expect to be fast.