Skip to content

Matrix Calculator

This matrix calculator adds, subtracts and multiplies matrices. It also finds the transpose, the determinant, the inverse and a scalar multiple, for matrices up to 6 × 6. Enter one row per line.

One row per line. Separate numbers with spaces or commas. Up to 6 × 6.

Used for add, subtract and multiply.

A × B

[ 2  1   7] [ 5  3  12] [16  1   7]

A × B, shown as a grid. The result is 3 × 3.

Size of A
3 × 3
Size of B
3 × 3
Result size
3 × 3
Result as a table
Rowc1c2c3
r1217
r25312
r31617

How to use this calculator

  1. 1 Enter matrix A, one row per line, with the numbers separated by spaces or commas.
  2. 2 For add, subtract or multiply, enter matrix B too. Check that its size fits the operation.
  3. 3 Choose the operation. For a scalar multiple, enter the number k.
  4. 4 Read the result grid, and check the size and the summary below it.

What is a matrix?

A matrix is a rectangular grid of numbers arranged in rows and columns. Its size is written as rows × columns, so a matrix with 2 rows and 3 columns is a 2 × 3 matrix.

Each number is called an entry. The entry in row 1, column 2 is written a₁₂. Matrices are used to store data tables, to solve sets of equations and to describe transformations such as rotating or stretching a shape.

Matrices follow their own rules. For example, A × B usually does not equal B × A, so the order of multiplication matters. For plain distances between two points, the distance calculator is simpler.

How the operations work

To add or subtract two matrices, they must be the same size. You add or subtract the entries in the same position. For example, the entry in row 1, column 1 of A + B is a₁₁ + b₁₁.

To multiply A by B, the number of columns in A must equal the number of rows in B. Each entry of the result is the dot product of a row of A and a column of B. Multiply the pairs, then add the products. The result has the rows of A and the columns of B.

Also, the transpose swaps rows and columns. A scalar multiple multiplies every entry by the same number k. Both keep the size of the matrix, except the transpose, which swaps its rows and columns.

Matrix sizes needed for each operation
OperationSize ruleResult size
A + B or A − BA and B must be the same sizeSame as A
A × BColumns of A = rows of BRows of A × columns of B
Aᵀ (transpose)Any sizeColumns of A × rows of A
k × AAny sizeSame as A
det(A) or A⁻¹A must be squareOne number, or the same size as A

Determinant and inverse

The determinant is a single number that describes a square matrix. For a 2 × 2 matrix [[a, b], [c, d]], it is ad − bc. For larger matrices, it is found by elimination or by expanding along a row. If the determinant is zero, the matrix is singular.

The inverse of A, written A⁻¹, is the matrix that undoes A. For example, it reverses a transformation. Multiplying A by its inverse gives the identity matrix, which has 1s on the diagonal and 0s elsewhere. A singular matrix has no inverse, because the division would be by zero.

For a 2 × 2 matrix, the inverse is (1 ÷ det) multiplied by the matrix [[d, −b], [−c, a]]. The absolute value of the determinant also gives the area scaling of a transformation, which is why it links to the area calculator.

Tips for entering matrices

Most errors come from the layout of the numbers rather than the arithmetic. These checks help:

  • Count the columns in each row. Every row needs the same number of entries.
  • Use the right size for B. For A × B, the columns of A must match the rows of B.
  • Use square matrices for determinants. Determinants and inverses need the same number of rows and columns.
  • Watch for multiples. If one row is a multiple of another, the determinant is zero.
  • Use the determinant to test a system. A non-zero determinant means a 2 × 2 system of linear equations has exactly one solution. For equations with x², try the quadratic formula calculator.

The formula

Matrix product

(AB)ᵢⱼ = Σₖ aᵢₖ × bₖⱼ

i, j
the row and column of the result
k
runs over the columns of A and the rows of B

Determinant of a 2 × 2 matrix

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

det
the determinant, a single number

Inverse of a 2 × 2 matrix

A⁻¹ = (1 ÷ (ad − bc)) × [[d, −b], [−c, a]]

A⁻¹
the inverse, which exists only when ad − bc is not zero

Transpose and scalar multiple

(Aᵀ)ᵢⱼ = aⱼᵢ, (kA)ᵢⱼ = k × aᵢⱼ

k
the scalar, a single number

Worked example

Find the inverse of A = [[2, 1], [1, 3]]

  1. 1.Determinant: 2 × 3 − 1 × 1 = 6 − 1 = 5.
  2. 2.Swap the diagonal entries and change the signs of the others: [[3, −1], [−1, 2]].
  3. 3.Divide every entry by 5: A⁻¹ = [[0.6, −0.2], [−0.2, 0.4]].
  4. 4.Check: A × A⁻¹ = [[1, 0], [0, 1]], the identity matrix.

The inverse of A is [[0.6, −0.2], [−0.2, 0.4]], and the determinant of A is 5.

Frequently asked questions

How do I multiply two matrices?

Multiply each row of the first matrix by each column of the second, pair by pair, then add the products. The number of columns in the first matrix must equal the number of rows in the second.

What does a determinant of zero mean?

It means the matrix is singular. Its rows or columns are linked, so it has no inverse. For a 2 × 2 matrix, a zero determinant means ad = bc.

Why does the calculator say a matrix has no inverse?

An inverse exists only for a square matrix with a non-zero determinant. If the determinant is zero, the division needed for the inverse is impossible.

Is A × B the same as B × A?

Usually not. Matrix multiplication depends on order, so the two products can differ, and one may not even be possible.

What is the largest matrix this calculator accepts?

Up to 6 rows and 6 columns for each matrix. Enter the rows one per line, with every row the same length.

Sources

Last reviewed by the GridCalculators team.