Linear Algebra

Matrix Calculator

This matrix calculator online multiplies, adds and subtracts matrices up to 6 × 6 and finds the determinant, inverse, transpose, powers and trace, with steps in exact fractions.

Try
Matrix A

Type whole numbers, decimals or fractions such as 3/4. Choose the size above the grid, or paste a block copied from a spreadsheet. Entries must be numbers, not letters.

Matrix B

Result

A × B: [[-9, 7], [18, -12]]

A × B

AB=[−9718−12]AB = \begin{bmatrix} -9 & 7 \\ 18 & -12 \end{bmatrix}

[[-9, 7], [18, -12]]

Size of the result
2 × 2
Size rule
(2 × 3)(3 × 2) → 2 × 2
Determinant of the result
−18-18
Trace of the result
−21-21

A (2 × 3) times B (3 × 2) gives a 2 × 2 matrix. Each entry is a row of A times a column of B; for example, entry (1, 1) is −9.

Step-by-step working (6 steps)
  1. Check the sizes

    A is 2 × 3 and B is 3 × 2. The inner sizes match (3 = 3), so the product exists and has the outer sizes, 2 × 2.

    (2×3)(3×2)→2×2(2 \times 3)(3 \times 2) \to 2 \times 2
  2. Entry (1, 1): row 1 of A times column 1 of B

    Multiply matching entries of the row and the column, then add the products.

    c11=2⋅1+(−1)⋅5+3⋅(−2)=−9c_{11} = 2 \cdot 1 + \left(-1\right) \cdot 5 + 3 \cdot \left(-2\right) = -9
  3. Entry (1, 2): row 1 of A times column 2 of B

    c12=2⋅2+(−1)⋅(−3)+3⋅0=7c_{12} = 2 \cdot 2 + \left(-1\right) \cdot \left(-3\right) + 3 \cdot 0 = 7
  4. Entry (2, 1): row 2 of A times column 1 of B

    c21=0⋅1+4⋅5+1⋅(−2)=18c_{21} = 0 \cdot 1 + 4 \cdot 5 + 1 \cdot \left(-2\right) = 18
  5. Entry (2, 2): row 2 of A times column 2 of B

    c22=0⋅2+4⋅(−3)+1⋅0=−12c_{22} = 0 \cdot 2 + 4 \cdot \left(-3\right) + 1 \cdot 0 = -12
  6. Result

    AB=[−9718−12]AB = \begin{bmatrix} -9 & 7 \\ 18 & -12 \end{bmatrix}
By Hira Noor, mathematicianLast reviewed Free, no sign-up, runs in your browserReport a problem

How to use this calculator

  1. Choose the operation. Fields for B, the scalar k or the exponent n appear only when the operation needs them.
  2. Set the number of rows and columns of each matrix with the size menus, then type the entries. Use the arrow keys or Enter to move between cells.
  3. Enter whole numbers, decimals such as 0.25 or fractions such as −3/4. To paste from a spreadsheet, copy a block of cells and paste it into the top-left cell.
  4. Read the result matrix, its size and the size rule, then open the steps to see each entry, row operation or diagonal sum worked out.

Formulas

Matrix product (row by column)

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

Plain-text formula: (AB)_(ij) = ∑_{k = 1}^n a_(ik)b_(kj)

aika_{ik}
entry in row i, column k of A
bkjb_{kj}
entry in row k, column j of B
nn
number of columns of A, which must equal the number of rows of B

Entry (i, j) of AB is row i of A times column j of B: multiply matching entries and add. An m × n matrix times an n × p matrix gives an m × p matrix, so the inner sizes must agree.

Sum, difference and scalar multiple

(A±B)ij=aij±bij,(kA)ij=kaij(A \pm B)_{ij} = a_{ij} \pm b_{ij}, \qquad (kA)_{ij} = k\, a_{ij}

Plain-text formula: (A ± B)_(ij) = a_(ij) ± b_(ij), (kA)_(ij) = k a_(ij)

Addition and subtraction work entry by entry and need two matrices of the same size. A scalar multiplies every entry.

Transpose and trace

(AT)ij=aji,tr(A)=a11+a22+⋯+ann(A^{T})_{ij} = a_{ji}, \qquad \operatorname{tr}(A) = a_{11} + a_{22} + \cdots + a_{nn}

Plain-text formula: (A^T)_(ij) = a_(ji), tr(A) = a_11 + a_22 + ⋯ + a_(nn)

The transpose swaps rows and columns. The trace of a square matrix is the sum of its diagonal entries.

Determinant and inverse

det⁡[abcd]=ad−bc,AA−1=A−1A=I\det\begin{bmatrix} a & b \\ c & d \end{bmatrix} = ad - bc, \qquad A A^{-1} = A^{-1} A = I

Plain-text formula: det [a, b; c, d] = ad − bc, AA^(−1) = A^(−1)A = I

The determinant of a square matrix is a single number; for larger matrices the calculator finds it by row reduction. The inverse exists exactly when det A ≠ 0, and the calculator finds it by Gauss–Jordan elimination.

Integer powers

