Matrix Calculator

Calculate matrix addition, multiplication, determinants, inverses, transposes, powers, rank and trace for matrices up to 6 × 6, with exact fractions and working.

Matrix calculator

Type each row on a new line, with numbers separated by spaces or commas. Fractions such as 1/2 are allowed.

Result

Working

Matrices can be up to 6 × 6. Results are exact fractions when every entry is a whole number or fraction; otherwise they're rounded to 6 decimal places.

On this page

A matrix calculator performs the main matrix operations: addition, subtraction, multiplication, scalar multiplication, powers, transpose, determinant, inverse, rank and trace. It works with matrices up to 6 × 6, gives exact fractional answers whenever the entries are whole numbers or fractions, and shows the key steps so you can follow the method.

For example, the determinant of [2 1; 5 3] is 1, the inverse of [4 7; 2 6] is [3/5 −7/10; −1/5 2/5], and [1 2; 3 4] × [5 6; 7 8] = [19 22; 43 50].

How to use the matrix calculator

  1. Type matrix A with one row per line and the numbers separated by spaces or commas. For example, type “2 1” on the first line and “5 3” on the second.
  2. For A + B, A − B or A × B, type matrix B in the same way.
  3. Choose the operation. For a scalar multiple or a power, enter k or n in the extra box.
  4. Press Calculate to see the resulting matrix or value and the working.

What is a matrix?

A matrix is a rectangular grid of numbers arranged in rows and columns. Its size is written rows × columns, so a matrix with 2 rows and 3 columns is a 2 × 3 matrix. A square matrix has the same number of rows and columns. Matrices are a compact way to store and work with many numbers at once, and they’re the language of linear algebra.

Adding and subtracting matrices

Two matrices can be added or subtracted only if they’re the same size. Add or subtract the entries in matching positions: [1 2; 3 4] + [5 6; 7 8] = [6 8; 10 12]. Matrix addition is commutative, so A + B = B + A.

Multiplying matrices

To multiply A × B, the number of columns in A must equal the number of rows in B. The result has as many rows as A and as many columns as B. Each entry is the dot product of a row of A with a column of B: multiply matching entries and add them up.

For [1 2; 3 4] × [5 6; 7 8], the top-left entry is 1 × 5 + 2 × 7 = 19, the top-right is 1 × 6 + 2 × 8 = 22, the bottom-left is 3 × 5 + 4 × 7 = 43 and the bottom-right is 3 × 6 + 4 × 8 = 50.

Matrix multiplication is not commutative: A × B is usually different from B × A, and one may exist when the other doesn’t. A 2 × 3 matrix times a 3 × 2 matrix gives a 2 × 2 result, while the reverse order gives a 3 × 3 result.

Scalar multiplication and the transpose

Multiplying a matrix by a scalar, an ordinary number, multiplies every entry by that number: ½ × [1 2; 3 4] = [½ 1; 3/2 2]. The transpose, written Aᵀ, flips a matrix over its main diagonal so that rows become columns. The transpose of a 2 × 3 matrix is 3 × 2.

The determinant

The determinant is a single number calculated from a square matrix. For a 2 × 2 matrix [a b; c d], it’s ad − bc. For [2 1; 5 3], that’s 2 × 3 − 1 × 5 = 1. For a 3 × 3 matrix, you can expand along the first row: det = a(ei − fh) − b(di − fg) + c(dh − eg). Larger determinants are calculated by row reduction, which the calculator does automatically.

The determinant tells you whether a matrix can be inverted: if it’s zero, the matrix is singular and has no inverse. Geometrically, its absolute value is the factor by which the matrix scales areas (in 2D) or volumes (in 3D), and a negative sign means the orientation is flipped.

The inverse of a matrix

The inverse of a square matrix A, written A⁻¹, is the matrix that gives the identity when multiplied by A: A × A⁻¹ = I. The identity matrix has 1s on the main diagonal and 0s elsewhere; it plays the role of the number 1.

For a 2 × 2 matrix [a b; c d], the inverse is (1 ÷ (ad − bc)) × [d −b; −c a]. For [4 7; 2 6], the determinant is 24 − 14 = 10, so the inverse is [6/10 −7/10; −2/10 4/10] = [3/5 −7/10; −1/5 2/5]. For larger matrices, the calculator uses Gauss–Jordan elimination: it row-reduces [A | I] until the left half becomes the identity, and the right half is then A⁻¹.

