in reply to Re: Lagrange Polynomials in Perl
in thread Lagrange Polynomials in Perl

It works, once I changed the arrays to array references it worked. I tested it by approximating a sine function, and was able to get very close to the small angle approximation.

Replies are listed 'Best First'.
Re^3: Lagrange Polynomials in Perl
by hdb (Monsignor) on Apr 29, 2015 at 14:39 UTC

    It should be exact for polynomials, correct? Have you tried that?

      It should be exact at the points you supply it, and it does work for that. Unfortunately since the algorithm only sees points and not the whole polynomial, it's a left hand doesn't know what the right hand is doing situation...and you still get some error between the points you supply. Although I have tried it with some polynomials, and it's pretty convincing.

        My understanding from Lagrange_polynomial is that it is exact for polynomials. So if you see differences you might still have an issue.