Tool to invert a matrix. The inverse of a square matrix M is a matrix denoted M^-1 such as que M.M^-1=I where I is the identity matrix.

Inverse of a Matrix - dCode

Tag(s) : Matrix

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!

A suggestion ? a feedback ? a bug ? an idea ? *Write to dCode*!

The inverse of a square matrix $ M $ is noted $ M^{-1} $ and can be calculated in several ways. The most suitable for 2x2 or 3x3 matrix sizes is the cofactor method which necessitate to calculate the determinant of the matrix $ \det M $ and the transposed cofactor matrix (also called adjugate matrix $ \operatorname{adj}(M) $):

$$ M^{-1} = \frac{1}{\det M} \left( \operatorname{cof}(M) \right)^\mathsf{T} = \frac{1}{\det M} \operatorname{adj}(M) $$

The dCode calculator works for any size of square matrix.

For a 2x2 matrix (order 2):

$$ M = \begin{bmatrix} a & b \\ c & d \\ \end{bmatrix} \\ \det(M) = ad - bc \\ \operatorname{cof}(M) = \begin{bmatrix} d & -c \\ -b & a \end{bmatrix} \\ \operatorname{adj}(M) = \left( \operatorname{cof}(M) \right)^\mathsf{T} = \begin{bmatrix} d & -b \\ -c & a \end{bmatrix} \\ M^{-1} = \frac{1}{ad - bc} \begin{bmatrix} d & -b \\ -c & a \\ \end{bmatrix} $$

__Example:__ $$ M = \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix} \Rightarrow M^{-1} = \frac{1}{\det(M)} \begin{bmatrix} 4 & -2 \\ -3 & 1 \\ \end{bmatrix} = -\frac{1}{2} \begin{bmatrix} 4 & -2 \\ -3 & 1 \\ \end{bmatrix} $$

For a 3x3 matrix (order 3):

$$ M^{-1} = \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix}^{-1} = \left( \begin{bmatrix} \frac{e i-f h}{-c e g+b f g+c d h-a f h-b d i+a e i} & \frac{c h-b i}{-c e g+b f g+c d h-a f h-b d i+a e i} & \frac{b f-c e}{-c e g+b f g+c d h-a f h-b d i+a e i} \\ \frac{f g-d i}{-c e g+b f g+c d h-a f h-b d i+a e i} & \frac{a i-c g}{-c e g+b f g+c d h-a f h-b d i+a e i} & \frac{c d-a f}{-c e g+b f g+c d h-a f h-b d i+a e i} \\ \frac{d h-e g}{-c e g+b f g+c d h-a f h-b d i+a e i} & \frac{b g-a h}{-c e g+b f g+c d h-a f h-b d i+a e i} & \frac{a e-b d}{-c e g+b f g+c d h-a f h-b d i+a e i} \end{bmatrix} \right) $$

It is essential that the determinant of the matrix to be inverted is not equal to zero for the matrix to be invertible.

A matrix is invertible if its determinant is non-zero (different from 0). So to prove that a matrix has an inverse, calculate the determinant of the matrix, if it is different from 0, then the matrix is invertible.

A non invertible matrix is called *singular* (inversion is not possible).

Avoid the term *inversible* which is wrong.

A matrix with a determinant equal to 0 is not invertible. It does not have an inverse, it is not possible to calculate its inverse.

The multiplication of the matrix by its inverse must give the identity matrix. So the computation of $ M . M^{-1} = I $.

The principle is the same, but instead of calculating the determinant, calculate the modular inverse of the matrix determinant.

dCode retains ownership of the "Inverse of a Matrix" source code. Except explicit open source licence (indicated Creative Commons / free), the "Inverse of a Matrix" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Inverse of a Matrix" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Inverse of a Matrix" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!

Reminder : dCode is free to use.

The copy-paste of the page "Inverse of a Matrix" or any of its results, is allowed (even for commercial purposes) as long as you cite dCode!

Exporting results as a .csv or .txt file is free by clicking on the *export* icon

Cite as source (bibliography):

*Inverse of a Matrix* on dCode.fr [online website], retrieved on 2023-12-03,

- Square Matrix Inverse Calculator NxN
- Matrix Modular Inverse Calculator
- How to calculate the inverse of an invertible matrix?
- How to prove that a matrix is invertible?
- How to inverse a matrix with zero determinant?
- How to check that a matrix is the inverse of another?
- How to calculate the modular inverse of a matrix?

inverse,matrix,square,identity,inversion,invertible,singular

https://www.dcode.fr/matrix-inverse

© 2023 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback