Skip to content
  • Open the math solver
  • Ask the AI tutor
  • Find an AP course
  • Create a quiz
  • Open the calculator
  • Graphing Calculator
  • Browse all calculators
  • Read math guides
↑ ↓Enter to open · Esc to close
Solve a problem

Matrix Calculator

Multiply, add or subtract matrices, scale or raise one to a power, transpose it, row reduce it to RREF, or find its rank and trace, with exact fractions and every step.

One row per line (or separate rows with ;). Separate entries with spaces or commas. Fractions like 1/2 and decimals are fine.

One row per line (or separate rows with ;). Separate entries with spaces or commas. Fractions like 1/2 and decimals are fine.

Examples

About the Matrix Calculator

Matrices store numbers in rows and columns, and they are the language of linear algebra, computer graphics, economics models, statistics and machine learning. The operations themselves are simple, but they involve many small multiplications and additions, and a single slip in one entry spoils the whole answer.

This calculator performs nine matrix operations: multiplication, addition, subtraction, scalar multiplication, whole-number powers, transpose, reduced row echelon form, rank and trace. Entries can be integers, decimals or fractions, and all arithmetic is exact, so a result such as 32\frac32 is shown as a fraction rather than a rounded decimal. Row reduction lists each row operation in order.

What is a matrix?

A matrix is a rectangular array of numbers with mm rows and nn columns, called an m×nm \times n matrix. The entry in row ii and column jj is written aija_{ij}. A square matrix has the same number of rows and columns, and the identity matrix II has ones on its main diagonal and zeros elsewhere.

Matrices represent linear maps and systems of linear equations. Multiplying a matrix by a vector applies a transformation such as a rotation or a scaling, and multiplying two matrices composes two transformations into one.

How to use the Matrix Calculator

  1. Choose an operation from the list.
  2. Enter matrix A with spaces between entries and semicolons between rows, for example 1 2; 3 4.
  3. For multiply, add and subtract, enter matrix B in the same format.
  4. For scalar multiplication or powers, enter the number kk.
  5. Press Calculate and follow the steps to the result.

Formulas

Matrix product entry

(AB)ij=∑k=1naik bkj(AB)_{ij} = \sum_{k=1}^{n} a_{ik}\,b_{kj}

Sum

(A+B)ij=aij+bij(A + B)_{ij} = a_{ij} + b_{ij}

Transpose

(AT)ij=aji(A^{T})_{ij} = a_{ji}

Trace

tr⁡(A)=∑iaii\operatorname{tr}(A) = \sum_{i} a_{ii}

Worked example: A × B (2×2)

The example multiplies A=(1234)A = \begin{pmatrix}1 & 2\\3 & 4\end{pmatrix} by B=(5678)B = \begin{pmatrix}5 & 6\\7 & 8\end{pmatrix}. Each entry of the product is a row of AA dotted with a column of BB; the top-left entry is 1⋅5+2⋅7=191 \cdot 5 + 2 \cdot 7 = 19.

Repeating for the other three positions gives (19224350)\begin{pmatrix}19 & 22\\43 & 50\end{pmatrix}. Swapping the order produces (23343146)\begin{pmatrix}23 & 34\\31 & 46\end{pmatrix}, a different matrix, which shows that matrix multiplication is not commutative.

The solution below is generated by the same engine that powers the calculator above.

Final answer

[19224350]\begin{bmatrix}19 & 22 \\ 43 & 50\end{bmatrix}

How we read your problem

Compute A × B exactly.

Step-by-step solution

  1. Read matrix A

    A=[1234] (2×2)A = \begin{bmatrix}1 & 2 \\ 3 & 4\end{bmatrix}\ (2×2)
  2. Read matrix B

    B=[5678] (2×2)B = \begin{bmatrix}5 & 6 \\ 7 & 8\end{bmatrix}\ (2×2)
  3. Each entry is a row of A dotted with a column of B

    The result is 2×2.

    c11=(1)(5)+(2)(7)=19c_{11} = (1)(5) + (2)(7) = 19
  4. Result

    [19224350]\begin{bmatrix}19 & 22 \\ 43 & 50\end{bmatrix}

