Aller au contenu

08 · Inversion de matrice

Intuition

Inverser une matrice, c'est défaire la transformation qu'elle représente. Si \(\mathbf{A}\) envoie \(\mathbf{x}\) sur \(\mathbf{b}\), alors \(\mathbf{A}^{-1}\) ramène \(\mathbf{b}\) sur \(\mathbf{x}\).

Cela n'est possible que si rien n'a été perdu en chemin — d'où la condition \(\det\mathbf{A}\neq0\) établie au chapitre précédent.

Le programme demande explicitement deux méthodes : le pivot de Gauss et la comatrice. Elles ne servent pas aux mêmes situations, et ce chapitre dit précisément laquelle utiliser quand.

1. Définition

Définition

Une matrice carrée \(\mathbf{A}\) d'ordre \(n\) est inversible s'il existe \(\mathbf{B}\) telle que

\[ \mathbf{AB} = \mathbf{BA} = \mathbf{I}_n \]

\(\mathbf{B}\) est alors unique, notée \(\mathbf{A}^{-1}\).

Démonstration de l'unicité

Supposons \(\mathbf{B}\) et \(\mathbf{C}\) deux inverses. Alors

\[ \mathbf{B} = \mathbf{B}\mathbf{I} = \mathbf{B}(\mathbf{AC}) = (\mathbf{BA})\mathbf{C} = \mathbf{I}\mathbf{C} = \mathbf{C} \]

On a utilisé l'associativité, et rien d'autre. \(\blacksquare\)

Une seule des deux égalités suffit

Pour des matrices carrées de même taille, \(\mathbf{AB} = \mathbf{I}\) entraîne automatiquement \(\mathbf{BA} = \mathbf{I}\). C'est le pendant matriciel du théorème « injective ⟺ surjective en dimension finie égale » du chapitre 03.

En pratique, on vérifie donc un seul produit.

1.1 Propriétés

\[ (\mathbf{A}^{-1})^{-1} = \mathbf{A} \qquad \boxed{(\mathbf{AB})^{-1} = \mathbf{B}^{-1}\mathbf{A}^{-1}} \qquad (\mathbf{A}^\top)^{-1} = (\mathbf{A}^{-1})^\top \]
\[ (\lambda\mathbf{A})^{-1} = \frac{1}{\lambda}\mathbf{A}^{-1} \quad (\lambda\neq0) \qquad \det(\mathbf{A}^{-1}) = \frac{1}{\det\mathbf{A}} \]

L'ordre s'inverse — troisième occurrence

\((\mathbf{AB})^{-1} = \mathbf{B}^{-1}\mathbf{A}^{-1}\). C'est la même règle que pour \((g\circ f)^{-1} = f^{-1}\circ g^{-1}\) (chapitre 03) et \((\mathbf{AB})^\top = \mathbf{B}^\top\mathbf{A}^\top\) (chapitre 05).

Vérification en une ligne : \((\mathbf{AB})(\mathbf{B}^{-1}\mathbf{A}^{-1}) = \mathbf{A}(\mathbf{BB}^{-1})\mathbf{A}^{-1} = \mathbf{AA}^{-1} = \mathbf{I}\) ✓

Il n'y a pas de division matricielle

L'écriture \(\frac{\mathbf{B}}{\mathbf{A}}\) est ambiguë et proscrite : \(\mathbf{A}^{-1}\mathbf{B}\) et \(\mathbf{B}\mathbf{A}^{-1}\) ne sont pas égaux en général. Écrivez toujours le produit dans l'ordre voulu.

2. Le cas \(2\times2\) — à connaître par cœur

\[ \mathbf{A}=\begin{pmatrix}a&b\\c&d\end{pmatrix} \implies \mathbf{A}^{-1} = \frac{1}{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix} \]

Recette : on échange \(a\) et \(d\), on change le signe de \(b\) et \(c\), on divise par le déterminant.

Exemple. \(\mathbf{A}=\begin{pmatrix}3&5\\1&2\end{pmatrix}\), \(\det = 6-5 = 1\).

\[ \mathbf{A}^{-1} = \begin{pmatrix}2&-5\\-1&3\end{pmatrix} \]

Vérification : \(\begin{pmatrix}3&5\\1&2\end{pmatrix}\begin{pmatrix}2&-5\\-1&3\end{pmatrix} = \begin{pmatrix}6-5&-15+15\\2-2&-5+6\end{pmatrix} = \mathbf{I}_2\) ✓

3. Méthode 1 — le pivot de Gauss-Jordan

C'est la méthode à utiliser dès l'ordre 3.

Principe

