Matrix Calculator

About this calculator

The Matrix Calculator works with two matrices, A and B, of any size up to 10 × 10. Add, subtract or multiply them, or apply a single-matrix operation: transpose, determinant, inverse, rank, reduced row echelon form, a whole-number power, or multiplication by a scalar.

Choose the size with the row and column menus, type the entries (fractions such as 1/3 are accepted), and click an operation. Results are shown as a grid rounded to 10 significant digits.

Matrix A

×

Matrix B

×
Embed this calculator

Paste this code into a Custom HTML block on your site. The calculator fits the width of the block. Adjust the height in the code if you want more room for results.

Find this widget in the publisher directory

Matrix addition and subtraction

Two matrices can be added or subtracted only when they have the same number of rows and the same number of columns. The operation is done entry by entry: the entry in row i, column j of A + B is aij + bij.

[1 2; 3 4] + [5 6; 7 8] = [6 8; 10 12]

Matrix multiplication

Scalar multiplication

Multiplying a matrix by a single number (a scalar) multiplies every entry by that number. 3 × [1 2; 3 4] = [3 6; 9 12].

Multiplying two matrices

The product AB exists when the number of columns of A equals the number of rows of B. If A is m × n and B is n × p, then AB is m × p, and each entry is the dot product of a row of A with a column of B:

(AB)ij = ai1b1j + ai2b2j + ... + ainbnj

Example: [1 2; 3 4] × [5 6; 7 8] = [1·5 + 2·7, 1·6 + 2·8; 3·5 + 4·7, 3·6 + 4·8] = [19 22; 43 50]. Matrix multiplication is not commutative: in general AB and BA are different, and one may exist while the other does not.

Power of a matrix

An means A multiplied by itself n times, which requires a square matrix. A0 is the identity matrix, and a negative power such as A−2 is the inverse squared, so it exists only when A is invertible. The calculator uses repeated squaring, so even A100 takes only a handful of multiplications.

Transpose of a matrix

The transpose AT flips a matrix over its main diagonal, turning rows into columns. An m × n matrix becomes n × m. For example the transpose of [1 2 3; 4 5 6] is [1 4; 2 5; 3 6].

Determinant of a matrix

The determinant is a single number defined for square matrices. It tells you whether the matrix is invertible (the determinant is not zero) and how much the matrix scales area or volume.

2 × 2 determinant

det [a b; c d] = ad − bc

det [1 2; 3 4] = 1·4 − 2·3 = −2.

3 × 3 determinant

Expand along the first row, multiplying each entry by the determinant of the 2 × 2 matrix left after deleting its row and column, with alternating signs:

det A = a(ei − fh) − b(di − fg) + c(dh − eg)

For the default matrix A = [1 2 3; 4 5 6; 7 8 10]: 1(50 − 48) − 2(40 − 42) + 3(32 − 35) = 2 + 4 − 9 = −3.

4 × 4 and larger

Cofactor expansion grows very quickly with size, so the calculator instead reduces the matrix to triangular form with Gaussian elimination (using partial pivoting for accuracy). The determinant is then the product of the diagonal entries, with the sign flipped once for every row swap.

Inverse of a matrix

The inverse A−1 is the matrix that satisfies A × A−1 = A−1 × A = I, where I is the identity matrix: ones on the main diagonal and zeros elsewhere. Only square matrices with a nonzero determinant have an inverse.

2 × 2 inverse

[a b; c d]−1 = (1 / (ad − bc)) × [d −b; −c a]

So [1 2; 3 4]−1 = (1 / −2) × [4 −2; −3 1] = [−2 1; 1.5 −0.5].

3 × 3 and larger

Write A next to the identity matrix, [A | I], and apply row operations until the left side becomes I. The right side is then A−1. This Gauss-Jordan method is what the calculator uses for every size.

Rank and reduced row echelon form

Reduced row echelon form (RREF) is the result of Gauss-Jordan elimination: each nonzero row starts with a leading 1, each leading 1 is to the right of the one above it, and every other entry in a leading 1's column is zero. RREF is the standard way to solve a system of linear equations: enter the augmented matrix and read the solution from the last column. The rank is the number of nonzero rows in the RREF, which equals the number of linearly independent rows (or columns). A square n × n matrix is invertible exactly when its rank is n.

Rounding

Calculations use double-precision floating point and results are displayed to 10 significant digits, with values smaller than 10−10 shown as 0. That hides round-off such as 0.9999999999 appearing instead of 1. Use "Copy to A" or "Copy to B" under a result to keep working with it.

Frequently asked questions

How do I find the inverse of a matrix?
Enter a square matrix as A or B and click Inverse. If the determinant is zero the matrix is singular and has no inverse, and the calculator tells you so.
Why can't I multiply my two matrices?
A × B requires the number of columns in A to equal the number of rows in B. A 2 × 3 matrix can multiply a 3 × 4 matrix (giving 2 × 4), but not a 2 × 3 matrix.
What is the determinant used for?
A determinant of zero means the matrix is not invertible and its rows are linearly dependent. Its absolute value is the factor by which the matrix scales area (2 × 2) or volume (3 × 3).
Can I enter fractions?
Yes. Type entries such as 1/3 or -5/2. Results are shown as decimals rounded to 10 significant digits.
What is the largest matrix supported?
Each matrix can be up to 10 rows by 10 columns, and the two matrices can have different sizes.

Formulas and sample results on this page were checked against independent references. Page last reviewed or updated . How we verify calculators. Project led by Shaun Connell.