Matrix Calculator

Add, multiply, transpose, find determinant, inverse and rank up to 5×5, in fractions

A
B
Whole numbers, fractions (2/3) or decimals. Empty cells count as 0.
Fill an example
Operation
A × B (2×2)
2536
2028
2×2 × 2×2 gives a 2×2 matrix. Each entry is a row of A times a column of B, added up.

Runs entirely in your browser. Nothing you type or upload is sent to us or stored.

Results are for general guidance. Please check anything important before relying on it. Terms of use

How to Use

  1. Set the size of matrix A and matrix B with the row and column pickers (anything from 1×1 to 5×5), then type the entries. Whole numbers, fractions such as 2/3 and decimals all work; an empty cell counts as 0.
  2. Choose an operation: A + B, A − B, A × B, k × M, transpose, determinant, inverse, rank or trace. For the single-matrix operations, pick on A or on B.
  3. The result appears straight away, in exact fractions when your entries are whole numbers or fractions. Switch between Fractions and Decimals if you prefer. The determinant also shows its working.
  4. Use copy as text or copy as CSV to paste the answer elsewhere. swap A and B exchanges the two matrices, and the example buttons fill in sample matrices.

Matrix calculator with exact fractions

This matrix calculator adds, subtracts and multiplies matrices up to 5×5, and finds the transpose, determinant, inverse, rank and trace. It works with exact fractions, so the inverse of a matrix with whole-number entries comes out as 3/5 and −7/10 rather than 0.6 and −0.7 (switch to decimals if you want those). That makes it easy to check Class 12 matrix and determinant exercises, where answers are normally written as fractions or as (1/|A|) × adj A.

When each operation is possible

OperationSize ruleResult size
A + B, A − BA and B the same sizeSame as A
A × BColumns of A = rows of BRows of A × columns of B
k × A, transposeAny sizeSame, or flipped for the transpose
Determinant, inverse, traceSquare onlyA number (inverse: same as A)
RankAny sizeA whole number

Matrix multiplication is not commutative: A × B and B × A are usually different, and one of them may not even exist. With A = [1 2; 3 4] and B = [5 6; 7 8], A × B = [19 22; 43 50] but B × A = [23 34; 31 46]. Use swap A and B to see both.

Determinant

For a 2×2 matrix the determinant is ad − bc. For a 3×3 matrix the calculator expands along the first row, the method taught in NCERT Class 12:

A = [2 −1 0; 1 3 2; 0 1 4]
|A| = 2(3×4 − 2×1) − (−1)(1×4 − 2×0) + 0(1×1 − 3×0)
= 2 × 10 + 1 × 4 + 0 = 24

For 4×4 and 5×5 matrices it uses row reduction: turn the matrix into upper triangular form, then multiply the diagonal entries, changing the sign once for every row swap. Both methods give the same answer.

Inverse

A square matrix has an inverse only when its determinant is not 0. For a 2×2 matrix:

[a b; c d]⁻¹ = (1/(ad − bc)) × [d −b; −c a]
[4 7; 2 6]⁻¹ = (1/10) × [6 −7; −2 4] = [3/5 −7/10; −1/5 2/5]

For larger matrices the textbook formula is A⁻¹ = adj(A)/|A|. The calculator gets the same result by Gauss-Jordan elimination: it row-reduces [A | I] until the left half becomes the identity, and the right half is then A⁻¹. You can check any inverse by multiplying: A × A⁻¹ should give the identity matrix I. If the determinant is 0, the matrix is singular and the calculator says so. [1 2 3; 4 5 6; 7 8 9] is the classic example.

Rank and trace

The rank is the number of rows that are linearly independent: after row reduction, it is the number of non-zero rows. [1 2 3; 4 5 6; 7 8 9] has rank 2, because the third row equals 2 × (second row) − (first row). Comparing ranks tells you whether a system of linear equations has one solution, none or infinitely many. Consistency of such systems is part of the JEE Main syllabus. The trace is the sum of the main diagonal: for [1 2; 3 4] it is 1 + 4 = 5.

Tips

  • Type fractions directly (1/3) rather than 0.333. A decimal entry switches the display to decimals, but the arithmetic stays exact either way.
  • Copy as CSV pastes cleanly into Excel or Google Sheets, one row per line.
  • To solve AX = B, find A⁻¹ here and multiply it by B, or use the System tab of the equation solver.

Frequently Asked Questions

Only when the number of columns of the first equals the number of rows of the second. A 2×3 matrix times a 3×2 matrix is allowed and gives a 2×2 result. A 2×3 times another 2×3 is not.

Swap a and d, change the signs of b and c, and divide everything by the determinant ad − bc. For [4 7; 2 6], the determinant is 24 − 14 = 10, so the inverse is (1/10)[6 −7; −2 4].

Its determinant is 0, so it has no inverse. Its rows (or columns) are dependent, meaning one can be built from the others. [1 2 3; 4 5 6; 7 8 9] is singular.

Usually not. Matrix multiplication isn't commutative. For A = [1 2; 3 4] and B = [5 6; 7 8], A × B = [19 22; 43 50] while B × A = [23 34; 31 46].

It's the number of linearly independent rows, which equals the number of non-zero rows after row reduction. A 3×3 matrix with a non-zero determinant has rank 3; a singular one has rank 2 or less.

Because the calculator works exactly. If your entries are whole numbers or fractions, results like 3/5 are exact, while 0.6 might be rounded. Tap Decimals to see them as decimals instead.