On accole \(\mathbf{I}_n\) à droite de \(\mathbf{A}\) et on applique des opérations élémentaires sur les lignes jusqu'à transformer la partie gauche en \(\mathbf{I}_n\). La partie droite est alors \(\mathbf{A}^{-1}\).

\[ \big(\ \mathbf{A}\ \big|\ \mathbf{I}\ \big) \xrightarrow{\ \text{opérations}\ } \big(\ \mathbf{I}\ \big|\ \mathbf{A}^{-1}\ \big) \]

Pourquoi ça marche. Chaque opération élémentaire revient à multiplier à gauche par une matrice inversible \(\mathbf{E}_k\). Si le produit \(\mathbf{E}_p\cdots\mathbf{E}_1\) transforme \(\mathbf{A}\) en \(\mathbf{I}\), c'est que \(\mathbf{E}_p\cdots\mathbf{E}_1 = \mathbf{A}^{-1}\) — et ce même produit appliqué à \(\mathbf{I}\) donne exactement \(\mathbf{A}^{-1}\).

Différence avec le pivot de Gauss simple : on ne s'arrête pas à la forme échelonnée. On remonte ensuite pour annuler aussi les coefficients au-dessus des pivots, et on normalise chaque pivot à 1. C'est la variante Gauss-Jordan.

3.1 Exemple complet

\[ \mathbf{A} = \begin{pmatrix}1&2&3\\0&1&4\\5&6&0\end{pmatrix} \]
\[ \left(\begin{array}{ccc|ccc} 1&2&3&1&0&0\\ 0&1&4&0&1&0\\ 5&6&0&0&0&1 \end{array}\right) \]

Descente. \(L_3\leftarrow L_3-5L_1\) :

\[ \left(\begin{array}{ccc|ccc} 1&2&3&1&0&0\\ 0&1&4&0&1&0\\ 0&-4&-15&-5&0&1 \end{array}\right) \]

\(L_3\leftarrow L_3+4L_2\) :

\[ \left(\begin{array}{ccc|ccc} 1&2&3&1&0&0\\ 0&1&4&0&1&0\\ 0&0&1&-5&4&1 \end{array}\right) \]

Remontée. \(L_2\leftarrow L_2-4L_3\) :

\[ \left(\begin{array}{ccc|ccc} 1&2&3&1&0&0\\ 0&1&0&20&-15&-4\\ 0&0&1&-5&4&1 \end{array}\right) \]

\(L_1\leftarrow L_1-3L_3\) :

\[ \left(\begin{array}{ccc|ccc} 1&2&0&16&-12&-3\\ 0&1&0&20&-15&-4\\ 0&0&1&-5&4&1 \end{array}\right) \]

\(L_1\leftarrow L_1-2L_2\) :

\[ \left(\begin{array}{ccc|ccc} 1&0&0&-24&18&5\\ 0&1&0&20&-15&-4\\ 0&0&1&-5&4&1 \end{array}\right) \]
\[ \mathbf{A}^{-1} = \begin{pmatrix}-24&18&5\\20&-15&-4\\-5&4&1\end{pmatrix} \]

Vérification — première ligne de \(\mathbf{A}\) fois première colonne de \(\mathbf{A}^{-1}\) : \(1(-24)+2(20)+3(-5) = -24+40-15 = 1\) ✓ Première ligne fois deuxième colonne : \(1(18)+2(-15)+3(4) = 18-30+12 = 0\) ✓

Vérifiez toujours au moins deux coefficients

Un coefficient diagonal (doit valoir 1) et un hors-diagonale (doit valoir 0). C'est trente secondes et cela attrape l'immense majorité des erreurs.

Si la partie gauche ne peut pas devenir \(\mathbf{I}\)

Si au cours du pivot une ligne entière de la partie gauche devient nulle, c'est que \(\det\mathbf{A}=0\) : la matrice n'est pas inversible, et il faut s'arrêter là. Ce n'est pas une erreur de calcul, c'est le résultat.

4. Méthode 2 — la comatrice

\[ \mathbf{A}^{-1} = \frac{1}{\det\mathbf{A}}\big(\operatorname{com}\mathbf{A}\big)^\top \]

où \(\operatorname{com}(\mathbf{A})_{ij} = (-1)^{i+j}M_{ij}\), avec \(M_{ij}\) le mineur obtenu en supprimant la ligne \(i\) et la colonne \(j\).

La transposée de la comatrice s'appelle la matrice adjointe ou complémentaire.

4.1 Exemple d'ordre 3

\[ \mathbf{A} = \begin{pmatrix}1&2&0\\0&1&3\\2&0&1\end{pmatrix} \]

Déterminant (développement selon la première colonne) :

