Skip to content
FigureSure
Sign in

Matrix Calculator

Add, subtract and multiply matrices up to 6 × 6, multiply by a scalar, transpose, and find the determinant, inverse and rank. Every result is computed in exact fractions, so singular matrices are detected exactly and inverses have no rounding error.
  • Updated
  • Formula shown

Operation
Show results as
Matrix A
Matrix B

Arrow keys move between cells and Enter moves down. Cells accept whole numbers, decimals and fractions such as 2/3; blank cells count as 0.

Results

A × B
2 × 2matrix
Result shown below
Determinant of A × B
4
Trace of A × B
Sum of the main diagonal
69

A × B = [19, 22; 43, 50]

A × B
Row 11922
Row 24350

How to use the matrix calculator

  1. Choose the operation. Sum, difference and product use matrices A and B; the others work on A.
  2. Set the number of rows and columns for each matrix (1 to 6), then type the entries. Use the arrow keys to move between cells and Enter to move down a column.
  3. Entries can be whole numbers, decimals or fractions such as 2/3 or −1.5. Blank cells count as zero.
  4. Switch the results between fractions and decimals. Press Use result as A to carry an answer into the next calculation, for example to multiply three matrices.

Matrix formulas

Sum: (A + B)ᵢⱼ = aᵢⱼ + bᵢⱼ · Scalar: (kA)ᵢⱼ = k·aᵢⱼ · Transpose: (Aᵀ)ᵢⱼ = aⱼᵢ
Product: (AB)ᵢⱼ = aᵢ₁b₁ⱼ + aᵢ₂b₂ⱼ + … + aᵢₙbₙⱼ
2 × 2 determinant: det [a, b; c, d] = ad − bc
2 × 2 inverse: [a, b; c, d]⁻¹ = 1 ÷ (ad − bc) × [d, −b; −c, a]

Adding, subtracting and scaling work entry by entry, so the matrices must be the same size. Multiplication is different: each entry of AB is a row of A multiplied term by term with a column of B and added up, so A needs as many columns as B has rows, and the result has A's rows and B's columns. Because rows and columns swap roles, AB and BA are usually different.

The determinant of a square matrix is the factor by which it scales area (2 × 2) or volume (3 × 3); a determinant of zero means the matrix squashes space flat, so it cannot be undone and has no inverse. The rank is the number of independent rows, found by counting the pivots after row reduction. This calculator uses Gaussian elimination for the determinant and Gauss–Jordan elimination for the inverse and rank, with exact rational arithmetic throughout.

Worked examples

Take A = [1, 2; 3, 4] and B = [5, 6; 7, 8] (rows separated by semicolons). The top-left entry of AB is 1 × 5 + 2 × 7 = 19, and the full product is AB = [19, 22; 43, 50]. In the other order, BA = [23, 34; 31, 46], which shows that matrix multiplication is not commutative.

The determinant of A is 1 × 4 − 2 × 3 = −2. It is not zero, so A has an inverse: A⁻¹ = 1 ÷ (−2) × [4, −2; −3, 1] = [−2, 1; 3/2, −1/2]. Multiplying A by that inverse gives the identity matrix exactly.

For a 3 × 3 matrix, expand along the first row. With C = [6, 1, 1; 4, −2, 5; 2, 8, 7], det(C) = 6 × (−2 × 7 − 5 × 8) − 1 × (4 × 7 − 5 × 2) + 1 × (4 × 8 − (−2) × 2) = 6 × (−54) − 18 + 36 = −306.

Which sizes work together

OperationRequirement (A is m × n)Result size
A + B, A − BB is also m × nm × n
A × BB has n rows (B is n × p)m × p
k × AAny sizem × n
AᵀAny sizen × m
det(A), A⁻¹Square (m = n); inverse also needs det(A) ≠ 0A number; n × n
rank(A)Any sizeA whole number from 0 to the smaller of m and n

Determinant and rank of some common matrices

Computed with this calculator's exact engine.

MatrixDeterminantRankInvertible?
Identity, 3 × 313Yes
[1, 2; 3, 4]−22Yes
[6, 1, 1; 4, −2, 5; 2, 8, 7]−3063Yes
[1, 2, 3; 4, 5, 6; 7, 8, 9]02No
Rotation by 90°: [0, −1; 1, 0]12Yes
Hilbert, 3 × 3: [1, 1/2, 1/3; …]1/21603Yes

The Hilbert matrix, with entries 1 ÷ (i + j − 1), is a classic test of numerical accuracy: its determinant is tiny (1/2160 for 3 × 3) and floating-point software often reports small errors in its inverse. In exact arithmetic the inverse has whole-number entries.

Tips and common mistakes

  • Check the order. A × B and B × A are different products, and one of them may not even exist. Use Swap A and B to compare.
  • Inverse before dividing. There is no matrix division: to "divide" by B, multiply by B⁻¹, on the correct side.
  • Singular means dependent. If a row is a multiple or a sum of other rows, the determinant is zero, the rank drops and no inverse exists.
  • Solving equations. A system Ax = b with an invertible A has the unique solution x = A⁻¹b: compute A⁻¹, use it as A, then multiply by b entered as a one-column B.

For single equations with an x² term, use the quadratic formula calculator; for working with fractions directly, the fraction calculator.

Frequently asked questions

How do I multiply two matrices?

Multiply each row of the first matrix by each column of the second, entry by entry, and add the products. The first matrix needs as many columns as the second has rows. For [1, 2; 3, 4] × [5, 6; 7, 8], the result is [19, 22; 43, 50].

How do I find the determinant of a 2 × 2 matrix?

For [a, b; c, d] the determinant is ad − bc. For [1, 2; 3, 4] it is 1 × 4 − 2 × 3 = −2. Larger matrices are reduced to triangular form by row operations, and the determinant is the product of the pivots.

When does a matrix have no inverse?

When it is not square or its determinant is zero (a singular matrix). [1, 2, 3; 4, 5, 6; 7, 8, 9] has determinant 0 because its middle row is the average of the other two, so it has no inverse.

What is the rank of a matrix?

The number of linearly independent rows (or columns), equal to the number of pivots after row reduction. [1, 2, 3; 4, 5, 6; 7, 8, 9] has rank 2, while any invertible 3 × 3 matrix has rank 3.

Is A × B the same as B × A?

Usually not: matrix multiplication is not commutative. With A = [1, 2; 3, 4] and B = [5, 6; 7, 8], AB = [19, 22; 43, 50] but BA = [23, 34; 31, 46]. One of the two products may not even exist when the matrices are not square.

Was this calculator helpful?