Matrix Calculator

Enter one or two matrices and add, subtract, multiply, transpose, invert, raise to a power or find the determinant, with exact fraction answers.

Matrix A

×
Power of
Multiply by

Matrix B

×
Power of
Multiply by
Quick answer. Multiply, add or invert matrices up to 10 by 10 with exact fractions. For A = [1 2; 3 4] and B = [5 6; 7 8], AB = [19 22; 43 50] and BA = [23 34; 31 46]. The determinant of A is −2.

How to use the calculator

Set the number of rows and columns for each matrix (up to 10 × 10), type the numbers into the boxes, then press an operation. The buttons under each matrix work on that matrix alone: transpose, determinant, inverse, rank, trace and reduced row echelon form (RREF), plus raising it to a power or multiplying every entry by a number. The buttons in the middle combine the two matrices. Entries can be whole numbers, decimals or fractions such as 1/3, and the answers are worked out exactly, so you never see a rounding error where a clean fraction exists. A switch shows the answers as fractions or as decimals.

Worked example with the default matrices

The page opens with A = [1 2; 3 4] and B = [5 6; 7 8] and shows the product A × B. The top-left entry is 1×5 + 2×7 = 19, the top-right is 1×6 + 2×8 = 22, and so on, giving AB = [19 22; 43 50]. Order matters: BA = [23 34; 31 46], a different matrix, so always check which one you need.

Adding, subtracting and multiplying

You can only add or subtract matrices of the same size, and you do it entry by entry. For the defaults, A + B = [6 8; 10 12] and A − B = [-4 -4; -4 -4]. Multiplication is different: A × B needs the number of columns of A to equal the number of rows of B, and each entry of the answer is a row of A multiplied term by term with a column of B and added up. If the sizes do not fit, the calculator tells you the sizes and what is needed.

Multiplications needed to multiply two n by n matrices (n cubed)Each entry of the product needs n multiplications and there are n² entries, so the work grows with n cubed. The largest size the tool takes, 10 by 10, needs 1,000.Multiplications needed to multiply two n by n matrices (n cubed)2 × 283 × 3275 × 512510 × 101,000
Multiplication gets expensive quickly.

Transpose, scalar multiple and power

The transpose swaps rows and columns: AT = [1 3; 2 4]. Multiplying by a number multiplies every entry, so 2A = [2 4; 6 8]. Raising a square matrix to a power multiplies it by itself, so A² = [7 10; 15 22], and a negative power uses the inverse.

Determinant and inverse

The determinant is a single number that tells you a lot about a square matrix. For a 2 × 2 matrix [a b; c d] it is ad − bc, so for A it is (1)(4) − (2)(3) = −2. A matrix has an inverse only when its determinant is not zero. For C = [4 7; 2 6] the determinant is 10, and the inverse is [3/5 -7/10; -1/5 2/5]. Multiplying the two gives the identity matrix. If the determinant is zero the matrix is singular and there is no inverse, and the calculator says so. For A the inverse is [-2 1; 3/2 -1/2].

A 3 by 3 example

For 2 × 2 and 3 × 3 matrices the calculator also writes out the working. Take M = [2 0 1; 1 3 2; 1 1 4]. The determinant is a(ei − fh) − b(di − fg) + c(dh − eg) = 2(12 − 2) − 0 + 1(1 − 3) = 20 − 2 = 18. It is not zero, so M has an inverse, and M × M−1 is the 3 × 3 identity. For matrices larger than 3 × 3 the determinant is found by row reduction.

Solving a system of equations with the inverse

A pair of equations such as 4x + 7y = 15 and 2x + 6y = 10 can be written as A·v = b with A = [4 7; 2 6] and b = [15; 10]. Multiply both sides by the inverse and v = A−1b. Using the inverse of C above gives x = (3/5)(15) − (7/10)(10) = 2 and y = (−1/5)(15) + (2/5)(10) = 1. You can check it: 4(2) + 7(1) = 15 and 2(2) + 6(1) = 10. Put b in as a second matrix B with one column and multiply A−1 by it.

Reduced row echelon form