\[ \det\mathbf{A} = 1\begin{vmatrix}1&3\\0&1\end{vmatrix} - 0 + 2\begin{vmatrix}2&0\\1&3\end{vmatrix} = 1(1) + 2(6) = 13 \]

Les neuf cofacteurs :

\[ C_{11} = +\begin{vmatrix}1&3\\0&1\end{vmatrix} = 1 \qquad C_{12} = -\begin{vmatrix}0&3\\2&1\end{vmatrix} = 6 \qquad C_{13} = +\begin{vmatrix}0&1\\2&0\end{vmatrix} = -2 \]
\[ C_{21} = -\begin{vmatrix}2&0\\0&1\end{vmatrix} = -2 \qquad C_{22} = +\begin{vmatrix}1&0\\2&1\end{vmatrix} = 1 \qquad C_{23} = -\begin{vmatrix}1&2\\2&0\end{vmatrix} = 4 \]
\[ C_{31} = +\begin{vmatrix}2&0\\1&3\end{vmatrix} = 6 \qquad C_{32} = -\begin{vmatrix}1&0\\0&3\end{vmatrix} = -3 \qquad C_{33} = +\begin{vmatrix}1&2\\0&1\end{vmatrix} = 1 \]
\[ \operatorname{com}\mathbf{A} = \begin{pmatrix}1&6&-2\\-2&1&4\\6&-3&1\end{pmatrix} \implies \mathbf{A}^{-1} = \frac{1}{13}\begin{pmatrix}1&-2&6\\6&1&-3\\-2&4&1\end{pmatrix} \]

Ne pas oublier la transposition

C'est l'erreur numéro un de la méthode. On calcule la comatrice puis on la transpose. Sans la transposition, le résultat est faux — sauf si \(\mathbf{A}\) est symétrique, auquel cas l'erreur passe inaperçue et s'installe.

Vérification : \(1\times\frac{1}{13}(1) + 2\times\frac{1}{13}(6) + 0 = \frac{1+12}{13} = 1\) ✓

4.2 Quelle méthode choisir

Pivot de Gauss-Jordan Comatrice
Coût \(O(n^3)\) \(O(n^2)\) déterminants d'ordre \(n-1\)
Ordre 2 Inutilement long ✅ Formule directe
Ordre 3 ✅ Recommandé Acceptable
Ordre ≥ 4 ✅ Seule méthode raisonnable ❌ Explosion combinatoire
Matrice littérale Difficile (divisions par des expressions) ✅ Souvent plus lisible
En machine ✅ ❌ Jamais

En pratique

Ordre 2 : la formule par cœur. Ordre 3 : Gauss-Jordan, sauf si les coefficients sont des lettres. Ordre ≥ 4 : Gauss-Jordan, sans hésiter.

5. Applications

5.1 Résolution de système

Si \(\mathbf{A}\) est inversible, \(\mathbf{Ax}=\mathbf{b}\) a pour unique solution

\[ \mathbf{x} = \mathbf{A}^{-1}\mathbf{b} \]

À ne pas faire en pratique

Calculer \(\mathbf{A}^{-1}\) puis multiplier coûte environ trois fois plus cher que résoudre directement par pivot, et amplifie les erreurs d'arrondi.

L'inverse est utile quand on doit résoudre le système pour beaucoup de seconds membres différents, ou pour des raisons théoriques. Sinon, on factorise une fois (décomposition LU) et on réutilise.

5.2 Équations matricielles

L'inverse sert surtout à isoler une matrice inconnue.

\[ \mathbf{AX} = \mathbf{B} \implies \mathbf{X} = \mathbf{A}^{-1}\mathbf{B} \]
\[ \mathbf{XA} = \mathbf{B} \implies \mathbf{X} = \mathbf{B}\mathbf{A}^{-1} \]

Le côté compte

Ces deux solutions sont différentes. Il faut multiplier du même côté que celui où se trouve \(\mathbf{A}\).

5.3 Inversion par polynôme annulateur

Si l'on connaît une relation \(\mathbf{A}^2 = a\mathbf{A}+b\mathbf{I}\) avec \(b \neq 0\), alors

\[ \mathbf{A}^2 - a\mathbf{A} = b\mathbf{I} \implies \mathbf{A}\left(\frac{\mathbf{A}-a\mathbf{I}}{b}\right) = \mathbf{I} \implies \mathbf{A}^{-1} = \frac{\mathbf{A}-a\mathbf{I}}{b} \]

C'est de loin la méthode la plus rapide quand une telle relation est fournie ou facile à trouver.

Erreurs fréquentes

