Skip to main content

Matrix Calculator

Do matrix addition, subtraction, multiplication, scalar multiply, transpose, determinant, inverse, RREF, and solve A·x = b with exact fractions and optional step-by-step working.

This Matrix Calculator performs common matrix operations (A±B, A·B, Aᵀ, det(A), A⁻¹, RREF, and Ax=b) using exact fractions and shows optional Gaussian elimination steps.

Supported Matrix Operations

  • Addition & subtraction (same dimensions)
  • Multiplication (columns(A) = rows(B))
  • Scalar multiplication (c·A)
  • Transpose (Aᵀ)
  • Determinant and inverse (square matrices only)
  • RREF and solving linear systems (Ax = b)

Background

A matrix is a rectangular grid of numbers. Matrix operations follow strict rules: A + B requires matching dimensions, A·B requires inner dimensions match, and an inverse A−1 exists only if det(A) ≠ 0.

Matrix multiplication combines rows of A with columns of B and is defined only when the number of columns in A equals the number of rows in B.

Set up your matrices

Step 1 — What do you want to do?

Step 2 — Enter your values

Type one row per line, or separate rows with a semicolon (;). Separate entries with spaces or commas. Fractions like -3/4 and decimals like 0.5 are fine. Use a dot for decimals, because commas separate entries. In a matrix box, press Ctrl+Enter to calculate.

Learning options

Show answers as

Quick examples (click to calculate)

Result

How to use this calculator

  1. Choose what you want to do: add, subtract, multiply, scale, transpose, find a determinant or inverse, row-reduce, or solve a system.
  2. Type or paste your matrices, one row per line (or separated by semicolons). Matrix B, the scalar c or the vector b appear only when the operation needs them.
  3. Press Calculate (or press Ctrl+Enter inside a matrix box) to see the answer. If you change a value, press Calculate again.
  4. Choose Exact fractions or Decimals. Turn the step-by-step working on or off, and for RREF, inverse, solve and determinant choose whether to see the matrix after every step. The pivot is outlined and the changed rows are shaded.
  5. Click a quick example to load it and see the answer straight away.

How this calculator works

  • Addition and subtraction: entry by entry (same dimensions).
  • Multiplication: row-by-column dot products.
  • RREF, solve and inverse: Gaussian elimination with exact fractions.
  • Determinant: elimination with pivot tracking (exact).
  • Every number you type is read exactly, so a decimal like 0.1234567 keeps all of its digits.

Formulas & Equations Used

Addition/Subtraction (same size matrices): C[i,j] = A[i,j] ± B[i,j]

Multiplication (A is m×n, B is n×p): C[i,j] = Σk=1..n A[i,k] · B[k,j]

Solving A·x = b: build the augmented matrix [A | b], then use row operations to reach RREF and read x.

Inverse: build [A | I] and row-reduce until the left side is I. The right side becomes A−1.

2×2 inverse shortcut: A−1 = 1/(ad − bc) · [ [d, −b], [−c, a] ]

Example Problems & Step-by-Step Solutions

Example 1 — Add two 2×2 matrices

A = [ [1, 2], [3, 4] ] and B = [ [5, 6], [7, 8] ].

Step: add entry by entry: 1+5 = 6, 2+6 = 8, 3+7 = 10, 4+8 = 12.

Result: A + B = [ [6, 8], [10, 12] ].

Example 2 — Multiply a 2×3 by a 3×2

A = [ [1,2,3], [4,5,6] ] and B = [ [7,8], [9,10], [11,12] ].

Step: C[1,1] = 1·7 + 2·9 + 3·11 = 58, C[1,2] = 1·8 + 2·10 + 3·12 = 64, C[2,1] = 4·7 + 5·9 + 6·11 = 139, C[2,2] = 4·8 + 5·10 + 6·12 = 154.

Result: A·B = [ [58, 64], [139, 154] ].

Example 3 — Inverse of a 2×2

A = [ [4, 7], [2, 6] ].

Step: det(A) = 4·6 − 7·2 = 10, which is not 0, so the inverse exists. Then A−1 = 1/10 · [ [6, −7], [−2, 4] ].

Result: A−1 = [ [3/5, −7/10], [−1/5, 2/5] ].

Example 4 — Solve A·x = b

A = [ [2,1], [5,3] ] and b = [ [1], [0] ]. Start from [A | b] = [ [2, 1 | 1], [5, 3 | 0] ].

Step: Scale R1 by 1/2 → [1, 1/2 | 1/2]. R2 = R2 − 5·R1 → [0, 1/2 | −5/2]. Scale R2 by 2 → [0, 1 | −5]. R1 = R1 − (1/2)·R2 → [1, 0 | 3].

Result: x = [ [3], [−5] ]. The calculator shows these same row operations, with the matrix after each one, when step-by-step is on.

Frequently Asked Questions

What formats can I paste into the matrix boxes?

Use spaces or commas between entries, and new lines or semicolons between rows. Fractions like 3/5, decimals like 0.5 and e-notation like 2.5e-3 are supported. Use a dot, not a comma, for decimals.

Why does matrix multiplication sometimes show an error?

A·B is defined only when the number of columns in A equals the number of rows in B.

When does an inverse exist?

An inverse exists only for square matrices with nonzero determinant (det(A) ≠ 0).

Does this calculator keep exact fractions?

Yes. Every calculation uses exact fractions, and answers are shown as exact fractions by default. Choose Decimals to see rounded values with the exact fraction underneath.

What is RREF used for?

RREF is used to solve linear systems, find matrix rank, and determine whether a system has a unique, infinite, or no solution.

How many decimal places are kept in my input?

All of them. A decimal such as 0.1234567 is read exactly as 1234567/10000000, so nothing is rounded or cut off before the calculation.

How large can the matrices be?

Up to 20×20. Larger matrices are rejected with a message.

Back to all calculatorsAll calculators