Subject: Problem with expand in lagrange interpolation
From: Daniel Lakeland
Date: Thu, 14 Jun 2007 08:21:12 -0700
On Wed, Jun 13, 2007 at 05:54:15PM +0200, Mario Rodriguez 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] ]$
I spent a little time last night rewriting the lagrange routine's
computation of the polynomial to use the newton divided differences
form.
However, I was not able to debug the computation of the
coefficients. Here is the alternate code so far, with a small amount
of context, perhaps someone else can see what I'm doing wrong. I think
it involves a bug in the computation of the denominators, I was
fiddling with it last night and this is the last version before giving
up. (note: the variables exes and wyes need to be declared in the block
at the top as well).
/* controlling duplicated x's */
for i:2 thru n do
if tab[i-1][1] = tab[i][1]
then error("Duplicated abscissas are not allowed"),
/* constructing the interpolating polynomial */
exes:map(first,tab),
wyes:map(second,tab),
for i:2 thru n do
for j:i thru n do
(wyes[j]:(wyes[j]-wyes[j-1])/(exes[j+i-1]-exes[j-i+1])),
exes:map(first,tab),
sum(wyes[i]*product(defaults[1]-exes[j-1],j,2,i),i,1,n)
)$
--
Daniel Lakeland
dlakelan at street-artists.org
http://www.street-artists.org/~dlakelan