Erreur Correction
\((\mathbf{AB})^{-1} = \mathbf A^{-1}\mathbf B^{-1}\) L'ordre s'inverse
Oublier de transposer la comatrice \(\mathbf A^{-1} = \frac{1}{\det}(\operatorname{com}\mathbf A)^\top\)
Écrire \(\frac{\mathbf B}{\mathbf A}\) Ambigu, interdit
Multiplier du mauvais côté \(\mathbf{AX}=\mathbf B\) donne \(\mathbf X = \mathbf A^{-1}\mathbf B\)
Inverser sans vérifier \(\det\neq0\) Peut ne pas exister
\(\det\mathbf A^{-1} = -\det\mathbf A\) C'est \(\frac{1}{\det\mathbf A}\)

Exercices

★ Exercice 1. Inverser, ou justifier que ce n'est pas possible.

a) \(\begin{pmatrix}4&7\\1&2\end{pmatrix}\) b) \(\begin{pmatrix}2&6\\1&3\end{pmatrix}\) c) \(\begin{pmatrix}0&1\\-1&0\end{pmatrix}\)

★★ Exercice 2. Inverser par Gauss-Jordan.

\[ \mathbf{A}=\begin{pmatrix}1&0&2\\2&-1&3\\4&1&8\end{pmatrix} \]

★★ Exercice 3. Inverser par la comatrice.

\[ \mathbf{B}=\begin{pmatrix}2&1&0\\1&1&1\\0&1&2\end{pmatrix} \]

★★ Exercice 4. Soit \(\mathbf{A}=\begin{pmatrix}3&-1\\2&0\end{pmatrix}\).

a) Vérifier que \(\mathbf{A}^2 = 3\mathbf{A}-2\mathbf{I}\). b) En déduire \(\mathbf{A}^{-1}\) sans calcul d'inverse. c) En déduire \(\mathbf{A}^{-2}\).

★★★ Exercice 5. Résoudre l'équation matricielle \(\mathbf{AX}+\mathbf{B} = \mathbf{X}\), avec

\[ \mathbf{A}=\begin{pmatrix}2&1\\1&2\end{pmatrix},\qquad \mathbf{B}=\begin{pmatrix}1&0\\0&1\end{pmatrix} \]

★★★ Exercice 6. Soit \(\mathbf{N}\) nilpotente d'ordre \(k\) (\(\mathbf{N}^k=\mathbf{0}\)).

a) Montrer que \(\mathbf{I}-\mathbf{N}\) est inversible, d'inverse \(\mathbf{I}+\mathbf{N}+\mathbf{N}^2+\dots+\mathbf{N}^{k-1}\). b) Appliquer à \(\mathbf{N}=\begin{pmatrix}0&1&2\\0&0&3\\0&0&0\end{pmatrix}\). c) Faire le lien avec la somme d'une série géométrique.

★★★ Exercice 7. Soit \(\mathbf{A}\) inversible d'ordre \(n\).

a) Montrer que \(\det(\operatorname{com}\mathbf{A}) = (\det\mathbf{A})^{n-1}\). b) Vérifier sur une matrice \(2\times2\) et une matrice \(3\times3\) de votre choix.

★★★★ Exercice 8. Soient \(\mathbf{A}\) et \(\mathbf{B}\) inversibles telles que \(\mathbf{A}+\mathbf{B}\) soit aussi inversible.

Montrer que \(\mathbf{A}^{-1}+\mathbf{B}^{-1}\) est inversible et que

\[ (\mathbf{A}^{-1}+\mathbf{B}^{-1})^{-1} = \mathbf{A}(\mathbf{A}+\mathbf{B})^{-1}\mathbf{B} \]

★★★★ Exercice 9. Une matrice \(\mathbf{A}\) d'ordre \(n\) est dite stochastique si tous ses coefficients sont positifs et si la somme de chaque ligne vaut 1.

a) Montrer que \(\mathbf{A}\mathbf{u} = \mathbf{u}\) où \(\mathbf{u}=(1,1,\dots,1)^\top\). b) En déduire que \(\mathbf{A}-\mathbf{I}\) n'est jamais inversible. c) Quel est le lien avec les chaînes de Markov ?

★★★★ Exercice 10 — lien informatique. On veut résoudre \(\mathbf{Ax}=\mathbf{b}_i\) pour \(m\) seconds membres différents, \(\mathbf{A}\) étant d'ordre \(n\) fixe.

