Matrices inversibles, systèmes linéaires~2 min
Une matrice carrée $A$ d'ordre $n$ est inversible s'il existe une matrice carrée $B$ telle que $AB=BA=I_n$. Cette matrice est alors unique : on la note $A^{-1}$. (Pour des matrices carrées, $AB=I_n$ suffit : $BA=I_n$ en découle ; admis.)
Unicité. Si $B$ et $C$ vérifient $AB=BA=I$ et $AC=CA=I$, alors $B=BI=B(AC)=(BA)C=IC=C$.
Inverse d'un produit. Si $A$ et $B$ sont inversibles de même ordre, alors $AB$ est inversible et $\boldsymbol{(AB)^{-1}=B^{-1}A^{-1}}$ (attention à l'ordre). En effet : $(AB)(B^{-1}A^{-1})=A(BB^{-1})A^{-1}=AIA^{-1}=AA^{-1}=I$, et de même $(B^{-1}A^{-1})(AB)=I$.
$A=\begin{pmatrix}a&b\\c&d\end{pmatrix}$ est inversible si et seulement si $\boldsymbol{ad-bc\neq0}$, et dans ce cas $\;A^{-1}=\dfrac{1}{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}$.
Preuve : $\begin{pmatrix}a&b\\c&d\end{pmatrix}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}=(ad-bc)I_2$ ; si $ad-bc=0$, ce produit est nul avec un second facteur non nul (sauf $A=0$), ce qu'interdit l'inversibilité de $A$.
Ordre $3$ : l'inverse se calcule à la calculatrice ou avec Python (np.linalg.inv) ; on sait vérifier un inverse donné en calculant $AB$.
Écrire le système sous la forme $AX=B$ ($A$ matrice des coefficients, $X$ colonne des inconnues, $B$ colonne des seconds membres). Si $A$ est inversible, en multipliant à gauche par $A^{-1}$ : $AX=B\iff X=A^{-1}B$ : le système a une unique solution.
$A=\begin{pmatrix}2&5\\1&3\end{pmatrix}$ : $ad-bc=6-5=1\neq0$, donc $A^{-1}=\begin{pmatrix}3&-5\\-1&2\end{pmatrix}$. Vérification : $\begin{pmatrix}2&5\\1&3\end{pmatrix}\begin{pmatrix}3&-5\\-1&2\end{pmatrix}=\begin{pmatrix}6-5&-10+10\\3-3&-5+6\end{pmatrix}=I_2$.
Le système $\begin{cases}2x+5y=1\\x+3y=4\end{cases}$ s'écrit $AX=B$ avec $X=\begin{pmatrix}x\\y\end{pmatrix}$, $B=\begin{pmatrix}1\\4\end{pmatrix}$ : $X=A^{-1}B=\begin{pmatrix}3-20\\-1+8\end{pmatrix}=\begin{pmatrix}-17\\7\end{pmatrix}$. Solution $(-17\,;7)$.
import numpy as np A = np.array([[2, 5], [1, 3]]) B = np.array([[1], [4]]) A @ B # produit matriciel np.linalg.inv(A) @ B # solution de AX = B np.linalg.matrix_power(A, 5) # A puissance 5
def produit(A, B): # listes de listes
n, p, q = len(A), len(B), len(B[0])
C = [[0] * q for i in range(n)]
for i in range(n):
for j in range(q):
for k in range(p):
C[i][j] += A[i][k] * B[k][j]
return C