je cherche à écrire l'algorithme d'interpolation lagrangienne sous Maple (version 10) : http://fr.wikipedia.org/wiki/Interpolation_lagrangienne
En fait, j'ai un petit problème d'entrée, pour calculer les Lk. Voici ce que je rentre :
Code : Tout sélectionner
> restart;
> with(linalg):
Warning, the protected names norm and trace have been redefined and unprotected
> Lk:=proc(x,n)local S1,S2,i,k,L;
> L:=vector(n,0):
> for k from 1 by 1 to n do
> S1:=1:
> S2:=1:
> print('x[k]'=x[k]);
> for i from 1 by 1 to n do
> if (i!=k) then
> print('x[i]'=x[i]);
> S1:=S1*(x-x[i]):
> print('S1'=S1);
> S2:=S2*(x[k]-x[i]):
> print('S2'=S2);
> else end if:
> end do:
> end do:
> end proc:
>
> n:=3:
> x:=vector(n,[1,2,3]);
x := [1, 2, 3]
> Lk(x,n);
x[k] = 1
x[i] = 1
S1 = x - 1
S2 = 0
x[k] = 2
x[i] = 2
S1 = x - 2
S2 = 0
x[k] = 3
Merci d'avance .
Cordialement.
Clément.