Skip to content
Back to Calculators

Matrix Calculator

Multiply, add, invert, transpose and find determinants of matrices up to 8×8, with exact fractions and the steps

Matrix A
Paste from a spreadsheet
Matrix B
Paste from a spreadsheet

Multiply

Add or subtract

One matrix at a time: use

Whole number, -20 to 20.

Determinant and inverse

Transpose, scalar and power

Entries can be decimals (2.5, -3) or fractions (3/4). Calculated in your browser with exact arithmetic; nothing you enter or paste is saved or sent.

Illustrative example shown: A × B for two 2×2 matrices. Edit the matrices and choose an operation.

Result
2×2 matrix
A × B is a 2×2 matrix
Size rule
2×2 × 2×2 = 2×2
Operation
A × B

Result matrix

Result matrix, 2 by 2
1922
4350
  • Matrix multiplication is not commutative: A × B and B × A are usually different. Use the other button to compare.

The steps

  1. Each entry is a row of A times a column of B: (AB)ᵢⱼ = Σ Aᵢₖ·Bₖⱼ over k = 1…2.
  2. Entry (1,1): (1)(5) + (2)(7) = 19.
  3. Entry (1,2): (1)(6) + (2)(8) = 22.

How to Multiply Matrices

To multiply two matrices, take each row of the first and pair it with each column of the second: multiply the matching entries and add them up. Each result becomes one entry of the product. For A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], the top-left entry is 1 × 5 + 2 × 7 = 19, and the full product AB is [19, 22], [43, 50]. The calculator shows every one of those sums in the steps panel, so you can follow a homework problem line by line.

Multiplication works only when the inner sizes match: the number of columns in the first matrix must equal the number of rows in the second. A 2 × 3 matrix times a 3 × 2 matrix is allowed and gives a 2 × 2 result. For example, [[1, 2, 3], [4, 5, 6]] times [[7, 8], [9, 10], [11, 12]] equals [58, 64], [139, 154]. The size of the answer is the outer sizes, rows of the first by columns of the second. If the inner sizes differ, the tool tells you the two sizes and why the product is undefined rather than guessing.

Order matters. Matrix multiplication is not commutative, so AB and BA are usually different, and one may exist when the other does not. With the same A and B as above, BA is [23, 34], [31, 46], which is not the same as AB. That is why the calculator has separate A × B and B × A buttons instead of one multiply button. It is, however, associative, so (AB)C equals A(BC), and it distributes over addition.

How to Find the Inverse of a Matrix

The inverse of a square matrix A is the matrix A⁻¹ that gives the identity matrix when multiplied by A on either side. Only some matrices have one. For a 2 × 2 matrix [[a, b], [c, d]] the inverse is 1 / (ad − bc) times [[d, −b], [−c, a]]. For [[1, 2], [3, 4]] the determinant is -2, so the inverse is [-2, 1], [3/2, -1/2]. The tool then multiplies A by A⁻¹ and reports that the result is the identity, which is a quick way to confirm the answer.

For larger sizes the calculator uses Gauss–Jordan elimination: it writes A next to an identity matrix and applies row operations until the left side becomes the identity, at which point the right side is the inverse. Every step is carried out in exact fractions, so you see entries such as 3/2 rather than 1.5000000001. The decimals checkbox shows rounded values when you want them, and rounded values are always marked with ≈ so you can tell them from exact ones.

The inverse is what solves systems of linear equations written as Ax = b: multiply both sides by A⁻¹ to get x = A⁻¹b. In practice elimination is faster by hand, but the inverse is useful when you need to solve for several right-hand sides, and it appears throughout statistics and finance, for instance in the normal equations of a regression and in portfolio covariance matrices.

How to Find the Determinant

The determinant is a single number computed from a square matrix. For a 2 × 2 matrix it is ad − bc, so [[1, 2], [3, 4]] has determinant 1 × 4 − 2 × 3 = -2. For a 3 × 3 matrix you expand along a row or column, multiplying each entry by the determinant of the smaller matrix left after deleting its row and column, with alternating signs. For [[2, 1, 3], [0, 4, 1], [1, 0, 2]] this gives 5.

The determinant tells you two things at once. If it is zero, the matrix is singular: it has no inverse and its rows are linearly dependent. If it is not zero, the matrix is invertible. Geometrically, the absolute value of a 2 × 2 determinant is the area scale factor of the transformation the matrix describes, and a negative sign means the orientation is flipped. The calculator evaluates larger matrices by exact elimination and shows the working, so the sign and the size are both reliable.

Matrix Dimension Rules

Most errors come from sizes, so the calculator states them for every operation. Addition and subtraction need two matrices of exactly the same size and work entry by entry. Multiplication needs the inner sizes to match, as described above. Transposing flips rows and columns, so a 2 × 3 matrix becomes 3 × 2. The determinant, the inverse and integer powers need a square matrix. Scalar multiplication works on any size and multiplies every entry by the same number.

A quick example of transposing: [[1, 2, 3], [4, 5, 6]] becomes [1, 4], [2, 5], [3, 6]. Powers repeat multiplication, so a matrix to the power 5 is the matrix multiplied by itself five times; [[1, 1], [1, 0]] to the power 5 is [8, 5], [5, 3], which contains the Fibonacci numbers. A power of zero gives the identity matrix, and a negative power is the inverse raised to the matching positive power, so it needs the matrix to be invertible. Sizes up to 8 × 8 are supported.

Singular Matrices

A singular matrix has a determinant of zero and no inverse. A common example is [[1, 2], [2, 4]], where the second row is exactly twice the first. Asking for its inverse returns a clear message rather than an error: A is singular: it has no inverse. The same applies to negative powers of a singular matrix, because a negative power needs the inverse. A singular result is a valid mathematical answer, not a failure, so the calculator explains it instead of showing a blank. If you expected an inverse, check for a row or column that is a multiple or a sum of others, or for a typing slip in one entry.

Pasting a Matrix from a Spreadsheet

Typing a large matrix cell by cell is slow, so each matrix accepts a pasted block. Select the cells in Excel or Google Sheets, copy them, click into any cell of the matrix and paste, or open the paste box under the grid and press Use these values. Rows should be on separate lines and values separated by tabs or spaces. The grid resizes to match, up to 8 × 8. If the rows have different lengths, or a cell is not a number, the message names the row so you can fix it. Entries may be integers, decimals such as 2.5, or fractions such as 3/4. Commas are not accepted as separators because they can also be decimal marks. Nothing you paste leaves your browser.

Results can be copied back the same way: the Copy result button puts the answer on the clipboard as tab-separated rows, ready to paste into a spreadsheet.

Frequently asked questions

Why can't I multiply these two matrices?

The number of columns in the first matrix must equal the number of rows in the second. A 2 × 3 matrix can multiply a 3 × 4 matrix but not another 2 × 3 matrix. The calculator shows both sizes so you can see the mismatch.

Is AB the same as BA?

Usually not. Matrix multiplication depends on order, and BA may not even be defined when AB is. Use the separate A × B and B × A buttons to compare them.

When does a matrix have an inverse?

Only when it is square and its determinant is not zero. A matrix with a zero determinant is called singular and has no inverse.

Are the results exact?

Yes. Calculations use exact fractions, so entries such as 1/3 are not rounded along the way. Decimals shown with the decimals option are rounded and marked ≈; the exact fractions stay unchanged.

What size of matrix can I enter?

Up to 8 rows and 8 columns for each of the two matrices. You can type values, use the row and column selectors, or paste a block copied from a spreadsheet.

Related tools: the statistics calculator and the standard deviation calculator for summarizing data sets, and the math directory for every math tool on the site.

Get New Free Calculators by Email

Get practical calculator walkthroughs and new tool updates by email. Occasional emails only, unsubscribe at any time.

No spam. See our privacy policy.