Formulas used

  • Matrix product

    cij=∑kaikbkjc_{ij} = \sum_k a_{ik} b_{kj}

A is 2×2 and B is 2×2, so AB is 2×2. Matrix multiplication is not commutative: BA is generally different.

Verification

  • All arithmetic is exact (fractions, no rounding).

Detailed explanation

When operations are defined

Addition and subtraction need matrices of exactly the same size and work entry by entry. Multiplication ABAB needs the number of columns of AA to equal the number of rows of BB; an m×nm \times n matrix times an n×pn \times p matrix gives an m×pm \times p result. A 2×32 \times 3 matrix cannot multiply a 2×22 \times 2 matrix, and the calculator explains the size mismatch rather than returning an error code.

Powers are defined only for square matrices, because A⋅AA \cdot A needs matching sizes. Raising (1110)\begin{pmatrix}1 & 1\\1 & 0\end{pmatrix} to the fifth power gives (8553)\begin{pmatrix}8 & 5\\5 & 3\end{pmatrix}, whose entries are Fibonacci numbers.

Row reduction and rank

Reduced row echelon form (RREF) is obtained with three row operations: swapping two rows, multiplying a row by a nonzero number and adding a multiple of one row to another. The goal is a leading 1 in each nonzero row, with zeros above and below it. RREF is the standard way to solve linear systems, find a basis and test independence.

The rank is the number of nonzero rows in the RREF, which equals the number of linearly independent rows or columns. The matrix (123456789)\begin{pmatrix}1 & 2 & 3\\4 & 5 & 6\\7 & 8 & 9\end{pmatrix} reduces to a form with a zero row, so its rank is 2: the third row is a combination of the first two.

Transpose and trace

The transpose flips a matrix across its main diagonal, turning rows into columns. It appears in dot products, least-squares fitting and the definition of symmetric matrices, which equal their own transpose. The trace adds the diagonal entries of a square matrix; it equals the sum of the eigenvalues, which makes it a quick check on eigenvalue calculations.

Common mistakes

  • Multiplying matrices entry by entry instead of rows by columns.
  • Assuming AB=BAAB = BA; the order of factors matters.
  • Trying to add matrices of different sizes.
  • Reading the product size wrongly; an m×nm \times n times n×pn \times p product is m×pm \times p.
  • Changing a row by multiplying it by zero during row reduction, which loses information.

Tips

  • Write the sizes next to each matrix before multiplying to confirm the product exists.
  • Use fractions rather than rounded decimals to keep row reduction exact.
  • Check a product by computing one entry by hand.
  • Use the determinant calculator to test whether a square matrix is invertible.
  • Use the systems of equations calculator when your matrix comes from a linear system.

Frequently asked questions

How do I enter a matrix?

Separate entries in a row with spaces or commas and separate rows with semicolons. For example, 1 2; 3 4 is the 2×2 matrix with rows (1, 2) and (3, 4).

Why is matrix multiplication not commutative?

AB combines rows of A with columns of B, while BA combines rows of B with columns of A. These are different calculations, so the results usually differ, and one product may exist while the other does not.

When can two matrices be multiplied?

When the number of columns of the first equals the number of rows of the second. The product has the row count of the first and the column count of the second.

What is reduced row echelon form?

A form in which each nonzero row starts with a leading 1, each leading 1 is to the right of the one above, and every other entry in a leading 1's column is zero.

What does the rank of a matrix tell me?

The number of linearly independent rows or columns. For a square matrix, full rank means the matrix is invertible and the related linear system has a unique solution.

Can I use fractions in the matrix?

Yes. Entries such as 1/2 are accepted, and all results are computed with exact fractions.

What is the trace of a matrix?

The sum of the entries on the main diagonal of a square matrix. It also equals the sum of the matrix's eigenvalues.

Run your matrix operation

Enter your matrices above to multiply, reduce or analyse them with exact fractions and every step shown.

More math calculators