RREF is what you reach by row reduction. Put the same system in as an augmented matrix [4 7 15; 2 6 10] and press RREF to get [1 0 2; 0 1 1]. Reading the last column gives x = 2 and y = 1. RREF also shows whether a system has one solution, none or many.

Rank and trace

The rank counts how many rows are truly independent. [1 2; 2 4] has rank 1, because the second row is just twice the first, and its determinant is 0. The trace is the sum of the diagonal entries, so tr(A) = 1 + 4 = 5.

A famous power

Raise [1 1; 1 0] to the 10th power and you get [89 55; 55 34]. Those entries are Fibonacci numbers, which you can explore in the Number Sequence Calculator.

Top-right entry of [1 1; 1 0] raised to the power n (Fibonacci numbers)Raising [1 1; 1 0] to the 10th power gives [89 55; 55 34], and the entries are Fibonacci numbers, which grow by about 1.6 times each step.Top-right entry of [1 1; 1 0] raised to the power n (Fibonacci numbers)0153045591471010Power nEntry
Matrix powers can generate the Fibonacci numbers.

Rules you can check with the calculator

  • Determinant of a product. det(AB) = det(A) × det(B). For the defaults, 19×50 − 22×43 = 4, and (−2)(−2) = 4.
  • Transpose of a product. (AB)T = BTAT, so both sides give [19 43; 22 50]. Note the order reverses.
  • Inverse of a product. (AB)−1 = B−1A−1, so both sides give [25/2 -11/2; -43/4 19/4].
  • The identity matrix. I has ones on the diagonal and zeros elsewhere, and A × I = I × A = A. The Clear, All 0, All 1 and Random buttons set up a matrix quickly.

Try each rule on your own matrices. If both sides agree, you can trust that the entries were typed correctly, and if they do not, look for a typo.

Where matrices turn up

  • Graphics. Rotations, scaling and projections in computer graphics are matrices.
  • Probability. The transitions in a Markov model are a matrix, and its powers show long-run behaviour.
  • Networks. A table of connections between nodes is a matrix.
  • Statistics. Data tables and regressions are solved with matrices.
  • Geometry. The determinant of [3 0; 1 2] is 6, the signed area of the parallelogram its rows describe, so half of it is the area of a triangle.

Common mistakes

  • Assuming AB = BA. Matrix multiplication is not commutative.
  • Trying to invert a non-square matrix, or one with a zero determinant.
  • Adding matrices of different sizes.
  • Mixing up rows and columns when you set the size.
  • Typing a space in a fraction like 1 / 3. Use 1/3.

How to read your result

The result appears under the buttons with a title that says what was done, for example “A + B” or “Determinant of A”. Fractions are exact by default. Switch to decimals for values rounded to six places. A quick check on any inverse: multiply the matrix by its inverse. If you do not get the identity matrix, there is a typo in one of the entries.

Answers are exact when entries are whole numbers, decimals or fractions. Matrices larger than 10 by 10 are not supported.

What to do next

Common questions

How do you multiply two matrices?

Multiply each row of the first matrix by each column of the second, adding the products. This works only when the number of columns of the first equals the number of rows of the second.

When does a matrix have an inverse?

Only when it is square and its determinant is not zero. A matrix with a zero determinant is called singular.

What is the determinant of a 2x2 matrix?

For [a b; c d] it is ad minus bc. For [1 2; 3 4] that is 1 times 4 minus 2 times 3, which is minus 2.

What does the rank of a matrix mean?

It is the number of linearly independent rows or columns, which is also the number of pivots in the reduced row echelon form.

Can I use fractions and decimals?

Yes. Type entries as whole numbers, decimals or fractions like 3/4. The calculator works exactly and can show the answers as fractions or as decimals.

Why is AB different from BA?

Matrix multiplication is not commutative. Each entry of AB comes from rows of A and columns of B, which gives a different result from rows of B and columns of A.

Sources: Wikipedia: Matrix (mathematics); Wikipedia: Determinant; Wikipedia: Invertible matrix; Wikipedia: Row echelon form

More Math Calculators

Pick another tool to jump straight to it.