Math
Matrix calculator
Type a matrix one row per line, choose what you want from it, and get the answer with the full working: each row operation of a Gauss–Jordan inverse, the characteristic polynomial behind the eigenvalues, the pivots that give the rank. Integer and fraction entries are kept exact.
One row per line; separate entries with spaces or commas. Fractions such as 1/3 are kept exact.
A whole number; negative powers use the inverse.
Show the working, step by step
Write A next to the identity matrix: [A | I]. Then row-reduce the whole thing until the left half is I. (Where a pivot of 1 or −1 is available the calculator swaps it up, which keeps fractions out of the early steps.)
2−10100−12−10100−12001Pivot in column 1:
R1 ↔ R2,R1 → −R1,R2 → R2 − 2R11−210−1003−21200−12001Pivot in column 2:
R2 ↔ R3,R2 → −R2,R1 → R1 + 2R2,R3 → R3 − 3R210−30−1−201−200−1004123Pivot in column 3:
R3 → R3 ÷ 4,R1 → R1 + 3R3,R2 → R2 + 2R31003/41/21/40101/211/20011/41/23/4The left half is now I, so the right half is A⁻¹.
A⁻¹ =3/41/21/41/211/21/41/23/4
Exact fraction arithmetic.
A worked example: the inverse
The calculator starts with this 3×3 matrix, which turns up in finite-difference methods:
A = [ 2 −1 0 −1 2 −1 0 −1 2 ]
Gauss–Jordan elimination works on [A | I], one column at a time:
- Column 1. Swap R1 and R2 to bring up a pivot of −1, make it 1 with R1 → −R1, then clear below it with R2 → R2 − 2R1. The rows are now [1 −2 1 | 0 −1 0], [0 3 −2 | 1 2 0], [0 −1 2 | 0 0 1].
- Column 2. Swap R2 and R3 for the −1 pivot, then R2 → −R2, R1 → R1 + 2R2 and R3 → R3 − 3R2. The third row becomes [0 0 4 | 1 2 3].
- Column 3. R3 → R3 ÷ 4, then R1 → R1 + 3R3 and R2 → R2 + 2R3 clear the rest of the column.
The left half is now I, and the right half is the inverse:
A⁻¹ = [ 3/4 1/2 1/4 1/2 1 1/2 1/4 1/2 3/4 ] = ¼ [ 3 2 1 ; 2 4 2 ; 1 2 3 ]
The determinant is 4, which is why quarters appear. Multiplying A by this matrix gives I exactly, and the calculator checks that for you.
Eigenvalues of the same matrix
The trace is 6, the three principal 2×2 minors are 3, 4 and 3 (sum 10), and det A = 4, so the characteristic polynomial is
λ³ − 6λ² + 10λ − 4 = 0
λ = 2 is a root (8 − 24 + 20 − 4 = 0). Dividing it out leaves λ² − 4λ + 2 = 0, whose roots are 2 ± √2. So the eigenvalues are 2 + √2 ≈ 3.41421, 2 and 2 − √2 ≈ 0.585786. They add up to the trace (6) and multiply to the determinant (4), which are good checks on any eigenvalue calculation.
For 4×4 and larger there is no practical exact method, so the calculator reduces the matrix to Hessenberg form and runs the shifted QR algorithm. The matrix with rows 1 2 3 4, 5 6 7 8, 2 6 4 8, 3 1 1 2, for example, has eigenvalues of about 15.0282, 1.15397 and the complex pair −1.59107 ± 1.2729i.
What each operation means
| Operation | Needs | What it tells you |
|---|---|---|
| Determinant | Square | The volume scale factor; zero means singular |
| Inverse | Square, det ≠ 0 | The matrix that undoes A, so x = A⁻¹b solves Ax = b |
| RREF | Any size | The simplest equivalent system; read solutions from it |
| Rank | Any size | How many rows (or columns) are independent |
| Trace | Square | Sum of the diagonal, which equals the sum of the eigenvalues |
| Transpose | Any size | Rows and columns swapped; symmetric if Aᵀ = A |
| Eigenvalues | Square | Scale factors along the directions A only stretches |
| Power Aⁿ | Square | Applying A n times, e.g. n steps of a Markov chain |
Things that trip people up
- Rectangular matrices. Only square matrices have a determinant, inverse, trace or eigenvalues. RREF, rank and transpose work for any shape.
- A pivot of zero is not the end. If the diagonal entry is 0, swap in a row below with a non-zero entry in that column. Only when every entry on and below is 0 is the column pivot-free.
- Different row operations, same answer. Your textbook may pick other pivots or order the steps differently. The RREF and the inverse are unique, so the final matrices will match even when the intermediate ones do not.
- Repeated eigenvalues. A repeated root may have fewer independent eigenvectors than its multiplicity. [1 2; 0 1] has λ = 1 twice but only one eigenvector direction, ⟨1, 0⟩.
Common questions
How do you find the inverse of a matrix?
Write the matrix beside the identity, [A | I], and row-reduce until the left half becomes I. The right half is then A⁻¹. If a column runs out of non-zero pivots first, the matrix is singular and has no inverse. For a 2×2 matrix there is a shortcut: swap a and d, change the signs of b and c, and divide by ad − bc.
Which matrices do not have an inverse?
Exactly those with determinant 0, called singular matrices. Equivalent tests: the rank is
less than n, the rows (or columns) are linearly dependent, 0 is an eigenvalue, or Ax = 0 has
a non-zero solution. [1 2; 2 4] is singular because the second row is twice the
first.
What is the rank of a matrix?
The number of pivots (leading 1s) in its reduced row echelon form, which equals the number of linearly independent rows and also the number of independent columns. The 3×3 matrix with rows 1 2 3, 4 5 6, 7 8 9 has rank 2: its RREF has rows 1 0 −1, 0 1 2 and a row of zeros.
How are eigenvalues calculated?
Eigenvalues are the roots of the characteristic polynomial det(A − λI) = 0. For a 2×2 matrix that is λ² − (trace)λ + det = 0, and for a 3×3 it is λ³ − (trace)λ² + (sum of the principal 2×2 minors)λ − det = 0. This calculator solves those exactly. For 4×4 and larger it uses the QR algorithm, a numerical method, and says so in the result.
Why does the calculator show fractions instead of decimals?
When every entry is an integer or a fraction such as 2/3, all the arithmetic is done in exact fractions, so an inverse shows 1/3 rather than 0.333333 and nothing is lost to rounding. Type a decimal anywhere in the matrix and it switches to floating point, shown to six significant figures.
Is A² the same as squaring every entry?
No. A² means A × A, matrix multiplication, where each entry is a row of A dotted with a column of A. For the default matrix the top-left entry of A² is 2×2 + (−1)×(−1) + 0×0 = 5, not 2² = 4. Only diagonal matrices can be powered entry by entry.
Related calculators
-
Determinant calculator
Cofactor expansion, Sarrus and row reduction, step by step.
-
Matrix operations
A + B, AB, BA, kA and solving AX = B.
-
Vector analysis
Linear independence, triple products and Gram–Schmidt.
-
Vector calculator
Dot and cross products, angles and projections.