An=A⋅A⋯A;(n factors),A0=I,A−n=(A−1)nA^{n} = A \cdot A \cdots A ;(n \text{ factors}), \quad A^{0} = I, \quad A^{-n} = \left(A^{-1}\right)^{n}

Plain-text formula: A^n = A · A⋯A;(n factors), A^0 = I, A^(−n) = (A^(−1))^n

Powers exist only for square matrices. Large powers are found by repeated squaring. Negative powers need the inverse, so they are undefined when det A = 0.

Reading the result

The size rule is the first thing to check. For a product, write the sizes side by side, (m × n)(n × p): the inner numbers must match and the outer numbers give the size of the result. A 2 × 3 matrix times a 3 × 2 matrix is 2 × 2, while the reverse order gives a 3 × 3 matrix.

Order matters in multiplication. In general AB ≠ BA, even when both products exist, so the calculator tells you whether your two square matrices happen to commute. Addition, by contrast, is commutative: A + B = B + A.

Results are exact. When an entry is a fraction, the decimal table underneath gives the same matrix to 10 significant digits for use in other software.

How to multiply matrices

1. Check the sizes. Write them side by side, (m × n)(n × p). The two inner numbers must be equal; the outer numbers give the size of the answer.

2. Take row i of A and column j of B. Multiply the first entry of the row by the first entry of the column, the second by the second, and so on.

3. Add the products. The total is entry (i, j) of AB. Repeat for every row of A and every column of B.

For A=[1234]A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} and B=[5678]B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix}, entry (1, 1) is 1⋅5+2⋅7=191 \cdot 5 + 2 \cdot 7 = 19 and entry (2, 2) is 3⋅6+4⋅8=503 \cdot 6 + 4 \cdot 8 = 50, so AB=[19224350]AB = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix}. Load the 2 × 2 product example above to see all four entries: used as a matrix multiplication calculator, the tool shows the row-times-column sum for every entry whenever the product has at most nine entries, such as a 3 × 3 result. To multiply a matrix by a number instead, choose k · A: every entry is multiplied by k.

Which matrix sizes can be multiplied
ABDoes A × B exist?Size of AB
2 × 22 × 2Yes2 × 2
2 × 33 × 2Yes2 × 2
3 × 22 × 3Yes3 × 3
2 × 22 × 1Yes (matrix times vector)2 × 1
3 × 33 × 3Yes3 × 3
2 × 32 × 3No: 3 columns but 2 rows—

What matrix multiplication means

A matrix acts on a vector by turning it into a new vector: Ax→A\vec{x} mixes the components of x→\vec{x} using the rows of A. The product AB is the single matrix that does "first B, then A". That is why the order cannot be swapped freely, and why the columns of A must match the rows of B.

Multiplication is associative, so three matrices can be multiplied in either grouping: (AB)C=A(BC)(AB)C = A(BC). Work out AB first, then multiply the result by C. Powers follow the same idea. If a matrix rotates the plane by 90°, its fourth power rotates by 360° and equals the identity, which you can check with the "Rotation to the 4th power" example.

Determinant, inverse and Gauss–Jordan elimination

Choose Determinant det(A) or Inverse A⁻¹ for a square matrix. The determinant is found by reducing A to triangular form and multiplying the diagonal; the inverse by Gauss–Jordan elimination, which row-reduces [A∣I][A \mid I] until the left half is the identity. If det A = 0, the matrix is singular and has no inverse.

For more detail, the determinant calculator adds cofactor expansion, the inverse matrix calculator adds the 2 × 2 shortcut and the adjugate method, and the RREF calculator runs Gauss–Jordan elimination on any matrix, including augmented matrices for solving Ax→=b→A\vec{x} = \vec{b}.

Matrix operations at a glance

Each operation has its own size rule. The table lists what each one needs and what it returns.

Size rules for each matrix operation
OperationNeedsResult
A + B, A − BA and B the same sizeSame size as A
A × BColumns of A = rows of B(rows of A) × (columns of B)
k · AAny matrix and a number kSame size as A
Transpose AᵀAny matrixm × n becomes n × m
Determinant, traceSquare matrixA single number
Inverse A⁻¹Square matrix with det A ≠ 0Same size as A
Power AⁿSquare matrix (det A ≠ 0 if n < 0)Same size as A

Matrices on a TI-84 or Casio calculator

