Problem with expand in lagrange interpolation



On 6/13/07, Mario Rodriguez <biomates at telefonica.net> wrote:

> I have found a problem with lagrange interpolation.
>
> Please, look at this output:
>
> (%i11) m:[[140, 15.72], [141, 15.53], [142, 15.19],
>           [143, 16.56], [144, 16.21], [145, 17.39],
>           [146, 17.36], [147, 17.42], [148, 17.60],
>           [149, 17.75], [150, 18.95] ]$
> (%i12) load(interpol)$
> (%i13) poly:lagrange(m)$
> (%i14) subst(x=140,poly);
> (%o14)                              68192.0
>
>
> The result should be 15.72.

I think the difference is due to floating point round-off error.
Try something like: (fpprec : 50, lagrange (bfloat (m)), subst (x=140, %%));

I'll recommend that lagrange apply rat to the input data so all
computations are exact.
Aside from that, there are probably formulations which suppress round-off error.

FWIW
Robert