You are on page 1of 29

ASI 3

Mthodes numriques
pour lingnieur
Rsolution de systmes linaires
par des mthodes directes :
Gauss, LU,
Ax=b : un cas simple
A est une matrice diagonale
[ ] n i
a
b
x
ii
i
i
, 1 , =

n
i
n
i
nn
ii
b
b
b
x
x
x
a
a
a

1 1 11

0 0 0
0 0
0 0 0 0
0 0
0 0 0
fait

jusqu' 1 pour
ii
i
i
a
b
x
n i

=
Fonction x = diago(A,b)
problme
solution
Algorithme
A est de forme triangulaire

'

=
=

=

1

1
1
1
1
1
i
j
j ij i
ii
i
x a b
a
x
a
b
x

n
i
n
i
nn ni n
ii i
b
b
b
x
x
x
a a a
a a
a

1 1
1
1
11

0
0 0
0
0 0 0
fait
omme

fait
omme omme
1 jusqu' 1 pour
omme
jusqu' 2 pour

11
1
1
ii
i
j ij
i
a
s
x
x a s s
i j
b s
n i
a
b
x

omme s
Fonction x = triang(A,b)
Commentaires sur le programme diago
Complexit ?
Dterminant :
que se passe til si A est triangulaire suprieure ?
Exercice :

