News for hackers. Stuff that matters.
Re:Polynomial Interpolation by thomasahle on Wednesday February 08, 2023 @07:05PM (#34717675)
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".

Re:Polynomial Interpolation by chewbaxxa on Wednesday February 08, 2023 @07:14PM (#34717756)
See also (M^T M)^-1 M^T
Re:Polynomial Interpolation by thomasahle on Wednesday February 08, 2023 @07:16PM (#34717773)
Sure, if you have more equations the degree, but that doesn't seem to be the case in the article.
Re:Polynomial Interpolation by thomasahle on Wednesday February 08, 2023 @09:54PM (#34719194)
Edit: 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]
Re:Polynomial Interpolation by wnkrshm on Thursday February 09, 2023 @03:00AM (#34721005)
If 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.
Re:Polynomial Interpolation by thomasahle on Thursday February 09, 2023 @12:50PM (#34728086)
For 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.