easyonlinecalculator

Matrix Calculator

Pick an operation, set the size of matrix A (and B when the operation needs two), type the numbers into the grid and read the result. It handles matrices from 1x1 up to 4x4 with decimals and negatives, and Show the work lists the arithmetic behind every entry.

Last updated November 4, 2026

Matrix A
Matrix B

Result

A x B is a 2x2 matrix

Result matrix A x B
1922
4350
Show the work

Formula: C(i,j) = A(i,1) x B(1,j) + A(i,2) x B(2,j) + ... (row i of A times column j of B)

  1. A is 2x2 and B is 2x2, so A x B is 2x2.
  2. C(1,1) = 1 x 5 + 2 x 7 = 19
  3. C(1,2) = 1 x 6 + 2 x 8 = 22
  4. C(2,1) = 3 x 5 + 4 x 7 = 43
  5. C(2,2) = 3 x 6 + 4 x 8 = 50

Result: A x B = [[19, 22], [43, 50]]

The rules behind each matrix operation

Formula

A + B and A - B: add or subtract matching entries

A x B: C(i,j) = A(i,1) x B(1,j) + A(i,2) x B(2,j) + ...

2x2 determinant = ad - bc

trace = sum of the diagonal

Addition and subtraction work entry by entry, so the two matrices must have the same number of rows and columns. A scalar times a matrix multiplies every entry by that number. The transpose turns each row into a column.

Multiplication is different. Entry C(i,j) of A x B is the dot product of row i of A with column j of B: multiply the pairs and add them. That only works when the number of columns in A equals the number of rows in B, and the result has the rows of A and the columns of B. Order matters, so A x B and B x A usually differ.

The determinant, inverse and trace need a square matrix. The determinant of a 2x2 matrix [[a, b], [c, d]] is ad - bc. Larger sizes are shown as a cofactor expansion along the first row, using the minors left after deleting a row and a column. The trace is the sum of the main diagonal.

The rank is the number of pivots found by Gaussian elimination, which equals the number of independent rows. A square matrix has an inverse only when its determinant is not 0, in other words when its rank equals its size.

See how we calculate for the formulas, sources and review schedule behind every calculator.

Also useful alongside this calculator: Quadratic Formula Calculator and Slope Calculator.

How the determinant, inverse and rank are computed

When every entry is a whole number, the determinant and rank use exact integer arithmetic (Bareiss fraction-free elimination), so a determinant of 0 is exact and never an almost-zero rounding artefact. With decimal entries the determinant uses LU elimination with partial pivoting, and rank uses Gaussian elimination with partial pivoting.

The inverse uses Gauss-Jordan elimination on A beside the identity matrix, always picking the largest available pivot. For decimal matrices, a pivot no larger than 1e-12 times the largest entry counts as zero. Results are rounded to 12 significant digits, so 0.1 + 0.2 shows as 0.3, and negative zero is shown as 0.

Singular matrices and error messages

A matrix with determinant 0 is singular. For [[1, 2], [2, 4]] the second row is twice the first, the determinant is 1 x 4 - 2 x 2 = 0, the rank is 1, and there is no inverse. The calculator then says so in plain words and still shows the determinant.

Size problems are named: for a 2x3 matrix A and a 2x2 matrix B the message reads that the columns of A (3) must equal the rows of B (2). An empty or non-numeric cell is reported by matrix, row and column.

How to use the Matrix Calculator

  1. Choose an operation: addition, subtraction, multiplication, scalar, transpose, determinant, inverse, trace or rank.
  2. Set the rows and columns of matrix A, and of matrix B if the operation uses two matrices.
  3. Type a number into every cell. Decimals and negative numbers are fine, and an empty cell is named in the message.
  4. Read the result matrix or number. Simple fractions such as 3/2 are listed under an inverse.
  5. Open Show the work to follow the arithmetic, then use Copy, Print or Share.

Worked example

Worked example

Take A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]. The top-left entry of A x B is 1 x 5 + 2 x 7 = 19. The determinant of A is 1 x 4 - 2 x 3 = -2, which is not 0, so A has an inverse: [[-2, 1], [1.5, -0.5]]. Multiplying A by that inverse returns the identity matrix.

Operations on A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]
OperationResult
A + B[[6, 8], [10, 12]]
A x B[[19, 22], [43, 50]]
B x A[[23, 34], [31, 46]]
Transpose of A[[1, 3], [2, 4]]
Determinant of A-2
Inverse of A[[-2, 1], [1.5, -0.5]]
Trace of A5
Rank of A2

Frequently asked questions

When can two matrices be multiplied?

When the number of columns in the first matrix equals the number of rows in the second. A 2x3 matrix times a 3x2 matrix gives a 2x2 result.

Why does my matrix have no inverse?

Its determinant is 0, so it is singular: at least one row is a combination of the others. Only square matrices with a non-zero determinant have an inverse.

Is matrix multiplication commutative?

No. For the example matrices A x B is [[19, 22], [43, 50]] but B x A is [[23, 34], [31, 46]], so the order you enter them matters.

What is the rank of a matrix?

It is the number of independent rows, found as the number of pivots in Gaussian elimination. The matrix [[1, 2], [2, 4]] has rank 1 because the second row is double the first.

What is the largest matrix I can enter?

Each matrix can have up to 4 rows and 4 columns, down to a single 1x1 cell. Entries can be decimals or negatives, but not fractions like 1/2.