To perform matrix multiplication of A and B, each entry of AB is a row of A times a column of B. You multiply matching entries and then add them. AB exists only if A has the same number of columns as B has rows. An (m x n) matrix times an (n x p) matrix yields an (m x p) matrix. For example, ( begin{pmatrix}1&23&4end{pmatrix}begin{pmatrix}5&67&8end{pmatrix} = begin{pmatrix}19&2243&50end{pmatrix} ). Generally, ( AB neq BA ).
A matrix is a rectangular array of numbers. Matrices describe systems of equations, transformations of the plane, networks, images and much of modern computing, including the neural networks behind AI. This guide covers multiplication in detail, then the determinant, the inverse and how they solve systems of equations.
Matrix basics
An ( m times n ) matrix has m rows and n columns. The entry in row i, column j is written ( a_{ij} ).

- Addition and subtraction: only for matrices of the same size; add matching entries.
- Scalar multiplication: multiply every entry by the number.
- Transpose ( A^T ): swap rows and columns.
- Identity matrix I: 1s on the diagonal, 0s elsewhere; ( AI = IA = A ).
How to multiply matrices
The entry in row i, column j of AB is the dot product of row i of A with column j of B:

$$(AB)_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + dots + a_{in}b_{nj}$$
Example 1: 2 × 2 times 2 × 2
$$begin{pmatrix}1&23&4end{pmatrix}begin{pmatrix}5&67&8end{pmatrix} = begin{pmatrix}1cdot5 + 2cdot7 & 1cdot6 + 2cdot8 3cdot5 + 4cdot7 & 3cdot6 + 4cdot8end{pmatrix} = begin{pmatrix}19&2243&50end{pmatrix}$$
Example 2: different sizes
A ( 2 times 3 ) matrix times a ( 3 times 2 ) matrix gives a ( 2 times 2 ) matrix:
$$begin{pmatrix}1&2&34&5&6end{pmatrix}begin{pmatrix}7&89&1011&12end{pmatrix} = begin{pmatrix}58&64139&154end{pmatrix}$$
The top-left entry is ( 1cdot7 + 2cdot9 + 3cdot11 = 58 ).
When is multiplication possible?
| A | B | AB |
|---|---|---|
| ( 2 times 3 ) | ( 3 times 4 ) | ( 2 times 4 ) |
| ( 3 times 1 ) | ( 1 times 3 ) | ( 3 times 3 ) |
| ( 2 times 3 ) | ( 2 times 3 ) | not defined |
The inner numbers must match; the outer numbers give the size of the result.
Properties
- Not commutative: usually ( AB neq BA ). For example, for the matrices in Example 1, ( BA = begin{pmatrix}23&3431&46end{pmatrix} ).
- Associative: ( (AB)C = A(BC) ).
- Distributive: ( A(B + C) = AB + AC ).
- ( (AB)^T = B^TA^T ).
Matrix calculator
Enter matrices with rows separated by semicolons. Try multiplication, then switch to the determinant or inverse.
Matrix Calculator
Determinant, inverse, transpose, sum and product. Separate entries with spaces or commas and rows with semicolons.
The full-page matrix calculator handles up to ( 6 times 6 ).
The determinant
The determinant is a single number computed from a square matrix. Also, it tells you whether the matrix is invertible (( det neq 0 )) and how much the matrix scales areas or volumes.

2 × 2:
$$detbegin{pmatrix}a&bc&dend{pmatrix} = ad - bc$$
Example 3. ( detbegin{pmatrix}4&72&6end{pmatrix} = 24 – 14 = 10 ).
3 × 3 (expansion along the first row):
$$detbegin{pmatrix}a&b&cd&e&fg&h&iend{pmatrix} = a(ei - fh) - b(di - fg) + c(dh - eg)$$
Example 4. ( detbegin{pmatrix}2&0&11&3&21&1&2end{pmatrix} = 2(6 – 2) – 0 + 1(1 – 3) = 8 – 2 = 6 ).
Useful facts: ( det(AB) = det Acdotdet B ); swapping two rows changes the sign; a row of zeros or two equal rows give 0.
The inverse matrix
The inverse ( A^{-1} ) satisfies ( AA^{-1} = A^{-1}A = I ). However, it exists only for square matrices with ( det A neq 0 ).