a) Coût si l'on refait un pivot de Gauss complet pour chaque \(\mathbf{b}_i\) ? b) Coût si l'on calcule \(\mathbf{A}^{-1}\) une fois puis \(m\) produits matrice-vecteur ? c) La décomposition LU factorise \(\mathbf{A} = \mathbf{LU}\) en \(\frac{2n^3}{3}\) opérations, après quoi chaque résolution coûte \(2n^2\). Comparer les trois stratégies pour \(n = 1000\) et \(m = 50\). d) Pourquoi LU est-elle préférée à l'inverse explicite, alors que les coûts asymptotiques sont comparables ?


Corrigés

Corrigé — Exercice 1

a) \(\det = 8-7 = 1\).

\[ \mathbf{A}^{-1} = \begin{pmatrix}2&-7\\-1&4\end{pmatrix} \]

Vérification : \(\begin{pmatrix}4&7\\1&2\end{pmatrix}\begin{pmatrix}2&-7\\-1&4\end{pmatrix} = \begin{pmatrix}8-7&-28+28\\2-2&-7+8\end{pmatrix} = \mathbf I\) ✓

b) \(\det = 6-6 = 0\). Non inversible : la seconde ligne est la moitié de la première.

c) \(\det = 0-(-1) = 1\).

\[ \mathbf{A}^{-1} = \begin{pmatrix}0&-1\\1&0\end{pmatrix} \]

C'est la rotation de \(-\frac\pi2\), inverse de la rotation de \(+\frac\pi2\) — cohérent géométriquement.

Corrigé — Exercice 2
\[ \left(\begin{array}{ccc|ccc} 1&0&2&1&0&0\\2&-1&3&0&1&0\\4&1&8&0&0&1 \end{array}\right) \]

\(L_2\leftarrow L_2-2L_1\), \(L_3\leftarrow L_3-4L_1\) :

\[ \left(\begin{array}{ccc|ccc} 1&0&2&1&0&0\\0&-1&-1&-2&1&0\\0&1&0&-4&0&1 \end{array}\right) \]

\(L_2\leftarrow -L_2\) :

\[ \left(\begin{array}{ccc|ccc} 1&0&2&1&0&0\\0&1&1&2&-1&0\\0&1&0&-4&0&1 \end{array}\right) \]

\(L_3\leftarrow L_3-L_2\) :

\[ \left(\begin{array}{ccc|ccc} 1&0&2&1&0&0\\0&1&1&2&-1&0\\0&0&-1&-6&1&1 \end{array}\right) \]

\(L_3\leftarrow -L_3\) :

\[ \left(\begin{array}{ccc|ccc} 1&0&2&1&0&0\\0&1&1&2&-1&0\\0&0&1&6&-1&-1 \end{array}\right) \]

Remontée. \(L_2\leftarrow L_2-L_3\), \(L_1\leftarrow L_1-2L_3\) :

\[ \left(\begin{array}{ccc|ccc} 1&0&0&-11&2&2\\0&1&0&-4&0&1\\0&0&1&6&-1&-1 \end{array}\right) \]
\[ \mathbf{A}^{-1} = \begin{pmatrix}-11&2&2\\-4&0&1\\6&-1&-1\end{pmatrix} \]

Vérification ligne 1 × colonne 1 : \(1(-11)+0(-4)+2(6) = 1\) ✓ ligne 1 × colonne 2 : \(1(2)+0+2(-1) = 0\) ✓ ligne 3 × colonne 3 : \(4(2)+1(1)+8(-1) = 8+1-8 = 1\) ✓

Corrigé — Exercice 3

Déterminant (Sarrus) :

\[ 2(1)(2)+1(1)(0)+0(1)(1) - 0(1)(0) - 2(1)(1) - 1(1)(2) = 4+0+0-0-2-2 = 0 \]

\(\det\mathbf B = 0\) : la matrice n'est PAS inversible.

Cohérence : on vérifie que \(L_1 - 2L_2 + L_3 = (2-2+0,\ 1-2+1,\ 0-2+2) = (0,0,0)\). Les lignes sont liées.

Le réflexe

Calculer le déterminant avant de se lancer dans les neuf cofacteurs. Ici, le calcul du déterminant prend dix secondes et évite dix minutes de travail inutile.

Corrigé — Exercice 4

a) \(\mathbf{A}^2 = \begin{pmatrix}3&-1\\2&0\end{pmatrix}^2 = \begin{pmatrix}9-2&-3\\6&-2\end{pmatrix} = \begin{pmatrix}7&-3\\6&-2\end{pmatrix}\).

\(3\mathbf{A}-2\mathbf{I} = \begin{pmatrix}9&-3\\6&0\end{pmatrix} - \begin{pmatrix}2&0\\0&2\end{pmatrix} = \begin{pmatrix}7&-3\\6&-2\end{pmatrix}\) ✓

