Explorer les Livres électroniques
Catégories
Explorer les Livres audio
Catégories
Explorer les Magazines
Catégories
Explorer les Documents
Catégories
Mthodes numriques
pour lingnieur
Interpolation
f(x)
2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
-4
-3
-2
-1
0
1
2
Approximation de fonctions
Soit une fonction f (inconnue explicitement)
connue seulement en certains points x
0
,x
1
x
n
ou valuable par un calcul coteux.
Principe :
reprsenter f par une fonction simple, facile valuer
Problme :
il existe une infinit de solutions !
3
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
-4
-3
-2
-1
0
1
2
Approximation de fonctions
Il faut se restreindre une famille de fonctions
polynmes,
exponentielles,
fonctions trigonomtriques
4
Quelques mthodes d'approximation
Interpolation polynomiale
polynmes de degr au plus n
polynmes de Lagrange
diffrences finies de Newton
Interpolation par splines
polynmes par morceaux
Interpolation d'Hermite
informations sur les drives de la fonction approche
5
ab ab
f(x)
P(x)
f(x)+c
f(x)-c
f(x)
P(x)
f(x)+c
f(x)-c
Thorme dapproximation de Weierstrass
| |
| |
| | b a x x P x f
b a x P
b a f
, ) ( ) (
: que tel , sur dfinit , ) ( polynme un existe il , 0 Alors,
, intervalle l' sur continue et dfinie fonction une soit
e <
>
c
c
) (x f
) (x P
c ) (x f
c + ) (x f
grand est polynome du ordre l' plus
petit, est , plusc
Interpolation :
n n n n n ordre : inconnues 1 quations, 1 s, contrainte 1 points, 1 + + + +
6
Interpolation polynomiale
Le problme : les donnes, la solution recherche
mauvaise solution : rsoudre le systme linaire
la combinaison linaire de polynmes est un polynme
( ) ( ) ( )
n i x f x P x P
x f y x x f y x x f y x
i i
i i i i i i
, 0 ), ( ) ( que tel ) (
) ( , ,..., ) ( , ,..., ) ( ,
0 0 0
= =
= = =
0 1 0
) ( ) ( ... ) ( ) ( ainsi
0 ) ( et 1 ) ( que tel
) ( ) ( ... ) ( ) (
0 0
0 0
+ + +
+ + + =
= = =
+ + + =
i n n i i i i i
j i i i
n n i i
x P y x P y x P y x P
i j x P x P
x P y x P y x P y x P
e Vandermond de matrice : ) (
0
V y Va x a x P
n
i
i
i
= =
=
7
Interpolation polynomiale : Lagrange
Thorme
Soient n+1 points distincts x
i
rels et n+1 rels y
i
,
il existe un unique polynme p e P
n
tel que
p(x
i
) = y
i
pour i = 0 n
Construction de p :
avec L
i
polynme de Lagrange
Proprits de L
i
L
i
(x
i
)=1
L
i
(x
j
)=0 (j = i)
=
=
n
0 i
i i
) x ( L y ) x ( p
( )
( )
[
=
=
=
n
i j
0 j
j i
j
i
x x
x x
) x ( L
L est un polynme dordre n
dmonstration
8
0 1
0
1
1 0
1
0
1 0
0
1
1 0
1
0
1 0
0 1 1 0
1 0
1 0
x x
x x
y
x x
x x
y
x x
x x
y
x x
x x
y y
x x
y x y x
x
x x
y y
y
=
Exemple avec n=1
on connat 2 points (x
0
,y
0
) et (x
1
,y
1
)
on cherche la droite y=ax+b (polynme de degr 1)
qui passe par les 2 points :
y
0
= a x
0
+ b a = (y
0
- y
1
) / (x
0
- x
1
)
y
1
= a x
1
+ b b = (x
0
y
1
- x
1
y
0
) / (x
0
- x
1
)
Lagrange : exemple n1
L
0
(x) L
1
(x)
x
0
x
1
y
1
y
0
9
Lagrange : exemple n2
Exemple avec n=2
on connat 3 points (0,1), (2,5) et (4,17)
polynmes de Lagrange associs :
( )( )
8
4 x 2 x
) x ( L
0
=
( )
8
2 x x
) x ( L
2
=
( )
4
4 x x
) x ( L
1
=
0 2 4
-
0 2 4 0 2 4
10
-1 0 1 2 3 4 5
0
5
10
15
20
25
30
Lagrange : exemple n2
calcul du polynme d'interpolation
p(x)=L
0
(x) + 5 L
1
(x) + 17 L
2
(x)
en simplifiant, on trouve p(x)=x
2
+1
11
Lagrange : lalgorithme
Complexit du calcul : n
2
fait
*
fait
) ( ) (
) (
*
; , jusqu' 1 pour
jusqu' 1 pour
l y y y
j x i x
j x x
l l
i j n j
n i
i
i i
i
+
= =
=
Fonction y = lagrange(x,x
i
,y
i
)
12
-1
0
1
2
3
4
5
-10
0
10
20
30
40
50
60
Lagrange : exemple n3
Exemple avec n=2 (fonction approcher y=e
x
)
on connat 3 points (0,1), (2,7.3891) et (4,54.5982)
Polynme d'interpolation
p(x) =L
0
(x) + 7.3891 L
1
(x) + 54.5982 L
2
(x)
13
Lagrange : exemple n3
Erreur d'interpolation e(x) = f(x) - p(x)
-1 0 1 2 3 4 5
-20
-10
0
10
20
30
40
50
60
14
Lagrange : erreur d'interpolation
Thorme :
si f est n+1 drivable sur [a,b], x e [a,b], notons :
I le plus petit intervalle ferm contenant x et les x
i
|(x)=(x-x
0
)(x-x
1
)(x-x
n
)
alors, il existe e I tel que
NB : dpend de x
Utilit = on contrle lerreur dapproximation donc .
la qualit de lapproximation
( )
( )
( )
( ) x
! 1 n
f
x e
) 1 n (
|
+
=
+
15
Lagrange : choix de n
Supposons que l'on possde un nb lev de points pour
approcher f faut-il tous les utiliser ?
(calculs lourds)
Mthode de Neville :
on augmente progressivement n
on calcule des L
i
de manire rcursive
on arrte ds que l'erreur est infrieure un seuil
(dou lutilit du calcul de lerreur)
16
La mthode de Neuville
Dfinition
Thorme
Dmonstration
Application systmatique
( ) ( ) ( )
k k
k
m m m m m m
m m m
y x y x y x k
x P
, ,..., , , , points les
sur calcul Lagrange de polynme ) (
2 2 1 1
2 1
,..., ,
( ) ( )
j i
n i i i n j j j
x x
x P x x x P x x
x P
=
+ +
) ( ) (
) (
,..., 1 , 1 ,..., 1 , 0 ,..., 1 , 1 ,..., 1 , 0
) ( ) ( et ) ( ) ( ); ( ) (
k k j j i i
x f x P x f x P x f x P = = =
3 , 3 4 , 2 , 1 , 0 2 , 3 3 , 2 , 1 1 , 3 3 , 2 0 , 3 3 3
2 , 2 2 , 1 , 0 1 , 2 2 , 1 0 , 2 2 2
1 , 1 1 , 0 0 , 1 1 1
0 , 0 0 0
Q P Q P Q P Q P x
Q P Q P Q P x
Q P Q P x
Q P x
= = = =
= = =
= =
=
i i j i j i j i
P Q
, 1 ,..., 1 , , +
=
17
Lalgorithme de Neuville
Complexit du calcul : n
2
( ) ( )
fait
) , (
fait
) ( ) (
1 1 ) ( 1 ) (
jusqu' 1 pour
jusqu' 1 pour
fait
) ( ) 0 , (
jusqu' 1 pour
n n Q y
j i x i x
) ,j Q(i i x x ) Q(i,j j i x x
Q(i,j)
i j
n i
i y i Q
n i
i i
i i
i
=
=
=
Fonction y = Neuville(x,x
i
,y
i
)
18
Interpolation polynomiale : Newton
Polynmes de Newton :
base = {1, (x-x
0
), (x-x
0
)(x-x
1
), , (x-x
0
)(x-x
1
)(x-x
n-1
)}
on peut r-crire p(x) :
p(x)=a
0
+ a
1
(x-x
0
) + a
2
(x-x
0
)(x-x
1
)++ a
n
(x-x
0
)(x-x
1
)(x-x
n-1
)
calcul des a
k
: mthode des diffrences divises
19
Newton : diffrences divises
Dfinition :
Soit une fonction f dont on connat les valeurs en des points
distincts a, b, c,
On appelle diffrence divise dordre 0, 1, 2,...,n
les expressions dfinies par rcurrence sur lordre k :
k=0 f [a] = f (a)
k=1 f [a,b] = ( f [b] - f [a] ) / ( b - a )
k=2 f [a,b,c] = ( f [a,c] - f [a,b] ) / ( c - b )
f [X,a,b] = ( f [X,b] - f [X,a] ) / ( b - a )
a e X , b e X , a = b
20
Newton : diffrences divises
Thormes :
dtermination des coefficients de p(x) dans la base de
Newton :
f [x
0
, x
1
,, x
k
] = a
k
avec k = 0 n
erreur d'interpolation :
e(x) = f [x
0
, x
1
,, x
n
, x] |(x)
21
Newton : diffrences divises
a
0
a
1
a
2
a
n
Calcul pratique des coefficients :
x
0
f [x
0
]
x
1
f [x
1
] f [x
0
, x
1
]
x
2
f [x
2
] f [x
1
, x
2
] f [x
0
, x
1
, x
2
]
...
f [x
n-3
, x
n-2
, x
n-1
]
x
n
f [x
n
] f [x
n-1
, x
n
] f [x
n-2
, x
n-1
, x
n
] f [x
0
, ..., x
n
]
22
Newton : exemple
a
0
a
2
p(x)=1
+ 2x + x(x-2) (et on retombe sur p(x) = 1 + x
2
)
a
1
(ex. n2) : n=2 (0,1), (2,5) et (4,17)
0
f [x
0
]=1
2
f [x
1
]=5 f [x
0
, x
1
]
=(1-5)/(0-2)=2
4
f [x
2
]=17 f [x
1
, x
2
] f [x
0
, x
1
, x
2
]
=(5-17)/(2-4)=6 = (2-6)/(0-4)=1
23
Newton : lalgorithme
Complexit du calcul : n
2
fait
) , ( (i)
jusqu' 1 pour
fait
fait
) ( ) (
1 1 1
jusqu' 1 pour
jusqu' 1 pour
fait
) ( ) 0 , (
jusqu' 1 pour
i n F a
n i
j i x i x
) ,j F(i ) F(i,j
F(i,j)
i j
n i
i y i F
n i
i i
i
=
=
=
Fonction a = Newton(x
i
,y
i
)
24
-6 -4 -2 0 2 4 6
-6
-4
-2
0
2
4
6
A bas les polynmes
Ex : y=2(1+tanh(x)) - x/10 avec 9 points
entre les points, le polynme fait ce qu'il veut
et plus son degr est lev plus il est apte osciller !
25
Interpolation par splines cubiques
Principe :
on approche la courbe par morceaux (localement)
on prend des polynmes de degr faible (3) pour viter les
oscillations
26
Splines cubiques : dfinition
Dfinition :
On appelle spline cubique dinterpolation une fonction note
g, qui vrifie les proprits suivantes :
g e C
2
[a;b] (g est deux fois continment drivable),
g concide sur chaque intervalle [x
i
; x
i+1
] avec un polynme de degr
infrieur ou gal 3,
g(x
i
) = y
i
pour i = 0 n
Remarque :
Il faut des conditions supplmentaires pour dfinir la spline
dinterpolation de faon unique
Ex. de conditions supplmentaires :
g"(a) = g"(b) = 0 spline naturelle.
27
Splines : illustration
P
1
(x)=o
1
x
3
+|
1
x
2
+_
1
x+o
1
=a
1
(x-x
1
)
3
+b
1
(x-x
1
)
2
+c
1
(x-x
1
)
+d
1
P
2
(x)=a
2
(x-x
2
)
3
+b
2
(x-x
2
)
2
+c
2
(x-x
2
)
+d
2
28
Splines cubiques : dtermination
Dtermination de la spline dinterpolation
g concide sur chaque intervalle [x
i
; x
i+1
] avec un polynme de
degr infrieur ou gal 3
g" est de degr 1 et est dtermin par 2 valeurs:
m
i
= g"(x
i
) et m
i+1
= g"(x
i+1
) (moment au noeud ni)
Notations :
h
i
= x
i+1
- x
i
pour i = 0 n-1
o
i
= [x
i
; x
i+1
]
g
i
(x) le polynme de degr 3 qui concide avec g sur lintervalle o
i
29
Splines cubiques : dtermination
g"
i
(x) est linaire :
x e o
i
on intgre
(a
i
constante)
on continue
(b
i
constante)
g
i
(x
i
) = y
i
g
i
(x
i+1
) = y
i+1
( )
i
1 i
i
i
i
1 i i
h
x x
m
h
x x
m x g
+
=
' '
+
+
( )
( ) ( )
( )
i i i
i
3
1 i
i
i
3
i
1 i i
b x x a
h 6
x x
m
h 6
x x
m x g + +
=
+
+
( )
( ) ( )
i
i
2
1 i
i
i
2
i
1 i i
a
h 2
x x
m
h 2
x x
m x g +
=
'
+
+
i
2
i i
i
b
6
h m
y + =
i i i
2
i 1 i
1 i
b h a
6
h m
y + + =
+
+
1
2
30
Splines cubiques : dtermination
g'(x) est continue :
et
on remplace les a
i
dans :
Rappel : on cherche les m
i
(n+1 inconnues)
on a seulement n-1 quations grce
il faut rajouter 2 conditions, par exemple
m
0
= m
n
=0 (spline naturelle)
( ) ( )
i 1 i 1 i
1 i
i i
i
i i i
x g a
2
h
m a
2
h
m x g
' = + = + = '
( ) ( )
i 1 i
i
i 1 i
i
i
m m
6
h
y y
h
1
a =
+ +
3
1
2
3
( ) ( ) ( )
|
|
.
|
\
|
= + + +
+ + 1 i i
1 i
i 1 i
i
1 i i i 1 i i 1 i 1 i
y y
h
1
y y
h
1
6 m h m h h 2 m h 4
4
31
Splines cubiques : dtermination
Ex de rsolution avec h
i
= x
i+1
- x
i
constant :
forme matricielle :
Tm=f
T inversible (diagonale strictement dominante)
( ) ( ) ( )
|
|
.
|
\
|
= + + +
+ + 1 i i
1 i
i 1 i
i
1 i i i 1 i i 1 i 1 i
y y
h
1
y y
h
1
6 m h m h h 2 m h
4
( )
i 1 i i 1 i
2
1 i i 1 i
f y y 2 y
h
1
m m 4 m = + = + +
+ +
|
|
|
|
|
|
.
|
\
|
=
|
|
|
|
|
|
.
|
\
|
|
|
|
|
|
|
.
|
\
|
1 n
1
1 n
1
f
f
m
m
4 1
1 4 1
1 4 1
0 1 4
32
Splines cubiques : lalgorithme
Complexit du calcul : complexit du solveur
( )
( )
( ) ( )
fait
6
) ( ) (
6
1
) (
1 ; 1 pour
] 0 , , 0 [
\
1 2 1 2
fait
6 ) 1 (
2 ) 1 , (
) 1 , (
2 ) , (
1 ; 2 pour
1 1
1
1 1
1
1
i i
i i
i
i i
i
i
i i
i
i i
i
i
i i
h m
i y i b
m m
h
y y
h
i a
n i
m m
f T m
:n- , :n- T T
h
y y
h
y y
i f
h i i T
h i i T
h h i i T
n i
=
|
|
.
|
\
|
+
+
=
+ +
33
Splines cubiques : exemple
Ex : y=2(1+tanh(x)) - x/10 avec 9 points
-6
-4
-2
0
2
4
6
-6
-4
-2
0
2
4
6
spline
polynme de degr 8
34
Conclusion
Interpolation polynomiale
valuer la fonction en un point : Polynme de Lagrange ->
mthode de Neville
compiler la fonction : Polynme de Newton
Interpolation polynomiale par morceau : splines
spline cubique dinterpolation
spline cubique dapproximation (on rgularise)
b spline
spline gnralise : splines gausinnes (multidimensionelle)
approximation - apprentissage