20 janvier 2017    /    Viewed: 28887    /    Comments: 0    /    Edit

Pour inverser une matrice avec python il existe sous numpy la méthode Linear algebra (numpy.linalg). Exemple

A = \left( \begin{array}{ccc}
1 & 3 & 3 \\
1 & 4 & 3 \\
1 & 3 & 4
\end{array}\right)

matrice inverse A_inv

A^{-1} = \left( \begin{array}{ccc}
7 & -3 & -3 \\
-1 & 1 & 0 \\
-1 & 0 & 1
\end{array}\right)

>>> import numpy as np
>>> A = np.array(([1,3,3],[1,4,3],[1,3,4]))
>>> A
array([[1, 3, 3],
       [1, 4, 3],
       [1, 3, 4]])
>>> A_inv = np.linalg.inv(A)
>>> A_inv
array([[ 7., -3., -3.],
       [-1.,  1.,  0.],
       [-1.,  0.,  1.]])


Vérification

>>> A_inv.dot(A)
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])


### Références

Liens Site
Matrice inversible wikipedia
Linear algebra (numpy.linalg) scipy doc
Inverse of a matrix using numpy stackoverflow
Inverse a matrix in python stackoverflow
Python Inverse of a Matrix stackoverflow
Matrix Inversion: Finding the Inverse of a Matrix purplemath

##### Daidalos

Hi, I am Ben.

I have developed this web site from scratch with Django to share with everyone my notes. If you have any ideas or suggestions to improve the site, let me know ! (you can contact me using the form in the welcome page). Thanks!