Inverse [m]
gives the inverse of a square matrix m.
Inverse
Inverse [m]
gives the inverse of a square matrix m.
Details and Options
- Inverse works on both symbolic and numerical matrices.
- For matrices with approximate real or complex numbers, the inverse is generated to the maximum possible precision given the input. A warning is given for ill‐conditioned matrices.
- The following options can be given
-
- Inverse [m,Modulus->p] evaluates the inverse of rational matrices modulo the integer n. If n is zero, ordinary arithmetic is used. If n is not prime, the computation may fail. »
- Inverse [m,ZeroTest->test] evaluates test[m[[i,j]]] to determine whether matrix elements are zero.
- Settings of Method applicable to exact and symbolic matrices include "CofactorExpansion", "DivisionFreeRowReduction", and "OneStepRowReduction". The default setting of Automatic switches among these methods depending on the matrix given.
- Inverse [m] formats as in StandardForm and TraditionalForm . »
Examples
open all close allBasic Examples (3)
Inverse of a 2×2 matrix:
Enter the matrix in a grid:
Inverse of a symbolic matrix:
Scope (14)
Basic Uses (9)
Find the inverse of a machine-precision matrix:
Invert a complex matrix:
Inverse of an exact matrix:
Inverse of an arbitrary-precision matrix:
Inverse of a symbolic matrix:
Verifying a symbolic inverse may require simplification:
The inversion of large machine-precision matrices is efficient:
Inverse of a matrix over a finite field:
Inverse of a CenteredInterval matrix:
Find a random representative mrep of m:
Verify that minv contains the inverse of mrep:
Output formatting:
Special Matrices (5)
The inverse of a sparse matrix is returned as a normal matrix:
Format the result:
When possible, the inverse of a structured matrix is returned as another structured matrix:
This is not always possible:
IdentityMatrix is its own inverse:
Inverse of HilbertMatrix :
Visualize the inverses for several matrix sizes:
Compute the inverse of a matrix of univariate polynomials of degree :
Options (7)
Method (4)
The Automatic method attempts to use a method appropriate for a given matrix:
Here, the Automatic method has avoided numerical instability possible for some methods when applied to an ill-conditioned matrix:
Generate a random numeric matrix with small off-diagonal elements and compute its inverse using various methods:
The results are very close but can differ slightly in the least significant digits due to numerical precision handling:
Compare timings using different methods on a matrix with exact numeric entries:
Create a matrix with several symbolic elements:
Compare timings and result sizes using the different methods on this matrix:
Modulus (1)
Invert a matrix using arithmetic modulo five:
The inverse using normal arithmetic:
Visualize the two results:
ZeroTest (1)
The automatic zero test cannot detect that the following matrix is nonsingular:
The problem is that machine-precision underflows for the bottom right entry:
The entry is very small but nonzero:
Use a zero test employing arbitrary-precision arithmetic to invert the matrix:
Modulus (1)
Invert a matrix of integers modulo 5:
Check it:
Applications (10)
Solving Equations (4)
Solve the system of equations , , . First, form the coefficient matrix and constant vector :
The solution is given by TemplateBox[{a}, Inverse].b:
Substitute the solution into the original system of equations to verify the solution:
Solve the matrix equation :
Multiplying both sides of the equation on the left by TemplateBox[{m}, Inverse] shows x=TemplateBox[{m}, Inverse].b:
Confirm the result using LinearSolve :
For numerical and especially sparse systems, LinearSolve can be considerably faster:
Solve the matrix equation :
Multiplying both sides of the equation on the left by TemplateBox[{m}, Inverse] shows x=TemplateBox[{m}, Inverse].y:
Substitute the solution into the equation for verification:
Solve the system of ODEs , , . First, construct the coefficient matrix for the right-hand side:
Find the eigenvalues and eigenvectors:
Construct a diagonal matrix whose entries are the exponential of :
Construct the matrix whose columns are the corresponding eigenvectors:
The general solution is p.d.TemplateBox[{p}, Inverse].{TemplateBox[{1}, CTraditional],TemplateBox[{2}, CTraditional],TemplateBox[{3}, CTraditional]}, for three arbitrary starting values:
Verify the solution using DSolveValue :
Change of Basis/Coordinates (6)
Express a general vector in TemplateBox[{}, Reals]^3 as a linear combination of the vectors , and . First, verify the vectors are linearly independent by checking that their null space is empty:
Form the matrix whose columns are the basis vectors:
The coefficients of a general vector are given by TemplateBox[{p}, Inverse].v:
Verify that does indeed equal the linear combination :
Find the change-of-basis matrix that transforms coordinates with respect to the basis to coordinates with respect to the basis :
The matrix whose columns are the transforms from -coordinates to standard coordinates:
The matrix whose columns are the transforms from -coordinates to standard coordinates:
Its inverse converts from standard coordinates back to -coordinates:
Therefore, TemplateBox[{q}, Inverse].p converts from -coordinates to -coordinates:
Express the linear operator whose representation in the standard is given by in the basis , ,
The matrix whose columns are the transforms from -coordinates to standard coordinates:
Its inverse converts from standard coordinates to -coordinates:
Therefore the representation of in -coordinates is:
Inverse can be used to diagonalize a matrix as m=p.d.TemplateBox[{p}, Inverse]. Compute 's eigenvalues and eigenvectors:
Construct a diagonal matrix from the eigenvalues and a matrix whose columns are the eigenvectors:
Confirm the identity m=p.d.TemplateBox[{p}, Inverse]:
Any function of the matrix can now be computed as f(m)=p.f(d).TemplateBox[{p}, Inverse]. For example, MatrixPower :
Similarly, MatrixExp becomes trivial, requiring only exponentiating the diagonal elements of :
Inverse of a transformation matrix gives the matrix for the reverse operation. For example, consider a translation by :
The inverse of its transformation matrix gives a translation by the opposite motion:
Consider a general affine transformation:
Construct the inverse transformation:
Verify that the two transformations really do undo each other:
For a mapping f:x in TemplateBox[{}, Reals]^n->y in TemplateBox[{}, Reals]^n, the Jacobian of the inverse mapping TemplateBox[{{f, ^, {(, {(, {-, 1}, )}, )}}, y}, Grad] is given by TemplateBox[{{(, TemplateBox[{f, x}, Grad, SyntaxForm -> Del], )}}, Inverse]. Consider the mapping from Cartesian to spherical coordinates:
Compute the Jacobian at the point :
The inverse mapping is the transformation from spherical back to Cartesian coordinates:
Verify the inverse function:
Compute the Jacobian of the inverse mapping at the coordinates corresponding to :
Confirm the identity TemplateBox[{{f, ^, {(, {(, {-, 1}, )}, )}}, y}, Grad]=TemplateBox[{{(, TemplateBox[{f, x}, Grad, SyntaxForm -> Del], )}}, Inverse]:
Properties & Relations (13)
Inverse satisfies the relation a.TemplateBox[{a}, Inverse]=TemplateBox[{a}, Inverse].a=IdentityMatrix[n] for an matrix :
Inverse satisfies the relation TemplateBox[{{(, {a, ., b}, )}}, Inverse]=TemplateBox[{b}, Inverse].TemplateBox[{a}, Inverse]:
Inverse satisfies the relation TemplateBox[{{(, TemplateBox[{a}, Transpose], )}}, Inverse]=TemplateBox[{{(, TemplateBox[{a}, Inverse], )}}, Transpose]:
A square matrix has an inverse if and only if its determinant is nonzero:
Moreover, determinant of the inverse TemplateBox[{TemplateBox[{a}, Inverse, SyntaxForm -> SuperscriptBox]}, Det] equals 1/(TemplateBox[{a}, Det]):
MatrixPower [m,-1] equals Inverse [m]:
For an invertible matrix , Inverse [a] equals Adjugate [a]/Det [a]:
Inverse [m] equals LinearSolve [m,IdentityMatrix [n]] for an invertible n×n matrix:
The inverse of an orthogonal matrix is given by Transpose :
The inverse of a unitary matrix is given by ConjugateTranspose :
A matrix and its inverse have the same symmetry:
A QuantityArray and its inverse have reciprocal units:
For an invertible matrix , Inverse [a] and PseudoInverse [a] coincide:
PseudoInverse extends to singular as well as rectangular matrices:
For an invertible matrix , Inverse [a] and DrazinInverse [a] coincide:
DrazinInverse extends to singular square matrices:
Possible Issues (4)
The inverse may not exist:
Typically a pseudo inverse does:
Full inverses do not exist for rectangular matrices:
Use PseudoInverse instead:
Accurate inverses cannot be found for ill-conditioned machine-precision numerical matrices:
Exact result:
Arbitrary-precision result:
The computation may fail if a non-prime modulus is provided:
See Also
PseudoInverse LinearSolve RowReduce NullSpace LinearSolveFunction DrazinInverse Adjugate MatrixRank
Function Repository: LinearAlgebraMod TridiagonalInverse
History
Introduced in 1988 (1.0) | Updated in 1996 (3.0) ▪ 2022 (13.2) ▪ 2024 (14.0) ▪ 2025 (14.3)
Text
Wolfram Research (1988), Inverse, Wolfram Language function, https://reference.wolfram.com/language/ref/Inverse.html (updated 2025).
CMS
Wolfram Language. 1988. "Inverse." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/Inverse.html.
APA
Wolfram Language. (1988). Inverse. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Inverse.html
BibTeX
@misc{reference.wolfram_2025_inverse, author="Wolfram Research", title="{Inverse}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Inverse.html}", note=[Accessed: 24-November-2025]}
BibLaTeX
@online{reference.wolfram_2025_inverse, organization={Wolfram Research}, title={Inverse}, year={2025}, url={https://reference.wolfram.com/language/ref/Inverse.html}, note=[Accessed: 24-November-2025]}