2 × 2 formula:
$$A^{-1} = frac{1}{ad - bc}begin{pmatrix}d&-b-c&aend{pmatrix}$$
Swap the diagonal entries, negate the off-diagonal ones, and divide by the determinant.
Example 5. For ( A = begin{pmatrix}4&72&6end{pmatrix} ): ( A^{-1} = frac{1}{10}begin{pmatrix}6&-7-2&4end{pmatrix} = begin{pmatrix}0.6&-0.7-0.2&0.4end{pmatrix} ).
Example 6. ( begin{pmatrix}2&15&3end{pmatrix}^{-1} = begin{pmatrix}3&-1-5&2end{pmatrix} ), since the determinant is 1.
For larger matrices, use row reduction on ( [A mid I] ) until the left side becomes I; the right side is then ( A^{-1} ).
Solving systems of equations
The system

$$2x + y = 5, qquad 5x + 3y = 13$$
is ( Amathbf{x} = mathbf{b} ) with ( A = begin{pmatrix}2&15&3end{pmatrix} ) and ( mathbf{b} = begin{pmatrix}513end{pmatrix} ). Next, multiply by the inverse from Example 6:
$$mathbf{x} = A^{-1}mathbf{b} = begin{pmatrix}3&-1-5&2end{pmatrix}begin{pmatrix}513end{pmatrix} = begin{pmatrix}21end{pmatrix}$$
So ( x = 2 ), ( y = 1 ). (Check: ( 4 + 1 = 5 ) and ( 10 + 3 = 13 ).)
Where matrices are used
- Computer graphics: rotations, scaling and projections are matrix multiplications.
- Machine learning: neural networks are long chains of matrix multiplications.
- Multivariable calculus: the Jacobian and Hessian matrices; the second derivative test uses a determinant (see multivariable calculus and partial derivatives).
- Economics, networks and probability: input-output models, link analysis and Markov chains.
Common mistakes
- Multiplying entry by entry. That’s a different operation (the Hadamard product), not matrix multiplication.
- Assuming ( AB = BA ).
- Multiplying incompatible sizes. Check inner dimensions first.
- Sign errors in the 3 × 3 determinant. However, the middle term has a minus sign.
- Inverting when ( det = 0 ). Such a matrix is singular and has no inverse.
Practice problems
- Multiply ( begin{pmatrix}2&01&3end{pmatrix}begin{pmatrix}1&42&5end{pmatrix} ).
- Can a ( 3 times 2 ) matrix be multiplied by a ( 3 times 2 ) matrix?
- Find ( detbegin{pmatrix}3&84&6end{pmatrix} ).
- Find the inverse of ( begin{pmatrix}1&23&7end{pmatrix} ).
- Find ( detbegin{pmatrix}1&2&3&1&45&6&0end{pmatrix} ).
Answers: (1) ( begin{pmatrix}2&87&19end{pmatrix} ); (2) no; (3) ( -14 ); (4) ( begin{pmatrix}7&-2-3&1end{pmatrix} ); (5) 1.

FAQ
How do you multiply two matrices?
Take each row of the first matrix and each column of the second, multiply matching entries and add them. The result goes in the corresponding row and column.
When can two matrices be multiplied?
When the number of columns in the first equals the number of rows in the second.
Is matrix multiplication commutative?
No. In general ( AB neq BA ), and one of them may not even be defined.
How do you find the inverse of a 2 × 2 matrix?
Swap a and d, change the signs of b and c, and divide every entry by ( ad – bc ).
What does a determinant of zero mean?
The matrix has no inverse, and the system it represents has either no solution or infinitely many.
Further reading
- Matrix multiplication (Wikipedia) — definition, properties and applications.
- Invertible matrix (Wikipedia) — conditions for invertibility and methods for finding inverses.
- Determinant (Wikipedia) — formulas and geometric meaning.
Calculators for this topic
Keep learning
The Unit Circle: Angles, Coordinates and Trig Values
The unit circle explained: why the coordinates are cos and sin, every special angle in degrees and radians, tangent on the unit circle, and memory tricks.
Trigonometric Functions: Sin, Cos, Tan, Table and Graphs
The six trig functions with SOH-CAH-TOA and the unit circle, a table of exact values (sin 30, cos 180, sec 45), graphs, period and amplitude.

