2.interp Deriv Integ
2.interp Deriv Integ
2.interp Deriv Integ
dérivation polynomiale
http://www.fast.u-psud.fr/~kasperski/enseignement/M1PAM/
Interpolation: on connaît la valeur d’une fonction f(x) sur un
ensemble de points {xi , i = 0, N } dit support d’interpolation:
f ( xi ) = f i
f0
fN
fi
x0 ………….. xi X
………….. xN
… Sinon : extrapolation 2
Représentation discrète d’une fonction continue
Maillage de la solution
Utilisation
d’une
Base de
fonctions
Décomposition polynomiale
N
polynôme : p(x) = ∑ a i x i
i =0
xi x
Support
δxi
Analyse de précision d’une interpolation en raisonnement asymptotique δx << 1
f ( x) ≈ f ( xi ) + δxf ' ( xi ) < f ( xi ) + δxi f ' ( xi )
L’erreur décroit comme δx : l’interpolation est d’ordre 1. Vérification Matlab
Ordre d’une approximation : si l’erreur effectuée sur une valeur décroit comme
δxp, alors l’évaluation est d’ordre p.
5
Approches de base 1D : approximation linéaire.
6
Approches de base 1D : approximation parabolique.
7
Polynôme de Lagrange :
n
fk
∑ ( x − xk ) v ' ( xk ) O(n) opérations si on a
P( x) = k =n 0
1 stocké les v ' ( xk )
∑
k = 0 ( x − xk ) v ' ( xk )
9
Algorithme de Aitken: construction progressive de
la valeur interpolée.
n
gré
Soit R(x) le polynôme construit sur {x0 , x1 ,..., xn−1 , b}
De
1
n+
Le polynôme P(x) construit sur {x0 , x1 ,..., xn−1 , a, b}
gré
De
(b − x)Q( x) − (a − x) R ( x)
S’écrit: P( x) =
b−a
Prise en compte d’un nombre de points croissant
Arrêt des itérations fonction d’un critère de précision
10
Tableau Aitken
12
Caractérisation de l’erreur. Soit f ∈ C n +1 [a, b], si a ≤ x0 < x1 < ... < xn ≤ b.
W s’annule n+2 fois, W’ s’annule n+1 fois, … Wn+1 s’annule une fois en un point
ξ ∈ [x0 , xn ]
W n +1 (t ) = f n +1 (t ) − ( n + 1)! K ( x) W n +1 (ξ ) = f n +1 (ξ ) − (n + 1)! K ( x) = 0
f n +1 (ξ )
K ( x) =
(n + 1)!
( x − x0 )( x − x1 )...( x − xn ) n+1
Erreur d’interpolation : f ( x) − P ( x ) = f (ξ )
(n + 1) !
13
Evaluation de l’erreur d’interpolation
2
T0 ( x) = 1 T1 ( x) = x 2
T ( x ) = 2 x −1
2k − 1
Zéros du polynôme: xk = cos π , k = 1,2,..., n
2n
k
Extrema: x'k = cos π , k = 0,1,..., n et Tn ( x'k ) = (− 1)k
n
1 son coefficient de plus haut
Polynôme normalisé: Tn = n−1 Tn 15
2 degré vaut 1
Polynômes de Chebyshev
1,5
1 T0(x)
T1(x)
0,5 T2(x)
T n (x)
T3(x)
0
T4(x)
-0,5 T5(x)
T6(x)
-1
T7(x)
-1,5 T8(x)
-1 -0,7 -0,4 -0,1 0,2 0,5 0,8 T9(x)
x 16
Propriété:
( x − x0 )( x − x1 )...( x − xn ) n +1 Tn +1 ( x ) n +1
f ( x ) − P( x ) = f (ξ ) = f (ξ )
(n + 1) ! (n + 1) !
17
Preuve :
Supposons p ( x) un polynôme de degré n de coefficient de plus haut degré égal à 1.
1
Si max p ( x) < max Tn ( x) = n −1
−1≤ x ≤1 −1≤ x ≤1 2
− p( x' ), k = 0,1,..., n
n −1 k
2
r prend des signes alternés sur n+1 points et a donc n zéros. Il est de degré n-1
donc :
r = 0 et p = T n
Ce qui contredit l’hypothèse.
18
Décomposition sur la base Chebyshev.
n n
f ( x) = ∑ fˆiTi ( x) = ∑ fˆi cos(i. arccos( x))
i =0 i =0
i =0 i =0 i =0
19
...
f ( x ) = (−1)i cos(ikπ / n) fˆ = T . fˆ
k
i sp i
...
... ...
fˆ = T −1. f ( x ) = T . f ( x )
i sp k
ps
k
... ...
20
Les splines
Interpolation par morceaux avec de bons raccords aux nœuds.
si ( xi ) = f i , i = 0, n Interpolation correcte
si' −1 ( xi ) = si' ( xi ), i = 1, n − 1
'' ''
Continuité aux raccords des dérivées
s ( xi ) = s ( xi ), i = 1, n − 1
i −1 i
21
Par interpolation de la dérivée seconde :
'' x −x
''
s ( x) ≈ f i i +1 + f i +'' 1
x − xi ( x − x ) + f '' ( x − xi ) + a ( x − x ) + b ( x − x )
⇒ si ( x) = f i '' i +1
3 3
i i +1 i i +1 i i
hi hi 6hi 6hi
hi2 f h
Conditions : si ( xi ) = f i ⇒ f i ''
+ ai hi = f i ⇒ ai = i − f i '' i
6 hi 6
hi2 f h
si ( xi +1 ) = f i +1 ⇒ f ''
i +1 + bi hi = f i ⇒ bi = i +1 − f i +'' 1 i
6 hi 6
( x − x )3
h ( x − x )3
hi fi f
''
si ( x) = f i i +1 i
''
− ( xi +1 − x ) + f i +1 i
− ( x − xi ) + ( xi +1 − x ) + i +1 ( x − xi )
6hi 6 6hi 6 hi hi
22
' '
Il manque le raccord des dérivées premières : si ( xi ) = si −1 ( xi )
− ( xi +1 − x )2 hi '' ( x − xi )
2
h f f
s ( x) = f i
'
i
''
+ + f i +1 − i − i + i +1
2hi 6 2hi 6 hi hi
2hi h f f h 2h f f
− f i '' − f i +'' 1 i − i + i +1 = f i −'' 1 i −1 + f i '' i −1 − i −1 + i
6 6 hi hi 6 6 hi −1 hi −1
f −f f − f i −1
⇒ hi f i +'' 1 + 2(hi + hi −1 ) f i '' + hi −1 f i −'' 1 = 6 i +1 i − i , i = 1,..., n − 1
hi hi −1
23
Intégration
Approches naïves.
xi x
δxi
approximations de la fonction :
∫ f ( x)dx = (b − a )∫ f (a + t (b − a ))dt
a 0
∫ f ( x)dx = f (1 / 2)
0
0 1 2
Approximation linéaire : formule du trapèze
1
f (0) + f (1)
∫
0
f ( x )dx =
2
0 1 2
1
f (0) + 4 f (1 / 2) + f (1)
∫
0
f ( x )dx =
6
0 1 2
1 s
i −1
Généralisation : formule de Newton-Cotes ∫ f ( x )dx = ∑ bi f
0 i =1 s −1
pulcherrima et utilissima regula de Newton
b
I ( f ) = ∫ µ ( x) f ( x)dx : µ ( x) connue analytiquement
a
f ( x) connu en n + 1 points xk .
n
But: approcher I(f) par I n ( f ) = ∑ Akn f ( xk )
k =0
Formule de quadrature
29
Quadrature de type interpolation
b
b n
I n ( f ) = ∫ Pn ( x) µ ( x)dx = ∑ ∫ l j ( x) µ ( x)dx f ( x j )
j =0 a
a
1442443
Anj
b
Erreur : Rn ( f ) = I ( f ) − I n ( f ) = ∫ µ ( x)( f ( x) − Pn ( x) )dx
a
b
( x − x0 )...( x − xn ) n+1
Rn ( f ) = ∫ µ ( x) f (ξ ) dx
a
(n + 1)!
30
Exactitude…relative
31
Si elle est exacte sur Pn:
b n
∫ µ ( x) P( x)dx = ∑
n
Ak P( xk ) pour tout polynôme de Pn
a k =0
b n
∫ µ ( x)l j ( x)dx = ∑
n n
Ak l j ( xk ) = Aj Elle est de type interpolation.
a k =0
∫ µ ( x) P( x)dx = ∫ µ ( x) Pp ( x)dx =∑
n
Ak P( xk )
a a k =0
32
Une formule de quadrature a un degré de précision n si elle est
exacte sur Pn mais pas sur Pn+1.
b n
On écrit : ∫ µ ( x) f ( x)dx = ∑ Ain f ( xi ) pour f ( x) = 1, x,.., x n
a i =0
n
Une formule de quadrature I n ( f ) = ∑ Akn f ( xk ) sera dite stable si :
k =0
n
∀{ε 0 , ε 1 ,..., ε n }, ∃M indépendante de n / ∑ Aknε k ≤ M max ε k .
k
k =0
Interprétation:
des erreurs sur f ( xk ) ont un effet borné sur l' évaluation de I n ( f )
même lorsque n → ∞
34
Convergence
n
I n ( f ) = ∑ Akn f ( xk ) converge sur un ensemble V si ∀f ∈ V ,
k =0
b
n n
lim ∑ Ak f ( xk ) = ∫ µ ( x) f ( x) dx
n→∞
k =0 a
Soit plus simplement : lim I n ( f ) = I ( f )
n →∞
35
Intégration sur support homogène compris entre a et b inclus:
i Quadrature instable
xi = a + (b − a ) , i = 0, n
n
36
N N N
Primitivation en Chebyshev ∫ f ( x )dx = ∑α k Tk = ∫ ∑ ck Tk ( x )dx =∑ ck ∫ Tk ( x )dx
k =0 k =0 k =0
∫ T dx = x = T
0 1 1 1
x 2 T2 T0
Pour k>1 : ∫ Tk dx = 2k + 2 Tk +1 − 2k − 2 Tk −1
∫ T1dx = 2 = 4 + 4 (démo chapitre suivant)
N
T2 T0 N Tk +1 Tk −1
∑
k =0
α k Tk = c0T1 + c1 + + ∑ ck −
4 4 k = 2 2k + 2 2 k − 2
T2 T0 N +1 ck −1 N −1
ck +1
= c0T1 + c1 + + ∑ Tk − ∑ Tk
4 4 k =3 2k k =1 2k
c1 c2 N ck −1 ck +1 cN
= T0 + T1 c0 − + ∑ Tk − N +1
+ T
4 2 k = 2 2k 2k 2N
Pn ( x) → P 'n ( x) directement
Maillage à pas constant= formules instables
interpolation polynômiale
formulation locale locale
développement de Taylor
39
Maillage homogène du type : x i = x0 + iδx
f i = f ( xi ) connus, on veut évaluer f i′, f i′....
′
Exemple:
δx 2 δx n
f i +1 = f i + δxf i′+ f i′′+ ... f i[ n ] + o(δx n+1 )
2 n!
δx 2 (−δx) n [ n ]
f i −1 = f i − δxf i′+ f i′′− ... + f i + o(δx n+1 )
2 n!
f i +1 − f i−1 δx 2 [ 3]
f i′ = + f i + O(δx 4 )
2δx 6
Formule approchée Erreur (ici d’ordre 2)
Beaucoup de façons d’écrire une dérivée, de façon
plus ou moins précise… Illustration en TD. 40
Dérivée décentrée au second ordre
δx 2 δx n [ n ] n +1
f
i = f i +1 − δx f ′
i +1 + f ′′
i +1 + ... f i +1 + o ( δ x )
2 n!
n
f = f − 2δxf ′ + 2δx 2 f ′′ + ... ( 2δx ) f [ n ] + o(δx n +1 )
i −1 i +1 i +1 i +1
n!
i +1
41
Utilisation du polynôme de Lagrange:
Sur trois points :
P ( x ) = f i −1
(x − xi )(x − xi +1 ) + f (x − xi −1 )(x − xi +1 ) + f i +1
(x − xi )(x − xi −1 )
(xi −1 − xi )(xi −1 − xi +1 ) i (xi − xi −1 )(xi − xi +1 ) (xi +1 − xi )(xi +1 − xi −1 )
P ' ( x ) = f i −1
(x − xi ) + (x − xi +1 ) + f (x − xi −1 ) + (x − xi +1 ) + f i +1
(x − xi ) + (x − xi −1 )
(xi −1 − xi )(xi −1 − xi +1 ) i (xi − xi −1 )(xi − xi +1 ) (xi +1 − xi )(xi +1 − xi −1 )
Pour évaluer cette dérivée en un point du maillage, il suffit de remplacer x par la coordonnée
du point de maillage voulu. Par exemple, pour x=xi+1
P ' ( x ) = f i −1
(xi +1 − xi ) + fi
(xi +1 − xi −1 ) + f i +1
(xi +1 − xi ) + (xi +1 − xi −1 )
(xi −1 − xi )(xi −1 − xi +1 ) (xi − xi −1 )(xi − xi +1 ) (xi +1 − xi )(xi +1 − xi −1 )
1 0 . . . . . . 0 f 0 0
1 − 2 1 0 . . . . 0 f1 2δx 2
O O O M M
O O O f 2δx 2
i −1
i 0 ... 0 1 − 2 1 0 ... 0 f i = 2δx
2
2
O O O f i +1 2δx
O O O M M
2
0 . . . . 0 1 −2 1 f n−1 2δx
0 . . . . . . 0 1 f n 1
Ligne n fn = 1 C.L. en x=1
2
f
Ligne i i +1 − 2 f i + f i −1 = 2δx Schéma
44
∂ 2 f ∂ 2 f
Problème 2D : 2 + 2 = s ( x, y ), x, y ∈ [0,1]
∂x ∂y
f (bord ) imposé
xi = iδx, i = 0, n avec δx = 1 / n
On pose , f i , j = f ( xi , y j )
y j = jδy, j = 0, m avec δy = 1 / m
Schéma :
f i +1, j − 2 f i , j + f i −1, j f i , j +1 − 2 f i , j + f i , j −1
2
+ 2
= si , j , i = 1, n − 1, j = 1, m − 1
δx δy
(n − 1)(m − 1) équations
m+1
m+1
j=1,m+1
m+1
n+1
m+1
m+1
i=1,n+1
46
47
Conditions aux limites Neumann
Il suffit de remplacer la ligne de l’opérateur correspondant à la condition aux
limites en question par la dérivée décentrée au bord. (à gauche ou droite selon le
bord).
∂f 3 f − 4 f1, j + f 2 , j
(0, y j ) ≈ 0, j = cste à gauche
∂x 2δx
∂f − 3 f n , j + 4 f n −1, j − f n − 2, j
(1, y j ) ≈ = cste à droite
∂x 2δx
∂f 3 f − 4 f i ,1 + f i , 2
( xi ,0) ≈ i , 0 = cste en bas
∂y 2δy
∂f − 3 f i ,m + 4 f i ,m −1 − f i ,m − 2
( xi ,1) ≈ = cste en haut
∂y 2δy
Aux coins, le choix existe d’imposer la condition aux bords horizontaux
ou verticaux. En général, privilégier la condition de Dirichlet.
Attention : imposer Neumann partout est impossible car le problème serait
indéterminé et l’opérateur non inversible.
Il faut au moins une condition de Dirichlet en un point.
48
Retour à Chebyshev : dérivation
n n
f ( x) = ∑ fˆiTi ( x) = ∑ fˆi cos(i. arccos( x))
i =0 i =0
n n
la moitié de termes non nuls
f ' ( x) = ∑ fˆiT 'i ( x) = ∑ fˆ 'i Ti ( x)
i =0 i =0
On cherche la matrice de dérivation : fˆ ' = fˆ
i k
f ' N est nul.
f 0 disparaît
f 'i ne dépend que de f k , k > i
49
θ = arccos(x)
k +1
T 'k +1 = sin(( k + 1)θ ) T 'k +1 T 'k −1 sin((k + 1)θ ) − sin((k − 1)θ )
1 − x2
k −1 ⇒ − =
T 'k −1 = sin(( k − 1)θ ) k + 1 k − 1 1 − x2
1 − x2
T 'k +1 T 'k −1 sin(θ ) cos(kθ )
− =2 = 2 cos kθ = 2Tk
k +1 k −1 sin θ
n n n −1 n
50
Construction de la matrice : n=6
0 1 0 3 0 5 0
0 0 4 0 8 0 12
0 0 0 6 0 10 0
0 0 0 0 8 0 12
0 0 0 0 0 10 0
0 0 0 0 0 0 12
0 0 0 0 0 0 0
51
Dérivée dans l’espace physique :
53
Programmes Matlab en TP
54