=
=
n
i
ii
a A
1
) det(
Quels sont les ges dAlice, de Louis, Sacha et Gaspar ?
Sachant que trois fois la somme des ges des garons est
gale la somme des ges des filles, que lge dAlice
moins trois fois la somme des ges de Louis et de Sacha
est gal moins neuf, que trois fois lge de Louis est gal
vingt sept, et que lge de Louis moins deux fois lge
de Sacha est gal 3.
Pivot de Gauss
4 principes fondamentaux
On ne change pas la solution lorsque lon :
1. permute 2 lignes
2. permute 2 colonnes
3. divise par un mme terme non nul les lments dune ligne
4. ajoute ou retranche une ligne un certain nombre
de fois une autre ligne
Stratgie: Transformer le systme linaire
en un systme quivalent facile rsoudre
Triangulaire !
Pivot de Gauss : un exemple

= + +
= + +
= + +
= +
6 2
8 2 3
0 3
6 2 4 2
4 3 2
4 3 2 1
4 2 1
3 2 1
x x x
x x x x
x x x
x x x
pivot (1)
Pivot de Gauss : un exemple

= + +
= + +
= + +
= +
6 2
8 2 3
0 3
6 2 4 2
4 3 2
4 3 2 1
4 2 1
3 2 1
x x x
x x x x
x x x
x x x
(2) = (2)-a
21
/pivot (1)
Pivot de Gauss : un exemple

= + +
= + +
= + +
= +
6 2
8 2 3
0 3
6 2 4 2
4 3 2
4 3 2 1
4 2 1
3 2 1
x x x
x x x x
x x x
x x x

= + +
= + +
= + + +
= +
6 2
8 2 3
3 0
6 2 4 2
4 3 2
4 3 2 1
4 3 2
3 2 1
x x x
x x x x
x x x
x x x
(2) = (2)-a
21
/pivot (1)
Pivot de Gauss : un exemple

= + +
= + +
= + +
= +
6 2
8 2 3
0 3
6 2 4 2
4 3 2
4 3 2 1
4 2 1
3 2 1
x x x
x x x x
x x x
x x x

= + +
= + +
= + + +
= +
6 2
7 1 2 4 7 0
3 0
6 2 4 2
4 3 2
4 3 2
4 3 2
3 2 1
x x x
x x x
x x x
x x x
(3) = (3)-a
31
/pivot (1)
Le premire variable t limine de toutes les quations sauf une
1. Triangularisation
2. Rsolution du systme triangulaire
Lalgorithme du pivot de Gauss
A x = b
fait
problme" " sinon
fait
fait

jusqu' 1 pour

jusqu' 1 pour
alors 0 si
*) pivot de stratgie (*
1 jusqu' 1 pour
kj
ik
ij ij
k
ik
i i
kk
a
pivot
a
a a
n k j
b
pivot
a
b b
n k i
pivot
a pivot
n k

+ =

+ =

=
Fonction A,b =descent(A,b)
Gauss : rsolution dun systme triangulaire

'

=
=

+ =

1

1
n
i j
j ij i
ii
i
n
n
n
x a b
a
x
a
b
x

n
i
n
i
nn
in ii
n i
b
b
b
x
x
x
a
a a
a a a



1 1 1 1 11

0 0 0
0
0 0
0
fait
omme

fait
omme omme
jusqu' 1 pour
omme
1 jusqu' 1 pour

ii
i
j ij
i
nn
n
n
a
s
x
x a s s
n i j
b s
n i
a
b
x


+ =

omme s
Fonction x = triang(A,b)
Gauss
U,c = descent(A,b)
x = triang(U,c)
Fonction x = Gauss(A,b)
Remarques
Choix du pivot : minimiser les erreurs darrondis
si un pivot est nul, on permute deux lignes
si tous les pivots restant sont nuls la matrice est singulire
(i.e. le systme dquations nadmet pas de solution unique)
pour minimiser les erreurs darrondis :
on choisi le plus grand pivot possible (en valeur absolue)
et donc on permute les lignes (voir les colonnes associes)
cest la stratgie du pivot maximal (partiel (lignes) ou total)
Comment inverser une matrice ?
Avec lalgorithme de gauss on peu rsoudre directement
dterminant dune matrice = produit des pivots
[ ] I AA c b Az
c Ay b Ax
= =
= =
1
: donc et ;
et
Exemple


2
1
1 1
1 10
4
x
Trouver x en ne gardant que 4 chiffres significatifs aprs la virgule

4
4
4
4
10 2
1
10 1 0
1 10
, 10 : x pivot
e
dddd 10 . 0 : tion reprsenta

1
0
10
1
10 0
1 10
4
4
4
x x
Que se passe til si on prend le systme lenvers...
Exemple


2
1
1 1
1 10
4
x
Trouver x en ne gardant que 4 chiffres significatifs aprs la virgule

4
4
4
4
10 2
1
10 1 0
1 10
, 10 : x pivot
e
dddd 10 . 0 : tion reprsenta

1
0
10
1
10 0
1 10
4
4
4
x x
Que se passe til si on prend le systme lenvers...
; ; : ement matriciell

,..., 1 pour
,..., 1 pour
) ( ) ( ) 1 ( ) ( ) ( ) 1 (
) (
) (
) (
) ( ) 1 (
) (
) (
) (
) ( ) 1 (
k k k k k k
k
k
k
kk
k
ik
k
i
k
i
k
kj
k
kk
k
ik
k
ij
k
ij
b M b A M A
b
a
a
b b
n k j a
a
a
a a
n k i
= =


+ =
+ =
+ +
+
+
Reprsentation matricielle de
llimination de Gauss
Lc b LU A
L
c Ux b Ax
= =
= =
et
: que telle matrice la recherche on

A chaque tape de lalgorithme...
Les cas du second membre b
; : ement matriciell
) ( ) ( ) 1 (
) (
) (
) (
) ( ) 1 (
) (
) (
) (
) ( ) 1 (
) (
) (
) (
, 1 ) (
1
) 1 (
1
) ( ) 1 (
) (
1
) 1 (
1
k k k
k
k
k
kk
k
nk
k
n
k
n
k
k
k
kk
k
ik
k
i
k
i
k
k
k
kk
k
k k k
k
k
k
k
k
k
k
k k
b M b
b
a
a
b b
b
a
a
b b
b
a
a
b b
b b
b b
=


+
+
+
+
+
+
+
+
+

=
=
+
1 0 0 0
0
1 0 0
0 0 1 0
0 0 0 1
;
,
, 1
) (
k n
k k
k
kk
ik
ik
m
m
M
a
a
m

M(k) ?
Les cas du second membre b
; : ement matriciell
) ( ) ( ) 1 (
) (
) (
) (
) ( ) 1 (
) (
) (
) (
) ( ) 1 (
) (
) (
) (
, 1 ) (
1
) 1 (
1
) ( ) 1 (
) (
1
) 1 (
1
k k k
k
k
k
kk
k
nk
k
n
k
n
k
k
k
kk
k
ik
k
i
k
i
k
k
k
kk
k
k k k
k
k
k
k
k
k
k
k k
b M b
b
a
a
b b
b
a
a
b b
b
a
a
b b
b b
b b
=


+
+
+
+
+
+
+
+
+

=
=
+
1 0 0 0
0
1 0 0
0 0 1 0
0 0 0 1
;
,
, 1
) (
k n
k k
k
kk
ik
ik
m
m
M
a
a
m

Factorisation

= =
= =
+
+ +
1 0 0 0
0
1 0 0
0 0 1 0
0 0 0 1
;
; ; : ement matriciell
,
, 1
) (
) ( ) ( ) 1 ( ) ( ) ( ) 1 (
k n
k k
k
kk
ik
ik
k k k k k k
m
m
M
a
a
m
b M b A M A

LU A M L
U M A A M
A M M M M
A M M
A M A U
M
n n
n n n
n n n
= =
= =
=
=
= =




a on posant en

...

1
1
) 1 ( ) 2 ( ) 2 ( ) 1 (
) 2 ( ) 2 ( ) 1 (
) 1 ( ) 1 ( ) (

LU : motivation
On connat la matrice A
on ne connat pas encore b
comment prparer A ?
LU : principe
Il est si facile le rsoudre un systme triangulaire !
) 2 (
) 1 (

=
=
=
=
y Ux
b Ly
b Ax
LU A
L
U
A
0
0
Comment construire Let U ?
ide :
reprendre ltape de triangularisation
de la mthode de Gauss
De Gauss LU
U A A A A M A
n k k k
= = =
+ ) ( ) 1 ( ) ( ) ( ) 1 (
et
Reprsentons une tape de la triangularisation
par la multiplication de A par une matrice M
(k)



kj
kk
ik
ij ij
k
kk
ik
i i
a
a
a
a a
b
a
a
b b

1 0 0
0 1 0 0
0
0 0 1
,
, 1
) (
, ,

=
= =
+
k n
k k
k
k i
kk
ik
k i
M
m
a
a

1
1
) 1 ( ) ( ) 1 (
donc

... ...

=
= =
= =
M L
LU U M A
MA A M M M U
k n
gauss
LU : la dcomposition
Les matrices lmentaires M
(k)
sont inversibles
et leurs inverses sont les matrices L
(k)
triangulaires infrieures
telles que :

+ = =
= =
=
=
,n k i l
n i l
l
L
ik ik
ii
ij
k
1 sauf
, 1 1 sauf
0
) (

( ) I M I L
k k
=
) ( ) (

1 0 0
0 1 0 0
0
0 0 1
,
, 1
) (

=
+
k n
k k
k
M




1 0 0
0 1 0 0
0
0 0 1
,
, 1
) (

=
+
k n
k k
k
L



) 1 ( ) ( ) 1 (
... ... L L L L
k n
= Cest la matrice l
ik
Lalgorithme de dcomposition
fait
problme" " sinon
fait
fait

jusqu' 1 pour

jusqu' 1 pour
1
alors 0 si
*) pivot de stratgie (*
1 jusqu' 1 pour
kj ik ij ij
ik
ik
kk
kk
a a a
n k j
pivot
a
n k i
pivot
a pivot
n k


+ =

+ =

=
Fonction L,U = dcompose(A)
Exemple

2
1
2
1
1 2
1 2 1
1 1
1 2
1
1 1 1
1 2 2
1 2 1
Montrez que :
LU : lalgorithme
L,U = decompose(A)
y =triang(L,b)
x =triang(U,y)
Fonction x = LU(A,b)
A=LU

= =
= = = = =
n
i
i
n
i
ii
u U U L LU A
1 1
pivot ) det( ) det( ) det( ) det( ) det(
Thorme : Si au cours de llimination de Gauss sur la matrice A,
les pivots sont non nuls,
alors il existe une matrice triangulaire infrieure L
et une matrice triangulaire suprieure U, telle que :
A = LU
si de plus on impose L davoir les lments diagonaux
gaux un
alors la factorisation est unique
LU U M A
MA A M M M U
k n
= =
= =

1
) 1 ( ) ( ) 1 (

... ...
Dmonstration : (lments)
unicit : par labsurde
Remarque : (dterminent)
A=LU
Thorme : Si au cours de llimination de Gauss sur la matrice A,
les pivots sont non nuls,
alors il existe une matrice triangulaire infrieure L
et une matrice triangulaire suprieure U, telle que :
A = LU
si de plus on impose L davoir les lments diagonaux
gaux un
alors la factorisation est unique

=
1 1
2 0
A
Contre exemple trivial :
Rorganisation du systme linaire :
permutation des lignes et des colonnes
RECHERCHE DU MEILLEUR PIVOT
La factorisation
PA=LU
Dfinition : Si la matrice A, est non singulire
alors il existe une matrice de permutation P
telle que les pivots de PA sont non nuls. (TL chapitre 4)

) 2 (
) 1 (

=
=
=
=
y Ux
Pb Ly
b Ax
LU PA
L,U,P = decompose(A)
y =triang(L,P*b)
x =triang(U,y)
Fonction x = LU(A,b)
Si est gal zro,
on change (permute) deux lignes
kk
a
Matlab !

You might also like