Méthodes Numériques I
Algorithmique numérique
François Cuvelier
Laboratoire d’Analyse Géométrie et Applications Institut Galilée
Université Paris XIII.
6 avril 2016
6 avril 2016 1 / 14
Plan
1
Polynômes d’interpolation de Lagrange
2
Dérivation numérique
3
Intégration numérique
4
Résolution de systèmes linéaires Matrices particulières
Matrices diagonales
Matrices triangulaires inférieures Matrices triangulaires supérieures
Méthode de Gauss-Jordan
Plan
1
Polynômes d’interpolation de Lagrange
2
Dérivation numérique
3
Intégration numérique
4
Résolution de systèmes linéaires Matrices particulières
Matrices diagonales
Matrices triangulaires inférieures Matrices triangulaires supérieures
Méthode de Gauss-Jordan
Dérivation numérique 6 avril 2016 3 / 14
Plan
1
Polynômes d’interpolation de Lagrange
2
Dérivation numérique
3
Intégration numérique
4
Résolution de systèmes linéaires Matrices particulières
Matrices diagonales
Matrices triangulaires inférieures Matrices triangulaires supérieures
Méthode de Gauss-Jordan
Plan
1
Polynômes d’interpolation de Lagrange
2
Dérivation numérique
3
Intégration numérique
4
Résolution de systèmes linéaires Matrices particulières
Matrices diagonales
Matrices triangulaires inférieures Matrices triangulaires supérieures
Méthode de Gauss-Jordan
Résolution de systèmes linéaires 6 avril 2016 5 / 14
Système diagonal
Soit
AP
MnpKq diagonale inversible et b b b P
Kn.
x
i“ b
i{A
i,i, @i P v1, nw. (1)
Algorithme 1 FonctionRSLMATDIAG permettant de résoudre le sys- tème linéaire à matrice diagonale inversible
Axxx“bbb.
Données : A : matrice diagonale deMnpRqinversible.
bbb : vecteur deRn. Résultat : xxx : vecteur deRn.
1: FonctionxxxÐRSLMATDIAG(A,bbb) 2: PouriÐ1ànfaire
3: xpiq Ðbpiq{Api,iq 4: Fin Pour
5: Fin Fonction
Système triangulaire inférieur
Soit
AP
MnpKq triangulaire inférieure inversible (A
i,j“ 0 si i ă j)
Ax
x x “ b b b ðñ
¨
˚
˚
˚
˚
˝
A
1,10 . . . 0
.. . . .. ... .. . .. . . .. 0 A
n,1. . . . . . A
n,n˛
‹
‹
‹
‹
‚
¨
˚
˚
˚
˚
˝ x
1.. . .. . x
n˛
‹
‹
‹
‹
‚
“
¨
˚
˚
˚
˚
˝ b
1.. . .. . b
n˛
‹
‹
‹
‹
‚
A
inversible ðñ
A
i,i‰ 0, @ i P v 1, n w
Soit i P v1, nw, pAx x x q
i“ b
i, ðñ
n
ÿ
j“1
A
i,jx
j“ b
i.
b
i“
i´1
ÿ
j“1
A
i,jx
j` A
i,ix
i`
n
ÿ
j“i`1
A
i,jlo omo on
“0
x
j“
i´1
ÿ
j“1
A
i,jx
j` A
i,ix
ix
i“ 1 A
i,i¨
˝ b
i´
i´1
ÿ
j“1
A
i,jx
j˛
‚ , @i P v1, nw. (2)
Résolution de systèmes linéaires Matrices particulières 6 avril 2016 7 / 14
Système triangulaire inférieur
Soit
AP
MnpKq triangulaire inférieure inversible (A
i,j“ 0 si i ă j)
Ax
x x “ b b b ðñ
¨
˚
˚
˚
˚
˝
A
1,10 . . . 0
.. . . .. ... .. . .. . . .. 0 A
n,1. . . . . . A
n,n˛
‹
‹
‹
‹
‚
¨
˚
˚
˚
˚
˝ x
1.. . .. . x
n˛
‹
‹
‹
‹
‚
“
¨
˚
˚
˚
˚
˝ b
1.. . .. . b
n˛
‹
‹
‹
‹
‚
A
inversible ðñ A
i,i‰ 0, @ i P v 1, n w
Soit i P v1, nw, pAx x x q
i“ b
i, ðñ
n
ÿ
j“1
A
i,jx
j“ b
i.
b
i“
i´1
ÿ
j“1
A
i,jx
j` A
i,ix
i`
n
ÿ
j“i`1
A
i,jlo omo on
“0
x
j“
i´1
ÿ
j“1
A
i,jx
j` A
i,ix
ix
i“ 1 A
i,i¨
˝ b
i´
i´1
ÿ
j“1
A
i,jx
j˛
‚ , @i P v1, nw. (2)
Système triangulaire inférieur
Soit
AP
MnpKq triangulaire inférieure inversible (A
i,j “0 siiăj)Ax
x x “ b b b ðñ
¨
˚
˚
˚
˚
˝
A
1,10 . . . 0
.. . . .. ... .. . .. . . .. 0 A
n,1. . . . . . A
n,n˛
‹
‹
‹
‹
‚
¨
˚
˚
˚
˚
˝ x
1.. . .. . x
n˛
‹
‹
‹
‹
‚
“
¨
˚
˚
˚
˚
˝ b
1.. . .. . b
n˛
‹
‹
‹
‹
‚
A
inversible ðñ A
i,i‰ 0, @ i P v 1, n w
Soit i P v1, nw, pAx x x q
i“ b
i, ðñ
n
ÿ
j“1
A
i,jx
j“ b
i.
b
i“
i´1
ÿ
j“1
A
i,jx
j` A
i,ix
i`
n
ÿ
j“i`1
A
i,jlo omo on
“0
x
j“
i´1
ÿ
j“1
A
i,jx
j` A
i,ix
ix
i“ 1 A
i,i¨
˝b
i´
i´1
ÿ
j“1
A
i,jx
j˛
‚, @i P v1, nw. (2)
Résolution de systèmes linéaires Matrices particulières 6 avril 2016 7 / 14
x
i“ 1 A
i,i¨
˝b
i´
i´1
ÿ
j“1
A
i,jx
j˛
‚ , @ i P v 1, n w.
Algorithme 2 R0
1: RésoudreAxxx“bbben calculant successivementx1, x2, . . . ,xn.
Algorithme 2 R1 1: PouriÐ1ànfaire
2: xiÐ 1
Ai,i
¨
˝bi´
i´1
ÿ
j“1
Ai,jxj
˛
‚ 3: Fin Pour
x
i“ 1 A
i,i¨
˝ b
i´
i´1
ÿ
j“1
A
i,jx
j˛
‚ , @i P v1, nw.
Algorithme 2 R1
1: PouriÐ1ànfaire
2: xi Ð 1
Ai,i
¨
˝bi´
i´1
ÿ
j“1
Ai,jxj
˛
‚
3: Fin Pour
Algorithme 2 R2
1: PouriÐ1ànfaire
2: SÐ
i´1
ÿ
j“1
Ai,jxj
3: xiÐ pbi´Sq{Ai,i
4: Fin Pour
Résolution de systèmes linéaires Matrices particulières 6 avril 2016 8 / 14
x
i“ 1 A
i,i¨
˝b
i´
i´1
ÿ
j“1
A
i,jx
j˛
‚ , @i P v1, nw.
Algorithme 2 R3
1: PouriÐ1ànfaire
2: SÐ
i´1
ÿ
j“1
Ai,jxj
3: xi Ð pbi´Sq{Ai,i
4: Fin Pour
Algorithme 2 R4
1: PouriÐ1ànfaire
2: SÐ0
3: PourjÐ1ài´1faire
4: SÐS`Api,jq ˚xpjq
5: Fin Pour
6: xiÐ pbi´Sq{Ai,i
7: Fin Pour
x
i“ 1 A
i,i¨
˝ b
i´
i´1
ÿ
j“1
A
i,jx
j˛
‚ , @i P v1, nw.
Algorithme 2FonctionRSLTRIINF permettant de résoudre le système linéaire triangulaire inférieur inversible
Axxx“bbb.
Données : A : matrice triangulaire deMnpKqinférieure inversible.
bbb : vecteur deKn. Résultat : xxx : vecteur deKn.
1: FonctionxxxÐRSLTRIINF(A,bbb)
2: PouriÐ1ànfaire
3: SÐ0
4: PourjÐ1ài´1faire
5: SÐS`Api,jq ˚xpjq
6: Fin Pour
7: xpiq Ð pbpiq ´Sq{Api,iq
8: Fin Pour
9: Fin Fonction
Résolution de systèmes linéaires Matrices particulières 6 avril 2016 8 / 14
Système triangulaire supérieur
Soit
AP
MnpKq triangulaire supérieure inversible (A
i,j“ 0 si i ă j)
Ax
x x “ b b b ðñ
¨
˚
˚
˚
˚
˝
A
1,1. . . . . . A
1,n0 . .. .. .
.. . . .. ... .. .
0 . . . 0 A
n,n˛
‹
‹
‹
‹
‚
¨
˚
˚
˚
˚
˝ x
1.. . .. . x
n˛
‹
‹
‹
‹
‚
“
¨
˚
˚
˚
˚
˝ b
1.. . .. . b
n˛
‹
‹
‹
‹
‚
Exercise 1
Ecrire la fonction
RSLTRISUPpermettant de résoudre le système
triangulaire supérieure
Axx x “ b b b.
Algorithme de Gauss-Jordan
Ax
x x “ b b b ðñ
Uxx x “ fff où
Umatrice triangulaire supérieure.
Opérations élémentaires sur les matrices :
‚ Li
Ø
Ljpermutation lignes i et j
‚ Li
Ð
Li` αL
jcombinaison linéaire
A l’aide d’opérations élémentaires, on va transformer successivement en n ´ 1 étapes le système. A l’étape k , on va s’arranger pour annuler les termes sous-diagonaux de la colonne k de la matrice sans modifier les k ´ 1 premières colonnes.
Résolution de systèmes linéaires Méthode de Gauss-Jordan 6 avril 2016 10 / 14
¨
˚
˚
˚
˚
˚
˚
˚
˚
˚
˚
˚
˚
˝
‚ ‚ ¨ ¨ ¨ ‚ ‚ ¨ ¨ ¨ ‚ 0 . .. . .. ... ... ... ... . .. . .. ‚ ... ...
0 . . . 0 ‚ ‚ ¨ ¨ ¨ ‚
0 ¨ ¨ ¨ ¨ ¨ ¨ 0 ‚ ¨ ¨ ¨ ‚ ... ... ... ...
0 . . . . . . 0 ‚ ¨ ¨ ¨ ‚
˛
‹
‹
‹
‹
‹
‹
‹
‹
‹
‹
‹
‹
‚ x x x=
¨
˚
˚
˚
˚
˚
˚
˚
˚
˝
‚ ...
‚
‚ ...
‚
˛
‹
‹
‹
‹
‹
‹
‹
‹
‚ k´1
Etape k
ðñ
¨
˚
˚
˚
˚
˚
˚
˚
˚
˚
˚
˚
˚
˝
‚ ‚ ¨ ¨ ¨ ‚ ‚ ¨ ¨ ¨ ‚ 0 . .. . .. ... ... ... ... . .. . .. ‚ ... ...
0 . . . 0 ‚ ‚ ¨ ¨ ¨ ‚
0 ¨ ¨ ¨ ¨ ¨ ¨ 0 ‚ ¨ ¨ ¨ ‚ ... ... ... ...
0 . . . . . . 0 ‚ ¨ ¨ ¨ ‚
˛
‹
‹
‹
‹
‹
‹
‹
‹
‹
‹
‹
‹
‚ x xx=
¨
˚
˚
˚
˚
˚
˚
˚
˚
˝
‚ ...
‚
‚ ...
‚
˛
‹
‹
‹
‹
‹
‹
‹
‹
‚ k
Algorithme 3
Algorithme de Gauss-Jordan formel pour la résolution de
Axx x “ b b b
1: Pour
j Ð 1
àn ´ 1
faire2:
Rechercher l’indice k de la ligne du pivot (sur la colonne j, k P vj, nw)
3:
Permuter les lignes j (L
j) et k (L
k) du système si besoin.
4: Pour
i Ð j ` 1
àn
faire5:
Eliminer en effectuant
LiÐ
Li´
AAi,jj,jLj
6: Fin Pour
7: Fin Pour
8:
Résoudre le système triangulaire supérieur par la méthode de la remontée.
Résolution de systèmes linéaires Méthode de Gauss-Jordan 6 avril 2016 12 / 14
Algorithme 4Algorithme de Gauss-Jordan avec fonctions pour la résolution deAxxx“bbb
Données : A : matrice deMnpKqinversible.
bbb : vecteur deKn. Résultat : xxx : vecteur deRn.
1: FonctionxxxÐRSLGAUSS(A,bbb)
2: PourjÐ1àn´1faire
3: kÐ CHERCHEINDPIVOT pA,jq Źà écrire
4: rA,bbbs Ð PERMLIGNESSYS pA,bbb,j,kq Źà écrire
5: PouriÐj`1ànfaire
6: rA,bbbs Ð COMBLIGNESSYS pA,bbb,j,i,´Api,jq{Apj,jqq Źà écrire
7: Fin Pour
8: Fin Pour
9: xxxÐRSLTRISUPpA,bbbq Źdéjà écrite
10: Fin Fonction
Algorithme 5Recherche d’un pivot pour l’algo- rithme de Gauss-Jordan.
Données : A : matrice deMnpKq.
j : entier, 1ďjďn.
Résultat : k : entier, indice ligne pivot
1:FonctionkÐCHERCHEINDPIVOT(A,j) 2: kÐj,pivotÐ |Apj,jq|
3: PouriÐj`1ànfaire 4: Si|Api,jq| ąpivotalors
5: kÐi
6: pivotÐ |Api,jq|
7: Fin Si 8: Fin Pour 9:Fin Fonction
Algorithme 6Permutte deux lignes d’une matrice et d’un vecteur.
Données : A : matrice deMnpKq.
b b
b : vecteur deKn. j,k : entiers, 1ďj,kďn.
Résultat : Aetbbbmodifiés.
1:FonctionrA,bbbs ÐPERMLIGNESSYS(A,bbb,j,k) 2: PourlÐ1ànfaire
3: tÐApj,lq 4: Apj,lq ÐApk,lq 5: Apk,lq Ðt 6: Fin Pour
7: tÐbbbpjq,bbbpjq Ðbbbpkq,bbbpkq Ðt 8:Fin Fonction
Algorithme 7Combinaison linéaireLiÐLi`αLjappli- qué à une matrice et à un vecteur.
Données : A : matrice deMnpKq.
b
bb : vecteur deKn. j,i : entiers, 1ďj,iďn.
alpha : scalaire deK Résultat : Aetbbbmodifiés.
1:FonctionrA,bbbs ÐCOMBLIGNESSYS(A,bbb,j,i, α) 2: PourkÐ1ànfaire
3: Api,kq ÐApi,kq `α˚Apj,kq 4: Fin Pour
5: bbbpiq Ðbbbpiq `αbbbpjq 6:Fin Fonction
Résolution de systèmes linéaires Méthode de Gauss-Jordan 6 avril 2016 14 / 14