zozo
Inscrit le: 03 Jan 2013 Messages: 125
|
Posté le: 04 Mar 2010 8:42 Sujet du message: Polynôme interpolateur d'Hermite |
|
|
Bonjour,
en espérant que ce sera utile à certains sur ce forum, voici une procédure qui calcule le polynôme interpolateur d'Hermite P d'une fonction f en certains points (ceux de la liste L).
Si L=[x1,x2, ... , xn], on a donc pour tout i de l'ensemble {1,..,n}, P(xi)=f(xi) et P'(xi)=f'(xi).
Code: |
> interp_hermite:=proc(f,L)
> local P,a,n,sys,vars;
> n:=nops(L):
> a:=array(0..2*n-1):
> P:=unapply(sum(a[k]*x^k,k=0..2*n-1),x);
> sys:={seq(P(L[i])=f(L[i]),i=1..n),seq(D(P)(L[i])=D(f)(L[i]),i=1..n)};
> vars:={seq(a[k],k=0..2*n-1)};
> assign(solve(sys,vars)):
> unapply(sum(a[k]*x^k,k=0..2*n-1),x)
> end proc:
> f:=x->ln(2*x/(x^2+1));
> h:=interp_hermite(f,[1,2,3,4]);
2 x
f := x -> ln(------)
2
x + 1
2999
h := x -> ---- - 36 ln(4/5) + 64 ln(3/5) + 47/3 ln(8/17)
85
/ 134357\
+ |150 ln(4/5) - 240 ln(3/5) - 550/9 ln(8/17) - ------| x +
\ 1020 /
/203207 10523 \ 2
|------ + 364 ln(3/5) - 1009/4 ln(4/5) + ----- ln(8/17)| x
\ 1020 108 /
+
/ 645947 8891 \ 3
|- ------ - 289 ln(3/5) + 881/4 ln(4/5) - ---- ln(8/17)| x
\ 4080 108 /
/18293 2155 \ 4
+ |----- + 130 ln(3/5) - 215/2 ln(4/5) + ---- ln(8/17)| x
\ 255 54 /
/ 38011 601 \ 5
+ |- ----- - 133/4 ln(3/5) + 59/2 ln(4/5) - --- ln(8/17)| x
\ 2040 54 /
/2633 179 \ 6
+ |---- + 9/2 ln(3/5) - 17/4 ln(4/5) + --- ln(8/17)| x
\1020 108 /
/ 201 11 \ 7
+ |- ---- - 1/4 ln(3/5) + 1/4 ln(4/5) - --- ln(8/17)| x
\ 1360 108 /
> plot([f(x),h(x)],x=0..5,color=[red,blue]);
|
A plus tard sur ce forum. |
|