b) De \(\mathbf{A}^2-3\mathbf{A} = -2\mathbf{I}\), on tire

\[ \mathbf{A}(\mathbf{A}-3\mathbf{I}) = -2\mathbf{I} \implies \mathbf{A}\cdot\frac{3\mathbf{I}-\mathbf{A}}{2} = \mathbf{I} \]
\[ \mathbf{A}^{-1} = \frac{3\mathbf{I}-\mathbf{A}}{2} = \frac12\begin{pmatrix}0&1\\-2&3\end{pmatrix} = \begin{pmatrix}0&\tfrac12\\-1&\tfrac32\end{pmatrix} \]

Vérification par la formule \(2\times2\) : \(\det\mathbf A = 0+2 = 2\), donc \(\mathbf A^{-1} = \frac12\begin{pmatrix}0&1\\-2&3\end{pmatrix}\) ✓

c) \(\mathbf{A}^{-2} = (\mathbf{A}^{-1})^2 = \frac14(3\mathbf I-\mathbf A)^2 = \frac14(9\mathbf I - 6\mathbf A+\mathbf A^2)\).

En remplaçant \(\mathbf A^2 = 3\mathbf A-2\mathbf I\) :

\[ = \frac14(9\mathbf I - 6\mathbf A + 3\mathbf A - 2\mathbf I) = \frac{7\mathbf I - 3\mathbf A}{4} = \frac14\begin{pmatrix}7-9&3\\-6&7\end{pmatrix} = \frac14\begin{pmatrix}-2&3\\-6&7\end{pmatrix} \]
Corrigé — Exercice 5
\[ \mathbf{AX}+\mathbf{B}=\mathbf{X} \iff \mathbf{AX}-\mathbf{X} = -\mathbf{B} \iff (\mathbf{A}-\mathbf{I})\mathbf{X} = -\mathbf{B} \]

Ne pas écrire \(\mathbf{X}(\mathbf{A}-\mathbf{I})\)

\(\mathbf{X}\) est à droite de \(\mathbf{A}\) dans \(\mathbf{AX}\). La factorisation doit respecter le côté : \(\mathbf{AX}-\mathbf{IX} = (\mathbf A-\mathbf I)\mathbf X\).

\[ \mathbf{A}-\mathbf{I} = \begin{pmatrix}1&1\\1&1\end{pmatrix} \]

Son déterminant vaut \(1-1 = 0\) : elle n'est pas inversible.

L'équation \((\mathbf A-\mathbf I)\mathbf X = -\mathbf I\) est donc à discuter directement. Posons \(\mathbf X = \begin{pmatrix}a&b\\c&d\end{pmatrix}\) :

\[ \begin{pmatrix}1&1\\1&1\end{pmatrix}\begin{pmatrix}a&b\\c&d\end{pmatrix} = \begin{pmatrix}a+c&b+d\\a+c&b+d\end{pmatrix} \]

Il faudrait que ce soit \(\begin{pmatrix}-1&0\\0&-1\end{pmatrix}\), ce qui exige \(a+c = -1\) et \(a+c = 0\) simultanément. Impossible.

\[ \mathcal{S} = \varnothing \]

La leçon

Une équation matricielle peut n'avoir aucune solution, même quand \(\mathbf A\) et \(\mathbf B\) sont inversibles. Toujours vérifier l'inversibilité de la matrice qui apparaît après factorisation, pas celle des données.

Corrigé — Exercice 6

a) Calculons le produit :

\[ (\mathbf I-\mathbf N)\big(\mathbf I+\mathbf N+\dots+\mathbf N^{k-1}\big) \]
\[ = (\mathbf I+\mathbf N+\dots+\mathbf N^{k-1}) - (\mathbf N+\mathbf N^2+\dots+\mathbf N^{k}) \]

Tous les termes intermédiaires se télescopent :

\[ = \mathbf I - \mathbf N^k = \mathbf I - \mathbf 0 = \mathbf I \]

\(\blacksquare\)

b) \(\mathbf N^2 = \begin{pmatrix}0&0&3\\0&0&0\\0&0&0\end{pmatrix}\), \(\mathbf N^3 = \mathbf 0\) : nilpotente d'ordre 3.

\[ (\mathbf I-\mathbf N)^{-1} = \mathbf I+\mathbf N+\mathbf N^2 = \begin{pmatrix}1&1&5\\0&1&3\\0&0&1\end{pmatrix} \]

Vérification : \((\mathbf I - \mathbf N) = \begin{pmatrix}1&-1&-2\\0&1&-3\\0&0&1\end{pmatrix}\). Ligne 1 × colonne 3 : \(1(5)+(-1)(3)+(-2)(1) = 5-3-2 = 0\) ✓ Ligne 1 × colonne 2 : \(1(1)+(-1)(1)+0 = 0\) ✓

