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
-
Method Automatic method to use Modulus 0 integer modulus to use ZeroTest Automatic test for whether an element is zero - 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)
Scope (14)
Basic Uses (9)
Find the inverse of a machine-precision matrix:
Inverse[{{1.2, 2.5, -3.2}, {0.7, -9.4, 5.8}, {-0.2, 0.3, 6.4}}]Inverse[{{1. + I, 2, 3 - 2I}, {0, 4π, 5I}, {E, 0, 6}}]Inverse[{{2, 3, 2}, {4, 9, 2}, {7, 2, 4}}]Inverse of an arbitrary-precision matrix:
Inverse[RandomReal[1, {2, 2}, WorkingPrecision -> 20]]Inverse[{{a, b}, {c, d}}]Verifying a symbolic inverse may require simplification:
%.{{a, b}, {c, d}}Simplify[%]The inversion of large machine-precision matrices is efficient:
a = RandomReal[{0, 10}, {800, 800}];Inverse[a];//TimingInverse of a matrix over a finite field:
ℱ = FiniteField[23, 4];
Inverse[{{ℱ[12], ℱ[23], ℱ[34]}, {ℱ[45], ℱ[56], ℱ[67]}, {ℱ[78], ℱ[89], ℱ[90]}}]//MatrixFormInverse of a CenteredInterval matrix:
(m = Map[CenteredInterval, RandomReal[{-10, 10}, {3, 3}, WorkingPrecision -> 10], {2}])//MatrixForm(minv = Inverse[m])//MatrixFormFind a random representative mrep of m:
ranrep[e_CenteredInterval] := e["Center"] + RandomInteger[{-1000, 1000}] / 1000e["Radius"]
(mrep = Map[ranrep, m, {2}])//MatrixFormVerify that minv contains the inverse of mrep:
MapThread[IntervalMemberQ, {minv, Inverse[mrep]}, 2]//MatrixFormInverse[m]Special Matrices (5)
The inverse of a sparse matrix is returned as a normal matrix:
SparseArray[{{1, 3} -> 1, {2, 2} -> 2, {3, 1} -> 3}, {3, 3}]Inverse[%]%//MatrixFormWhen possible, the inverse of a structured matrix is returned as another structured matrix:
QuantityArray[{{1, 2}, {3, 4}}, {"Meters", "Seconds"}]Inverse[%]SymmetrizedArray[{{1, 1} -> 3, {2, 2} -> 1, {3, 1} -> -5}, {3, 3}, Symmetric[All]]Inverse[%]IdentityMatrix is its own inverse:
Inverse[IdentityMatrix[3]]Inverse of HilbertMatrix:
Inverse[HilbertMatrix[3]]//MatrixFormVisualize the inverses for several matrix sizes:
Table[ArrayPlot[Inverse[HilbertMatrix[n]], Mesh -> True, ColorFunction -> "Rainbow"], {n, {3, 7, 15, 25}}]Compute the inverse of a
matrix of univariate polynomials of degree
:
rpoly[n_] := RandomInteger[{-2 ^ 10, 2 ^ 10}, {n + 1}].x ^ Range[0, n]
SeedRandom[1234];
m = Table[rpoly[100], {10}, {10}];Inverse[m]//Short[#, 4]&//AbsoluteTimingOptions (7)
Method (4)
The Automatic method attempts to use a method appropriate for a given matrix:
h = N[HilbertMatrix[5], 10];Inverse[h, Method -> Automatic]//MatrixFormHere, the Automatic method has avoided numerical instability possible for some methods when applied to an ill-conditioned matrix:
Inverse[h, Method -> "CofactorExpansion"]
Generate a random numeric matrix with small off-diagonal elements and compute its inverse using various methods:
SeedRandom[1111];
matrix = RandomReal[{0, 10 ^ -10}, {4, 4}] + DiagonalMatrix[{1, 1, 1, 1}]inverses = Table[Inverse[matrix, Method -> meth], {meth, {Automatic, "CofactorExpansion", "DivisionFreeRowReduction", "OneStepRowReduction"}}];The results are very close but can differ slightly in the least significant digits due to numerical precision handling:
MatrixForm[inverses[[1]] - #]& /@ Rest[inverses]Compare timings using different methods on a matrix with exact numeric entries:
matrix = HilbertMatrix[11];inverses = Table[RepeatedTiming@Inverse[matrix, Method -> meth], {meth, {Automatic, "CofactorExpansion", "DivisionFreeRowReduction", "OneStepRowReduction"}}];inverses[[All, 1]]Create a matrix with several symbolic elements:
matrix = HilbertMatrix[7];
matrix[[1, {1, 2}]] = a;
matrix[[2, {3, 4}]] = {b, c};
matrix[[{3, 4}, 2]] = {c, b};
matrix[[4, 4]] = d;
MatrixForm[matrix]Compare timings and result sizes using the different methods on this matrix:
inverses = Table[Timing[Inverse[matrix, Method -> meth]], {meth, {"CofactorExpansion", "DivisionFreeRowReduction", "OneStepRowReduction"}}];
Map[{#[[1]], LeafCount[#[[2]]]}&, inverses]Modulus (1)
ZeroTest (1)
The automatic zero test cannot detect that the following matrix is nonsingular:
m = {{1, 0}, {1, π - Root[8394424425973111046102466470564958295830951628283298149701386477242875447818673389226090192984\
029732939781061026077658550311303875032545498684307238995818676138470695390760454711538845664627035\
4435927421991406959528672443375423719871723709 ... 387494583708363193025825642551076544298993049143\
615185128783410198233550035568901018893959814690410410216282149769634197560732600787754846222883582\
50360748898046876231601365242979664076168746640932325062440279570663043850648012*#1^20 & , 4, 0]}}Inverse[m]The problem is that machine-precision underflows for the bottom right entry:
N[π - Root[8394424425973111046102466470564958295830951628283298149701386477242875447818673389226090192984\
029732939781061026077658550311303875032545498684307238995818676138470695390760454711538845664627035\
4435927421991406959528672443375423719871723709 ... 387494583708363193025825642551076544298993049143\
615185128783410198233550035568901018893959814690410410216282149769634197560732600787754846222883582\
50360748898046876231601365242979664076168746640932325062440279570663043850648012*#1^20 & , 4, 0]]The entry is very small but nonzero:
N[π - Root[8394424425973111046102466470564958295830951628283298149701386477242875447818673389226090192984\
029732939781061026077658550311303875032545498684307238995818676138470695390760454711538845664627035\
4435927421991406959528672443375423719871723709 ... 387494583708363193025825642551076544298993049143\
615185128783410198233550035568901018893959814690410410216282149769634197560732600787754846222883582\
50360748898046876231601365242979664076168746640932325062440279570663043850648012*#1^20 & , 4, 0], 10]Use a zero test employing arbitrary-precision arithmetic to invert the matrix:
Inverse[m, ZeroTest -> (N[#, $MachinePrecision] == 0&)]%.m//SimplifyApplications (10)
Solving Equations (4)
Solve the system of equations
,
,
. First, form the coefficient matrix
and constant vector
:
a = {{6, 9, 0}, {-7, 0, 3}, {0, 5, 9}};
b = {11, -12, -9};
{a//MatrixForm, b//MatrixForm}Inverse[a].bSubstitute the solution into the original system of equations to verify the solution:
6x + 9y == 11 && 3z - 7x == -12 && 5y + 9z == -9 /. Thread[{x, y, z} -> %]m = {{1, 2}, {3, 4}};b = {5, 6};Multiplying both sides of the equation on the left by
shows
:
Inverse[m].bConfirm the result using LinearSolve:
LinearSolve[m, b]For numerical and especially sparse systems, LinearSolve can be considerably faster:
n = 3500;
s = SparseArray[{{i_, i_} -> -2., {i_, j_} /; Abs[i - j] == 1 -> 1.}, {n, n}];
v = RandomReal[1, n];AbsoluteTiming[LinearSolve[s, v];]AbsoluteTiming[Inverse[s].v;]m = {{-6, 7, 9}, {-2, 1, 3}, {7, -10, 4}};y = {{-5, 6, -4}, {-7, 7, 8}, {-2, 1, 12}};Multiplying both sides of the equation on the left by
shows
:
Inverse[m].ySubstitute the solution into the equation for verification:
m.x == y /. x -> %Solve the system of ODEs
,
,
. First, construct the coefficient matrix
for the right-hand side:
a = {{0, 1, 0}, {0, 0, 1}, {-2, 1, 2}};Find the eigenvalues and eigenvectors:
{λ, v} = Eigensystem[a]Construct a diagonal matrix whose entries are the exponential of
:
d = DiagonalMatrix[Exp[t λ]]Construct the matrix whose columns are the corresponding eigenvectors:
p = Transpose[v]The general solution is
, for three arbitrary starting values:
p.d.Inverse[p].{C[1], C[2], C[3]}Verify the solution using DSolveValue:
Simplify[% == DSolveValue[{x'[t] == y[t], y'[t] == z[t], z'[t] == -2x[t] + y[t] + 2z[t]}, {x[t], y[t], z[t]}, t]]Change of Basis/Coordinates (6)
Express a general vector in
as a linear combination of the vectors
,
and
. First, verify the vectors are linearly independent by checking that their null space is empty:
Subscript[b, 1] = {1, 0, 1};Subscript[b, 2] = {2, 2, 3};Subscript[b, 3] = {-1, -1, 1};
NullSpace[{Subscript[b, 1], Subscript[b, 2], Subscript[b, 3]}]Form the matrix
whose columns are the basis vectors:
p = Transpose[{Subscript[b, 1], Subscript[b, 2], Subscript[b, 3]}];The coefficients of a general vector
are given by
:
{Subscript[c, 1], Subscript[c, 2], Subscript[c, 3]} = Inverse[p].{x, y, z}Verify that
does indeed equal the linear combination
:
Simplify[Underoverscript[∑, i = 1, 3]Subscript[c, i]Subscript[b, i]]Find the change-of-basis matrix that transforms coordinates with respect to the basis
to coordinates with respect to the basis
:
{Subscript[b, 1], Subscript[b, 2], Subscript[b, 3]} = {{2, 5, -4}, {1, 0, 3}, {-3, 3, -2}};{Subscript[d, 1], Subscript[d, 2], Subscript[d, 3]} = {{-2, 4, 1}, {3, -4, -1}, {3, 3, -4}};The matrix
whose columns are the
transforms from
-coordinates to standard coordinates:
(p = Transpose[{Subscript[b, 1], Subscript[b, 2], Subscript[b, 3]}])//MatrixFormThe matrix
whose columns are the
transforms from
-coordinates to standard coordinates:
(q = Transpose[{Subscript[d, 1], Subscript[d, 2], Subscript[d, 3]}])//MatrixFormIts inverse converts from standard coordinates back to
-coordinates:
Inverse[q]Therefore,
converts from
-coordinates to
-coordinates:
Inverse[q].pExpress the linear operator
whose representation in the standard is given by
in the basis
,
, ![]()
(m = {{1, 2, -3}, {2, 0, 1}, {-3, 1, 5}})//MatrixFormSubscript[b, 1] = {1, 0, 1};Subscript[b, 2] = {2, 2, 3};Subscript[b, 3] = {-1, -1, 2};The matrix
whose columns are the
transforms from
-coordinates to standard coordinates:
(p = Transpose[{Subscript[b, 1], Subscript[b, 2], Subscript[b, 3]}])//MatrixFormIts inverse converts from standard coordinates to
-coordinates:
Inverse[p]Therefore the representation of
in
-coordinates is:
p.m.Inverse[p]Inverse can be used to diagonalize a matrix as
. Compute
's eigenvalues and eigenvectors:
m = {{9, -7, 3}, {12, -10, 3}, {16, -16, 1}};Eigensystem[m]Construct a diagonal matrix
from the eigenvalues and a matrix
whose columns are the eigenvectors:
{d = DiagonalMatrix[First[%]], p = Transpose[Last[%]]}m == p.d.Inverse[p]Any function of the matrix can now be computed as
. For example, MatrixPower:
MatrixPower[m, k] == p.MatrixPower[d, k].Inverse[p]Similarly, MatrixExp becomes trivial, requiring only exponentiating the diagonal elements of
:
MatrixExp[m] == p.MatrixExp[d].Inverse[p]MatrixExp[d]Inverse of a transformation matrix gives the matrix for the reverse operation. For example, consider a translation by
:
trans = TranslationTransform[{Δx, Δy, Δz}]The inverse of its transformation matrix gives a translation by the opposite motion:
Inverse[TransformationMatrix[trans]]//MatrixFormTransformationFunction[%] == TranslationTransform[-{Δx, Δy, Δz}]Consider a general affine transformation:
aff = LinearFractionalTransform[{Array[Subscript[a, #1, #2]&, {2, 2}], Array[Subscript[b, #]&, {2}]}]Construct the inverse transformation:
affInv = TransformationFunction[Inverse[TransformationMatrix[aff]]]Verify that the two transformations really do undo each other:
affInv[aff[{x, y}]]//Simplifyaff[affInv[{x, y}]]//SimplifyFor a mapping
, the Jacobian of the inverse mapping
is given by
. Consider the mapping from Cartesian to spherical coordinates:
f[x_, y_, z_] := {Sqrt[x^2 + y^2 + z^2], ArcTan[z, Sqrt[x^2 + y^2]], ArcTan[x, y]}Compute the Jacobian at the point
:
fJac = Grad[f[x, y, z], {x, y, z}] /. {x -> 1, y -> 1, z -> 0}The inverse mapping is the transformation from spherical back to Cartesian coordinates:
fInv[r_, θ_, φ_] := {r Cos[φ]Sin[θ], r Sin[θ]Sin[φ], r Cos[θ]}fInv@@f[x, y, z]Compute the Jacobian of the inverse mapping at the
coordinates corresponding to
:
fInvJac = Grad[fInv[r, θ, φ], {r, θ, φ}] /. Thread[{r, θ, φ} -> f[1, 1, 0]]fInvJac == Inverse[fJac]Properties & Relations (13)
Inverse satisfies the relation
for an
matrix
:
a = {{1, 2}, {3, 4}}a.Inverse[a] == Inverse[a].a == IdentityMatrix[2]Inverse satisfies the relation
:
a = {{1, 1, 1}, {6, 9, 7}, {8, 1, 9}};b = {{0, 3, 9}, {7, 9, 7}, {4, 4, 1}};Inverse[a.b] == Inverse[b].Inverse[a]Inverse satisfies the relation
:
a = {{-(1/25), (12/25), -(7/25)}, {-(7/25), (9/25), (1/25)}, {(13/75), -(31/75), (16/75)}};Inverse[Transpose[a]] == Transpose[Inverse[a]]A square matrix has an inverse if and only if its determinant is nonzero:
m = (| | | |
| - | - | - |
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |);Det[m]Inverse[m]Moreover, determinant of the inverse
equals
:
a = RandomReal[1, {5, 5}];Det[Inverse[a]] == (1/Det[a])MatrixPower[m,-1] equals Inverse[m]:
m = {{9, 4, 1, 8}, {4, 8, 3, 4}, {7, 6, 8, 4}, {6, 9, 0, 9}};MatrixPower[m, -1] == Inverse[m]For an invertible matrix
, Inverse[a] equals Adjugate[a]/Det[a]:
a = {{1, 3, 5}, {7, 1, -1}, {8, 4, 1}};Inverse[a] == Adjugate[a] / Det[a]Inverse[m] equals LinearSolve[m,IdentityMatrix[n]] for an invertible n×n matrix:
m = RandomReal[1, {5, 5}];Inverse[m] == LinearSolve[m, IdentityMatrix[5]]The inverse of an orthogonal matrix is given by Transpose:
r = {{-(6/7), (2/7), (3/7)}, {(2/7), -(3/7), (6/7)}, {(3/7), (6/7), (2/7)}};OrthogonalMatrixQ[r]Inverse[r] == Transpose[r]The inverse of a unitary matrix is given by ConjugateTranspose:
u = {{-(8/9), -(2I/9), (2/9) - (I/3)}, {(2I/9), -(5/9), (2/3) + (4I/9)}, {(2/9) + (I/3), (2/3) - (4I/9), (4/9)}};UnitaryMatrixQ[u]Inverse[u] == ConjugateTranspose[u]A matrix and its inverse have the same symmetry:
s = {{3, 0, -5}, {0, 1, 0}, {-5, 0, 0}};{TensorSymmetry[s], TensorSymmetry[Inverse[s]]}a = {{0, -(3/2), (5/2), -6}, {(3/2), 0, 4, 3}, {-(5/2), -4, 0, -5}, {6, -3, 5, 0}};{TensorSymmetry[a], TensorSymmetry[Inverse[a]]}A QuantityArray and its inverse have reciprocal units:
QuantityArray[{{1, 2}, {3, 4}}, {("Meters"/"Seconds"), ("Meters"/"Seconds")}]Inverse[%]For an invertible matrix
, Inverse[a] and PseudoInverse[a] coincide:
a = (| | | |
| - | - | - |
| 4 | 3 | 8 |
| 9 | 5 | 2 |
| 9 | 6 | 7 |);Inverse[a] === PseudoInverse[a]PseudoInverse extends to singular as well as rectangular matrices:
PseudoInverse[(| | |
| - | - |
| 1 | 2 |
| 1 | 2 |)]//MatrixFormPseudoInverse[(| | |
| - | - |
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |)]//MatrixFormFor an invertible matrix
, Inverse[a] and DrazinInverse[a] coincide:
a = (| | | |
| - | - | - |
| 4 | 3 | 8 |
| 9 | 5 | 2 |
| 9 | 6 | 7 |);Inverse[a] === DrazinInverse[a]DrazinInverse extends to singular square matrices:
DrazinInverse[(| | |
| - | - |
| 1 | 2 |
| 1 | 2 |)]//MatrixFormPossible Issues (4)
Inverse[(| | |
| - | - |
| 1 | 2 |
| 1 | 2 |)]Typically a pseudo inverse does:
PseudoInverse[(| | |
| - | - |
| 1 | 2 |
| 1 | 2 |)]Full inverses do not exist for rectangular matrices:
Inverse[(| | | |
| - | - | - |
| 1 | 2 | 2 |
| 3 | 1 | 4 |)]Use PseudoInverse instead:
PseudoInverse[(| | | |
| - | - | - |
| 1 | 2 | 2 |
| 3 | 1 | 4 |)]Accurate inverses cannot be found for ill-conditioned machine-precision numerical matrices:
Inverse[N@HilbertMatrix[15]][[1, 1]]Inverse[HilbertMatrix[15]][[1, 1]]Inverse[N[HilbertMatrix[15], 30]][[1, 1]]The computation may fail if a non-prime modulus is provided:
Inverse[{{1, 2}, {3, 2}}, Modulus -> 6]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_2026_inverse, author="Wolfram Research", title="{Inverse}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Inverse.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_inverse, organization={Wolfram Research}, title={Inverse}, year={2025}, url={https://reference.wolfram.com/language/ref/Inverse.html}, note=[Accessed: 13-June-2026]}