Calculator Tools

Matrix Calculator

Add, subtract, and multiply matrices, or find a determinant, inverse, rank, transpose, or row reduced form. Choose an operation, type your matrices, and see the answer with every step.

Enter your matrices

The number of columns in A must equal the number of rows in B.

Matrix A
Matrix B
Show results as

Try an example

Result

A×B=[52556871]

Calculated with exact fractions, so nothing is rounded.

Step-by-step solution
  1. Check the sizes

    A is 2 × 2 and B is 2 × 2. The inner sizes match (2), so the product is 2 × 2.

  2. Multiply rows by columns

    Each entry is a row of the first matrix times a column of the second. The entry in row 1, column 1 is 3·8 + 7·4 = 52.

    A × B=[3⋅8+7⋅43⋅2+7⋅74⋅8+9⋅44⋅2+9⋅7]

    =[52556871]

What is a matrix?

A matrix is a rectangular grid of numbers arranged in rows and columns. A matrix with m rows and n columns is an m × n matrix, and aᵢⱼ means the entry in row i and column j. Matrices describe linear transformations such as rotations and scalings, store data, and let you solve many linear equations at once. This free matrix calculator adds, subtracts, and multiplies matrices, and finds the transpose, determinant, inverse, rank, trace, powers, and reduced row echelon form. It shows the steps, uses exact fractions, and checks determinants and inverses with a second method.

How to use the matrix calculator

  1. Choose an operation. Pick addition, multiplication, determinant, inverse, or another operation. The hint under the menu tells you what size the matrices need.
  2. Set the size. Use the Rows and Columns menus for each matrix, from 1 × 1 up to 6 × 6.
  3. Type the entries. Use whole numbers, decimals, or fractions such as 1/2. Press the up and down arrow keys to move between rows.
  4. Add a number if asked. The power and the multiply-by-a-number operations need one extra value.
  5. Read the result. You get the answer, a step-by-step solution, and a check where one applies. Switch to decimals if you prefer them to fractions.

Matrix operations at a glance

OperationWhat it does and what it needs
Add: A + BAdds matching entries. A and B must be the same size.
Subtract: A − BSubtracts matching entries. A and B must be the same size.
Multiply: A × BThe number of columns in A must equal the number of rows in B.
Transpose: AᵀSwaps the rows and columns of A.
Determinant: det(A)A must be square (same number of rows and columns).
Inverse: A⁻¹A must be square, and its determinant must not be 0.
Rank of ACounts the independent rows of A.
Trace: tr(A)Adds the diagonal entries. A must be square.
Row reduce (RREF)Gauss-Jordan elimination to reduced row echelon form.
Power: AⁿA must be square. The power n is a whole number from 0 to 10.
Multiply by a number: k·AMultiplies every entry of A by the number k.

Worked examples

These results come straight from the calculator, so you can compare them with your own work.

Add matrices

With A = [[3, 7], [4, 9]] and B = [[8, 2], [4, 7]], add the entries in the same position: 3 + 8, 7 + 2, 4 + 4, and 9 + 7.

A+B=[119816]

Subtract matrices

Subtract the entries in the same position instead: 3 − 8, 7 − 2, 4 − 4, and 9 − 7.

A−B=[−5502]

Multiply matrices

Each entry is a row of A times a column of B. The top-left entry is 3·8 + 7·4 = 52.

A×B=[52556871]

Transpose a matrix

Swap rows and columns. A 2 × 3 matrix [[1, 2, 3], [4, 5, 6]] becomes a 3 × 2 matrix.

AT=[142536]

Determinant of a 2 × 2 matrix

For A = [[3, 7], [4, 9]] the determinant is a·d − b·c = 3·9 − 7·4 = −1.

det(A)=−1

Inverse of a 2 × 2 matrix

Because the determinant is −1 and not 0, A has an inverse: (1/det) times [[d, −b], [−c, a]].

A−1=[−974−3]

Rank of a singular matrix

The rows of [[1, 2, 3], [4, 5, 6], [7, 8, 9]] are not independent: the third row is twice the second minus the first. Row reduction leaves two nonzero rows.

rank(A)=2

Solve a system by row reduction

Row reducing an augmented matrix solves the system. Here the last column holds the right-hand sides, and the left side becomes the identity.

rref(A)=[100−80101001−2]

Row operations, rank, and the inverse

Three row operations never change the solutions of a linear system: swap two rows, multiply a row by a number that is not 0, and add a multiple of one row to another. Gauss-Jordan elimination uses them to turn a matrix into reduced row echelon form, where each pivot is 1 and is the only nonzero entry in its column. The number of pivots is the rank. To find an inverse, the calculator writes A next to the identity matrix and row reduces: when the left side becomes the identity, the right side is A⁻¹. If a column has no pivot, A is singular and has no inverse.

Rules for matrix operations