c) C'est la version matricielle de

\[ \frac{1}{1-x} = 1+x+x^2+\dots \]

La différence est qu'ici la série s'arrête au bout de \(k\) termes, parce que \(\mathbf N^k = \mathbf 0\). On n'a donc besoin d'aucune hypothèse de convergence : c'est une identité algébrique exacte, valable même avec des coefficients entiers.

C'est aussi la formule établie au chapitre Prérequis 02, exercice 11, appliquée aux matrices.

Corrigé — Exercice 7

a) De la formule fondamentale \(\mathbf{A}(\operatorname{com}\mathbf A)^\top = (\det\mathbf A)\mathbf I_n\), prenons le déterminant des deux membres :

\[ \det\mathbf{A}\cdot\det\big((\operatorname{com}\mathbf A)^\top\big) = \det\big((\det\mathbf A)\mathbf I_n\big) = (\det\mathbf A)^n \]

(on a utilisé \(\det(\lambda\mathbf I_n) = \lambda^n\)).

Comme \(\det(\mathbf M^\top) = \det\mathbf M\) et \(\det\mathbf A \neq 0\) :

\[ \det(\operatorname{com}\mathbf A) = (\det\mathbf A)^{n-1} \quad\blacksquare \]

b) Ordre 2. \(\mathbf A = \begin{pmatrix}a&b\\c&d\end{pmatrix}\), \(\operatorname{com}\mathbf A = \begin{pmatrix}d&-c\\-b&a\end{pmatrix}\), de déterminant \(ad - bc = \det\mathbf A\). Et \((\det\mathbf A)^{2-1} = \det\mathbf A\) ✓

Ordre 3. Reprenons la matrice de l'exemple : \(\mathbf A = \begin{pmatrix}1&2&0\\0&1&3\\2&0&1\end{pmatrix}\), \(\det\mathbf A = 13\), \(\operatorname{com}\mathbf A = \begin{pmatrix}1&6&-2\\-2&1&4\\6&-3&1\end{pmatrix}\).

Sarrus : \(1(1)(1)+6(4)(6)+(-2)(-2)(-3) - (-2)(1)(6) - 1(4)(-3) - 6(-2)(1)\) \(= 1+144-12+12+12+12 = 169\).

Et \(13^{3-1} = 169\) ✓

Corrigé — Exercice 8

L'idée est de factoriser \(\mathbf{A}^{-1}+\mathbf{B}^{-1}\) en produit de matrices inversibles.

\[ \mathbf{A}^{-1}+\mathbf{B}^{-1} = \mathbf{A}^{-1}(\mathbf{I} + \mathbf{A}\mathbf{B}^{-1}) = \mathbf{A}^{-1}(\mathbf{B}+\mathbf{A})\mathbf{B}^{-1} \]

(Deuxième égalité : on écrit \(\mathbf I = \mathbf B\mathbf B^{-1}\), d'où \(\mathbf I + \mathbf A\mathbf B^{-1} = (\mathbf B+\mathbf A)\mathbf B^{-1}\).)

Les trois facteurs \(\mathbf A^{-1}\), \(\mathbf A+\mathbf B\) et \(\mathbf B^{-1}\) sont inversibles par hypothèse. Un produit de matrices inversibles l'est, donc \(\mathbf{A}^{-1}+\mathbf{B}^{-1}\) est inversible.

Son inverse s'obtient en inversant chaque facteur dans l'ordre inverse :

\[ (\mathbf{A}^{-1}+\mathbf{B}^{-1})^{-1} = (\mathbf B^{-1})^{-1}(\mathbf A+\mathbf B)^{-1}(\mathbf A^{-1})^{-1} = \mathbf{B}(\mathbf{A}+\mathbf{B})^{-1}\mathbf{A} \]

Ce n'est pas exactement la formule demandée. Reprenons en factorisant de l'autre côté :

\[ \mathbf{A}^{-1}+\mathbf{B}^{-1} = \mathbf{B}^{-1}(\mathbf{B}\mathbf{A}^{-1}+\mathbf{I}) = \mathbf{B}^{-1}(\mathbf{B}+\mathbf{A})\mathbf{A}^{-1} \]

d'où

\[ (\mathbf{A}^{-1}+\mathbf{B}^{-1})^{-1} = \mathbf{A}(\mathbf{A}+\mathbf{B})^{-1}\mathbf{B} \quad\blacksquare \]

Les deux expressions sont égales

On a démontré au passage que \(\mathbf{A}(\mathbf A+\mathbf B)^{-1}\mathbf B = \mathbf{B}(\mathbf A+\mathbf B)^{-1}\mathbf A\), ce qui n'est pas évident directement. C'est un exemple d'identité matricielle obtenue « gratuitement » en calculant la même chose de deux façons.

Cette formule est utilisée en statistique bayésienne : elle donne la variance d'une combinaison de deux estimateurs indépendants à partir de leurs précisions (inverses de variances).

Corrigé — Exercice 9

a) La \(i\)-ème coordonnée de \(\mathbf{Au}\) vaut