TI-84 Plus: press 2nd then x⁻¹ to open MATRIX, go to EDIT, choose [A], set the size and type the entries; do the same for [B]. On the home screen insert [A] and [B] from the NAMES menu with × between them and press ENTER. Use x⁻¹ after [A] for the inverse, and det( from the MATH tab of the same MATRIX menu for the determinant.

Casio fx-991EX (ClassWiz): press MENU and choose Matrix, define MatA and MatB with their sizes (up to 4 × 4) and type the entries. Press AC, then use OPTN to insert MatA and MatB, type × between them and press =. A size mismatch gives Dimension ERROR.

Handheld calculators show only the answer. Use this page to see the working, or for 5 × 5 and 6 × 6 matrices. This calculator is for linear algebra; it is not a "Destiny Matrix" numerology chart.

Worked example

Multiply a 2 × 3 matrix by a 3 × 2 matrix

Find AB for A = [[2, −1, 3], [0, 4, 1]] and B = [[1, 2], [5, −3], [−2, 0]].

  1. Sizes: (2 × 3)(3 × 2). The inner sizes are both 3, so AB exists and is 2 × 2.
  2. Entry (1, 1): row 1 of A times column 1 of B is 2⋅1+(−1)⋅5+3⋅(−2)=2−5−6=−92 \cdot 1 + (-1) \cdot 5 + 3 \cdot (-2) = 2 - 5 - 6 = -9.
  3. Entry (1, 2): 2⋅2+(−1)(−3)+3⋅0=4+3+0=72 \cdot 2 + (-1)(-3) + 3 \cdot 0 = 4 + 3 + 0 = 7.
  4. Entry (2, 1): 0⋅1+4⋅5+1⋅(−2)=0+20−2=180 \cdot 1 + 4 \cdot 5 + 1 \cdot (-2) = 0 + 20 - 2 = 18.
  5. Entry (2, 2): 0⋅2+4⋅(−3)+1⋅0=−120 \cdot 2 + 4 \cdot (-3) + 1 \cdot 0 = -12.

Answer: AB=[−9718−12]AB = \begin{bmatrix} -9 & 7 \\ 18 & -12 \end{bmatrix}, a 2 × 2 matrix with determinant (−9)(−12)−(7)(18)=−18(-9)(-12) - (7)(18) = -18. These are the default matrices, so the calculator above already shows this product with its steps.

Frequently asked questions

How do you multiply two matrices?

Check that A has as many columns as B has rows. Then each entry (i, j) of AB is row i of A times column j of B: multiply matching entries and add. For example, [[1, 2], [3, 4]] × [[5, 6], [7, 8]] = [[19, 22], [43, 50]].

Why can’t I multiply my two matrices?

A × B exists only when A has as many columns as B has rows. A 2 × 3 matrix can multiply a 3 × 4 matrix, but not a 2 × 3 matrix. The calculator names the mismatch, for example "A has 3 columns but B has 2 rows".

Can you multiply matrices with different dimensions?

Yes, as long as the inner sizes match. A 2 × 3 matrix times a 3 × 4 matrix gives a 2 × 4 matrix. Adding and subtracting are stricter: both matrices must have exactly the same size.

Is matrix multiplication commutative?

No. With A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], AB = [[19, 22], [43, 50]] but BA = [[23, 34], [31, 46]]. Some pairs do commute, for example any matrix and the identity.

How do I multiply three matrices?

Multiply two at a time and keep the order: find AB, then multiply the result by C. Because multiplication is associative, (AB)C = A(BC), so either grouping gives the same answer.

What does a negative power of a matrix mean?

A⁻ⁿ is the inverse of A raised to the power n. For A = [[2, 1], [1, 1]], the inverse is [[1, −1], [−1, 2]] and A⁻² = [[2, −3], [−3, 5]]. If det A = 0 there is no inverse, so negative powers are undefined.

Can I raise a non-square matrix to a power?

No. A² = A × A needs the columns of A to match its rows, which only happens for square matrices. The same is true of the trace, the determinant and the inverse.

Are decimals rounded?

No. A decimal such as 0.1 is stored as the fraction 1/10, so sums and products are exact. A decimal table is added whenever the result contains fractions.

What is the trace used for?

The trace is the sum of the diagonal entries and equals the sum of the eigenvalues. It satisfies tr(AB) = tr(BA), and it appears in the characteristic polynomial used by the eigenvalue calculator.

Determinant Calculator

Exact determinants of 2x2 to 6x6 matrices by row reduction or cofactor expansion, with every step.

Linear Algebra

Inverse Matrix Calculator

Exact inverses of 2x2 to 6x6 matrices by Gauss–Jordan elimination, with every row operation and a check.

Linear Algebra

RREF Calculator

Reduced row echelon form or REF with each row operation, rank, nullity and linear system solutions.

Linear Algebra

Vector Calculator

Dot product, angle between vectors, magnitude, unit vector and projections of 2D to 6D vectors.

Linear Algebra

Step-by-Step Math Solver

Free worked solutions for equations, systems, inequalities, factoring, derivatives, integrals, limits and matrices.

Tools

Learn more: For how to type matrices and vectors in the full calculator, read matrices and vectors.

Sources and further reading

  1. Introduction to Linear Algebra, 6th edition, Chapter 2: Solving Linear Equations, Wellesley-Cambridge Press (Gilbert Strang, 2023)
  2. 18.06 Linear Algebra, Lecture 3: Multiplication and Inverse Matrices (opens in a new tab), MIT OpenCourseWare
  3. Matrices and Matrix Operations (Section 7.5, College Algebra 2e) (opens in a new tab), OpenStax, Rice University

Results are calculated in your browser with methods checked by automated tests, and are intended for learning and general use. For engineering, medical, financial, legal or safety-critical decisions, verify important values independently and follow the rounding rules your work requires. How accurate are these results?