Solving systems of equations

Matrices are a powerful way to solve simultaneous equations. The system 4x + 7y = 1 and 2x + 6y = 0 can be written as A × [x; y] = [1; 0] with A = [4 7; 2 6]. Multiplying both sides by A⁻¹ gives [x; y] = A⁻¹ × [1; 0] = [3/5; −1/5]. You can do this with the calculator by finding A⁻¹ and then multiplying it by the column of constants, entered as matrix B with one number per line.

Rank and trace

The rank of a matrix is the number of linearly independent rows, which equals the number of non-zero rows after row reduction. In [1 2 3; 2 4 6; 1 0 1], the second row is twice the first, so the rank is 2, not 3. A square matrix is invertible exactly when it has full rank. The trace of a square matrix is the sum of its main diagonal entries; for that matrix, it’s 1 + 4 + 1 = 6.

Matrix powers

A matrix power multiplies a square matrix by itself repeatedly: A² = A × A. A neat example is the Fibonacci matrix [1 1; 1 0]. Its 10th power is [89 55; 55 34], which contains the Fibonacci numbers 89, 55 and 34. Any square matrix raised to the power 0 gives the identity matrix.

Worked example: a 3 × 3 determinant

Take A = [2 −3 1; 2 0 −1; 1 4 5]. Expanding along the first row: 2 × (0 × 5 − (−1) × 4) − (−3) × (2 × 5 − (−1) × 1) + 1 × (2 × 4 − 0 × 1). That’s 2 × 4 + 3 × 11 + 1 × 8 = 8 + 33 + 8 = 49. Because the determinant isn’t zero, this matrix has an inverse, and a system of three equations using these coefficients has exactly one solution.

Matrices as transformations

A 2 × 2 matrix can be thought of as a rule that moves every point in the plane. The matrix [0 −1; 1 0] rotates points 90° anticlockwise about the origin, [2 0; 0 2] doubles every distance, and [1 0; 0 −1] reflects points in the x-axis. Multiplying two transformation matrices combines the movements into one, which is exactly how graphics software chains rotations, scalings and translations together efficiently.

Where matrices are used

  • Computer graphics and games: rotating, scaling and moving shapes on screen.
  • Engineering: analysing structures, circuits and control systems.
  • Data science and machine learning: storing data sets and computing models.
  • Economics: input–output models of industries.
  • Cryptography: some classic ciphers encode messages with matrix multiplication.

Common mistakes

  • Multiplying matrices entry by entry instead of row by column.
  • Assuming A × B equals B × A.
  • Trying to invert a non-square matrix or one with a determinant of zero.
  • Getting the sign pattern wrong when expanding a 3 × 3 determinant: it’s +, −, + along the first row.

Related calculations

Two other tools work well alongside this one: the number sequence calculator, to find the nth term and sum of a sequence, and the quadratic formula calculator, to solve quadratic equations.

Frequently asked questions

For [a b; c d], the determinant is ad − bc. For [2 1; 5 3], it's 6 − 5 = 1.

For a 2 × 2 matrix, swap a and d, change the signs of b and c, and divide by the determinant. For larger matrices, row-reduce [A | I] to [I | A⁻¹].

When it isn't square or when its determinant is 0. Such a matrix is called singular.

No. The number of columns in the first must equal the number of rows in the second.

Usually not. Matrix multiplication is not commutative, and the two products may even have different sizes.

A square matrix with 1s on the main diagonal and 0s elsewhere. Multiplying any matrix by it leaves the matrix unchanged.

The matrix you get by turning rows into columns. A 2 × 3 matrix becomes 3 × 2.

The number of linearly independent rows or columns. It tells you how much independent information the matrix contains.

Yes, when all entries are whole numbers or fractions, results are shown as exact fractions. With other decimals, they're rounded to 6 places.

The sum of the entries on the main diagonal of a square matrix. The trace of [1 2; 3 4] is 1 + 4 = 5.

Yes. Find the inverse of the coefficient matrix, then multiply it by the column of constants entered as matrix B.

Up to 6 rows and 6 columns.

Type one row per line, separating the numbers with spaces or commas. Fractions such as 3/4 and negative numbers are fine.