Matrix Addition and Subtraction Calculator
Enter two matrices of the same dimensions, choose addition or subtraction, and get the result matrix instantly. The step-by-step panel shows every element calculation so you can follow the arithmetic and verify your work. Supports any rectangular matrix from 2x2 up to 4x4.
Formula
Worked example
Given A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], the sum A+B is found by adding corresponding entries: C(1,1) = 1+5 = 6, C(1,2) = 2+6 = 8, C(2,1) = 3+7 = 10, C(2,2) = 4+8 = 12. Result: [[6, 8], [10, 12]]. For A-B: C(1,1) = 1-5 = -4, C(1,2) = 2-6 = -4, C(2,1) = 3-7 = -4, C(2,2) = 4-8 = -4. Result: [[-4, -4], [-4, -4]].
What is matrix addition and subtraction?
A matrix is a rectangular array of numbers arranged in rows and columns. When two matrices have the same number of rows and the same number of columns, you can add or subtract them by operating on corresponding entries one at a time. If Matrix A is a 3x3 array and Matrix B is also 3x3, then the entry in row 2, column 3 of A+B equals the entry in row 2, column 3 of A plus the entry in row 2, column 3 of B. The requirement that the dimensions match exactly is called conformability. If A is 2x3 and B is 3x2, the operation is undefined - the sizes do not conform for addition or subtraction even though each matrix has 6 entries total.
How to use this calculator
Select the size of your matrices from the dropdown (from 2x2 up to 4x4), then choose addition or subtraction. Enter all entries of Matrix A in row-major order as a comma-separated list: for a 2x3 matrix, enter the 3 entries of row 1 followed by the 3 entries of row 2, giving 6 numbers total. Do the same for Matrix B. The result matrix and every element-wise calculation appear instantly. The Steps panel shows every individual addition or subtraction so you can verify each entry of the result.
Properties of matrix addition
Matrix addition satisfies several algebraic properties that parallel those of ordinary number addition. It is commutative: A+B equals B+A for any two conformable matrices. It is associative: (A+B)+C equals A+(B+C). The zero matrix (all entries zero) acts as an additive identity, so A plus the zero matrix equals A. Every matrix A has an additive inverse -A obtained by negating every entry, so A+(-A) equals the zero matrix. Subtraction is defined as A-B = A+(-B): you negate every entry of B and then add. This means subtraction is not commutative in general: A-B and B-A differ by a sign on every entry.
Real-world uses of matrix addition
Matrix addition appears whenever you need to combine or compare two rectangular data structures element by element. In economics and data science, matrices often represent datasets where rows are observations and columns are variables - adding two such matrices merges period-over-period changes. In computer graphics, transformations applied to the same set of vertices can be summed to compute a combined offset. In signal processing, two measurement arrays recorded at the same sample points can be added to accumulate energy. In network analysis, adjacency matrices can be added to combine two different types of connections into a single weighted graph. In any of these cases the math is always the same: entry (i,j) of the result is entry (i,j) of A combined with entry (i,j) of B.
Matrix operation conformability rules
| Operation | Requirement | Result size |
|---|---|---|
| Addition (A + B) | A and B must be same size: m x n + m x n | m x n |
| Subtraction (A - B) | A and B must be same size: m x n - m x n | m x n |
| Multiplication (A * B) | Columns of A must equal rows of B: m x n * n x p | m x p |
| Transpose (A^T) | Any matrix works | n x m (rows and columns swap) |
| Determinant (|A|) | A must be square: n x n | Scalar value |
| Inverse (A^-1) | A must be square and non-singular | n x n |
Which size combinations are allowed for each operation. m, n, p and q are positive integers.
Frequently asked questions
Can I add matrices of different sizes?
No. Matrix addition and subtraction require both matrices to have exactly the same number of rows and the same number of columns. If A is 2x3 and B is 3x2, the operation is undefined - there is no standard mathematical way to add them even though each has six entries. You would need to transpose one of them first to make them the same shape.
What is the formula for matrix addition?
The entry in row i, column j of the result C is C(i,j) = A(i,j) + B(i,j) for addition, and C(i,j) = A(i,j) - B(i,j) for subtraction. You repeat this for every position in the matrix. There are no row or column interactions - each output entry depends only on the two entries in that same position.
Is matrix addition commutative?
Yes, addition is commutative: A+B always equals B+A, because adding two numbers in either order gives the same result, and that applies to every entry. Subtraction is not commutative: A-B produces entries A(i,j)-B(i,j) while B-A produces entries B(i,j)-A(i,j), which differ by a sign in every position unless A and B are equal.
How do I enter a 3x3 matrix into this calculator?
Select "3 x 3" from the size dropdown. Then enter nine numbers separated by commas in row-major order. For a matrix whose first row is [1 2 3], second row is [4 5 6] and third row is [7 8 9], type: 1,2,3,4,5,6,7,8,9. The calculator reads the first three numbers as row 1, the next three as row 2, and the last three as row 3.
What is the difference between a matrix and a vector in this context?
A vector is just a special case of a matrix with either one row (a row vector) or one column (a column vector). A row vector with 4 entries is a 1x4 matrix and a column vector with 4 entries is a 4x1 matrix. You can add or subtract two row vectors of the same length, or two column vectors of the same length, using exactly the same rule as for any matrix - add corresponding entries.