Addition is commutative
A + B = B + A
Multiplication is not commutative
A × B ≠ B × A in general
Multiplication is associative
(A × B) × C = A × (B × C)
Transpose of a product
(A × B)ᵀ = Bᵀ × Aᵀ
Determinant of a product
det(A × B) = det(A) · det(B)
Inverse of a product
(A × B)⁻¹ = B⁻¹ × A⁻¹
Identity matrix
A × I = I × A = A

What this calculator can and cannot do

  • Matrices from 1 × 1 up to 6 × 6 with whole-number, decimal, or fraction entries.
  • Exact fractions throughout, so there is no rounding error. Very large numbers are reported instead of being rounded.
  • Powers from 0 to 10 and any rational scalar multiple.

It does not find eigenvalues, eigenvectors, or LU, QR, and other decompositions, and it does not accept symbols, variables, or complex numbers as entries.

Tips for working with matrices

  • Check the sizes first. For A × B, the columns of A must equal the rows of B.
  • Do not swap the order in a product. A × B and B × A usually differ.
  • A determinant of 0 means there is no inverse and the rank is less than the size.
  • Multiply A by its inverse as a quick self-check. You should get the identity matrix.
  • To clear a matrix quickly, press Clear and type the new entries.

Matrix terms explained

Square matrix
A matrix with the same number of rows and columns. Determinants, inverses, traces, and powers need one.
Identity matrix
A square matrix with 1 on the main diagonal and 0 elsewhere. It acts like the number 1 in multiplication.
Zero matrix
A matrix whose entries are all 0.
Diagonal matrix
A square matrix whose entries are 0 everywhere except on the main diagonal.
Symmetric matrix
A square matrix that equals its own transpose, so aᵢⱼ = aⱼᵢ.
Singular matrix
A square matrix with determinant 0. It has no inverse.
Pivot
The first nonzero entry in a row after row reduction. The number of pivots is the rank.
Trace
The sum of the entries on the main diagonal of a square matrix.

Related calculators

Working through calculus too? Try the derivative calculator, the integral calculator, or thelimit calculator.

Frequently asked questions

What is a matrix?

A matrix is a rectangular grid of numbers arranged in rows and columns. A matrix with m rows and n columns is called an m × n matrix, and the entry in row i, column j is written aᵢⱼ. Matrices are used to describe linear transformations and to solve systems of linear equations.

How do I add or subtract matrices?

Both matrices must be exactly the same size. Add or subtract the entries that sit in the same position. For example, adding [[3, 7], [4, 9]] and [[8, 2], [4, 7]] gives [[11, 9], [8, 16]].

How do I multiply two matrices?

The number of columns in the first matrix must equal the number of rows in the second. Each entry of the product is the sum of products of one row of the first matrix with one column of the second. An m × p matrix times a p × n matrix gives an m × n matrix.

Is A × B the same as B × A?

Not usually. Matrix multiplication is not commutative, so A × B and B × A can be different, and one of them may not even exist if the sizes do not match. It is associative, so (A × B) × C equals A × (B × C).

How do I find the determinant of a matrix?

The determinant is defined only for square matrices. For a 2 × 2 matrix [[a, b], [c, d]] it is a·d − b·c. For larger matrices you can expand along a row or reduce the matrix to triangular form and multiply the diagonal, keeping track of row swaps. The calculator uses the second method for the steps and checks the result with cofactor expansion.

When does a matrix have an inverse?

A square matrix has an inverse exactly when its determinant is not 0. Such a matrix is called invertible or non-singular. If the determinant is 0 the matrix is singular and has no inverse. The inverse A⁻¹ satisfies A × A⁻¹ = I, where I is the identity matrix.

What is the rank of a matrix?

The rank is the number of independent rows (or columns). You find it by row reducing the matrix and counting the nonzero rows, which is the same as counting the pivots. A square n × n matrix is invertible exactly when its rank is n.

What is the transpose of a matrix?

The transpose Aᵀ swaps the rows and columns of A. The first row becomes the first column, the second row becomes the second column, and so on. An m × n matrix becomes an n × m matrix.

What sizes and numbers does the calculator support?

Matrices can be from 1 × 1 up to 6 × 6. Entries can be whole numbers, decimals, or fractions such as 1/2, and the calculator works with exact fractions, so nothing is rounded along the way. Entries must be numbers, not symbols or variables.

Does the calculator show the steps?

Yes. For addition and multiplication it shows each entry before it is simplified. For determinants, inverses, rank, and row reduction it lists every row operation with the matrix after each one. Determinants and inverses are also checked automatically with a second method.

Can it find eigenvalues, or LU and QR decompositions?

Not yet. This calculator covers addition, subtraction, multiplication, scalar multiples, powers, transpose, determinant, inverse, rank, trace, and reduced row echelon form. Eigenvalues, eigenvectors, and matrix decompositions are not included.