A more comprehensive version of this tool is now available: Matrix Multiplication and Determinant Solver - adds determinant calculations (|A|, |B|) using Laplace expansion for all square matrices up to 5x5.
Matrix A
Rows
Cols
2x2
Matrix B
Rows
Cols
2x2
Result: Matrix C
Key Terms Explained
Matrix
A rectangular array of numbers arranged in rows and columns, used to represent data or transformations.
Element
A single number inside a matrix, identified by its row and column position (e.g., row 2, column 3).
Row
A horizontal line of elements in a matrix. A matrix with m rows has m horizontal layers of numbers.
Column
A vertical line of elements in a matrix. A matrix with n columns has n vertical groups of numbers.
Dimensions (m x n)
The size of a matrix expressed as rows by columns. A 3x4 matrix has 3 rows and 4 columns, totaling 12 elements.
Dot Product
The sum of products of corresponding elements in two equal-length sequences. Used row-by-column to compute each element of a matrix product.
Commutative Property
A property where order does not matter (e.g., 2+3 = 3+2). Matrix addition IS commutative; matrix multiplication is NOT.
Identity Matrix
A square matrix with 1s on the main diagonal and 0s elsewhere. Multiplying any matrix by the identity matrix leaves it unchanged.

The Complete Guide to Matrix Operations

Matrices are one of the most powerful and widely applied structures in all of mathematics. Whether you are a student learning linear algebra for the first time or an engineer refreshing your memory, this guide walks through everything you need to understand matrix addition, subtraction, and multiplication.

How to Use This Calculator

Set the number of rows and columns for Matrix A and Matrix B using the dropdowns in each panel. Click any cell and type a number. The result in Matrix C updates the moment you type. To switch between operations, click the A + B, A - B, or A x B buttons at the top. Empty cells are treated as zero. There is no submit button - everything is live.

Addition and Subtraction: Element by Element

Adding or subtracting matrices is straightforward: both matrices must have the exact same dimensions, and you simply apply the operation to each pair of corresponding elements. The element at row 1, column 1 of Matrix A is added to (or subtracted from) the element at row 1, column 1 of Matrix B. This produces the element at row 1, column 1 of the result. The result matrix always has the same dimensions as the inputs. If the dimensions do not match, the operation is mathematically undefined.

Because matrix addition follows the same element-by-element rule as regular addition, it inherits commutativity: A + B always equals B + A. Subtraction, however, is not commutative - A - B is generally not the same as B - A, just as 5 - 3 differs from 3 - 5.

Multiplication: Rows Meet Columns

Matrix multiplication is more nuanced. To multiply Matrix A (size m x p) by Matrix B (size p x n), the number of columns in A must equal the number of rows in B - those are the "inner" dimensions. The result, Matrix C, has dimensions m x n.

Each element of Matrix C is computed as the dot product of a row from Matrix A and a column from Matrix B. Specifically, C[i][j] = sum over k of A[i][k] times B[k][j]. For every element in the result, you are pairing up an entire row of A with an entire column of B, multiplying each pair, and summing the products. This is why the inner dimensions must agree - there must be an equal number of elements to pair up.

Unlike addition, matrix multiplication is not commutative. A x B usually does not equal B x A. Sometimes only one order is even valid. In real applications - graphics pipelines, neural networks, quantum mechanics - the order of matrix multiplication determines the meaning of the transformation.

Frequently Asked Questions

How do you add or subtract two matrices?
Both matrices must have identical dimensions. You add or subtract the corresponding element in each position. For example, the element in row 1, column 1 of Matrix A is added to the element in row 1, column 1 of Matrix B to produce the result in row 1, column 1 of Matrix C. If the matrices have different dimensions, the operation is undefined.
Why must matrices have specific dimensions to be multiplied?
Matrix multiplication requires the number of columns in Matrix A to equal the number of rows in Matrix B. This is because each result element is computed as a dot product between a row of A and a column of B. Without matching inner dimensions, there is no way to pair up elements to perform those products. A 2x3 matrix can multiply a 3x4 matrix (inner dimension 3 matches), yielding a 2x4 result. A 2x3 multiplied by a 2x4 is undefined.
Is matrix multiplication commutative - does A x B equal B x A?
No. Matrix multiplication is generally not commutative. In most cases A x B does not equal B x A, and sometimes only one order is even defined. Even when both products exist and have the same shape (as with square matrices), the results are usually different matrices. This is a fundamental distinction from regular number multiplication.
What are matrices actually used for in real life?
Matrices appear across virtually every technical field. In computer graphics, they rotate, scale, and translate objects in 2D and 3D space. In machine learning, neural networks are chains of matrix multiplications applied to data. In economics, input-output models represent entire industries as matrices. In physics and engineering, circuits, structural stress, and fluid flow are all described by matrix equations. Matrices are also the foundation of Google's original PageRank algorithm, modern cryptography, and quantum mechanics.
What is the identity matrix and why does it matter?
The identity matrix is a square matrix with 1s along the main diagonal (top-left to bottom-right) and 0s everywhere else. It is the matrix equivalent of the number 1: multiplying any matrix by the appropriately sized identity matrix leaves the original matrix unchanged. For a 2x2 case the identity is [[1,0],[0,1]], for 3x3 it is [[1,0,0],[0,1,0],[0,0,1]]. Understanding the identity is essential for grasping matrix inverses and solving linear systems.