\[ \sum_{j=1}^{n}a_{ij}\times1 = \sum_{j=1}^{n}a_{ij} = 1 \]

par hypothèse. Donc \(\mathbf{Au} = \mathbf{u}\). \(\blacksquare\)

b) \(\mathbf{Au}=\mathbf{u}\) s'écrit \((\mathbf{A}-\mathbf{I})\mathbf{u} = \mathbf{0}\).

Comme \(\mathbf{u}\neq\mathbf{0}\), le système homogène associé à \(\mathbf{A}-\mathbf{I}\) admet une solution non nulle. Par le théorème central du chapitre 07 (équivalence 2 ⟺ 4), \(\mathbf{A}-\mathbf{I}\) n'est pas inversible, et \(\det(\mathbf{A}-\mathbf{I}) = 0\). \(\blacksquare\)

c) En termes du chapitre suivant : 1 est toujours valeur propre d'une matrice stochastique, de vecteur propre \(\mathbf{u}\).

Pour une chaîne de Markov, \(\mathbf{A}\) est la matrice de transition et le résultat garantit l'existence d'une distribution stationnaire : un vecteur de probabilités \(\pi\) tel que \(\pi^\top\mathbf{A} = \pi^\top\). C'est l'état d'équilibre vers lequel la chaîne converge (sous des hypothèses d'irréductibilité et d'apériodicité).

C'est aussi, exactement, le principe de PageRank : le score d'une page est la composante du vecteur propre associé à la valeur propre 1 de la matrice de transition du graphe du web.

Corrigé — Exercice 10

a) Pivot complet à chaque fois. Chaque résolution coûte \(\frac{2n^3}{3}\) (élimination) \(+\ n^2\) (remontée). Pour \(m\) seconds membres :

\[ C_a = m\left(\frac{2n^3}{3} + n^2\right) \approx \frac{2mn^3}{3} \]

b) Inverse explicite. Calculer \(\mathbf{A}^{-1}\) par Gauss-Jordan coûte environ \(2n^3\) (on traite \(n\) seconds membres simultanément). Puis chaque produit matrice-vecteur coûte \(2n^2\) :

\[ C_b \approx 2n^3 + 2mn^2 \]

c) LU.

\[ C_c \approx \frac{2n^3}{3} + 2mn^2 \]

Pour \(n=1000\) et \(m=50\), avec \(n^3 = 10^9\) et \(n^2 = 10^6\) :

Stratégie Calcul Opérations
(a) Pivot répété \(\frac{2\times50\times10^9}{3}\) \(3{,}3\times10^{10}\)
(b) Inverse \(2\times10^9 + 2\times50\times10^6\) \(2{,}1\times10^{9}\)
(c) LU \(\frac{2\times10^9}{3} + 10^8\) \(7{,}7\times10^{8}\)

LU est 43 fois plus rapide que le pivot répété et 2,7 fois plus rapide que l'inverse explicite.

d) Pourquoi LU plutôt que l'inverse, malgré des coûts du même ordre :

  1. Précision. L'inverse explicite accumule les erreurs d'arrondi sur \(n^2\) coefficients, puis les propage dans le produit. LU résout directement, avec une erreur bornée par le conditionnement — sans amplification supplémentaire.
  2. Structure creuse. Si \(\mathbf{A}\) est creuse (peu de coefficients non nuls), \(\mathbf{L}\) et \(\mathbf{U}\) le restent largement, alors que \(\mathbf{A}^{-1}\) est presque toujours pleine. Pour une matrice creuse d'ordre \(10^6\), LU est faisable et l'inverse ne l'est pas — il occuperait 8 To.
  3. Mémoire. LU se stocke à la place de \(\mathbf{A}\), sans allocation supplémentaire.

C'est la raison pour laquelle numpy.linalg.solve est préférable à numpy.linalg.inv(A) @ b, y compris quand les deux sont écrits en une ligne : la première appelle LAPACK avec une factorisation, la seconde forme une matrice dont on n'a pas besoin.


Chapitre suivant : Valeurs et vecteurs propres.