Matrix Addition and Subtraction Calculator

Add or subtract two matrices of the same size, entry by entry, and see the resulting matrix plus its trace and Frobenius norm.

Quick Facts

Addition rule
(A + B)ᵢⱼ = Aᵢⱼ + Bᵢⱼ
Add the entries in matching positions; matrices must be the same size.
Subtraction rule
(A − B)ᵢⱼ = Aᵢⱼ − Bᵢⱼ
Subtract entry by entry; order matters, unlike addition.
Commutativity
A + B = B + A, but A − B ≠ B − A
Addition is commutative and associative; subtraction is neither.

Your Results

Calculated
Result Matrix C
-
C = A + B or A − B, entry by entry
Sum of All Entries
-
Total of every entry in C
Trace of C
-
Sum of the main diagonal entries
Frobenius Norm of C
-
√(sum of every entry squared)

Ready

Enter both matrices, choose add or subtract, then press Calculate.

How the Matrix Addition and Subtraction Calculator works

Matrix addition and subtraction are defined entry by entry (element-wise). For two matrices A and B with the same number of rows and the same number of columns, the sum C = A + B has entries Cij = Aij + Bij, and the difference C = A − B has entries Cij = Aij − Bij, where i is the row index and j is the column index. This calculator lets you enter two 2×2 or 3×3 matrices, choose addition or subtraction, and instantly get the resulting matrix along with two useful summary values: its trace and its Frobenius norm.

Formula and worked example

Because the operation is defined position by position, both matrices must have identical dimensions — you cannot add a 2×2 matrix to a 3×3 matrix. For example, with A = [[4, −2], [1, 3]] and B = [[1, 7], [0, 2]]:

A + B = [[4+1, −2+7], [1+0, 3+2]] = [[5, 5], [1, 5]], while A − B = [[4−1, −2−7], [1−0, 3−2]] = [[3, −9], [1, 1]].

The calculator also reports the trace of the result — the sum of the entries on the main diagonal (C11 + C22 + … + Cnn) — and the Frobenius norm, ‖C‖F = √(Σ Cij²), which is the square root of the sum of every entry squared. The Frobenius norm is a common way to measure the overall "size" of a matrix, similar to how vector length measures the size of a vector.

Common sources of error

  • Dimension mismatch: addition and subtraction only work when both matrices have the same number of rows and the same number of columns — there is no way to add a 2×2 matrix to a 3×3 matrix.
  • Sign errors when subtracting: subtraction is not commutative, so A − B and B − A give matrices with all signs flipped relative to each other; double-check which matrix comes first.
  • Confusing addition with multiplication: unlike matrix multiplication, addition and subtraction never involve multiplying rows by columns — every entry only interacts with the entry directly in the same position.

Properties and applications

Matrix addition is commutative (A + B = B + A) and associative ((A + B) + C = A + (B + C)), and the zero matrix acts as the identity element (A + 0 = A). Matrix subtraction has neither property. These operations show up throughout linear algebra and its applications: combining transformation matrices, summing data tables that share the same row/column structure, computing differences between two states in a Markov process, and adding covariance or adjacency matrices in statistics and graph theory.

Frequently Asked Questions

Can you add or subtract matrices of different sizes?
No. Matrix addition and subtraction are only defined when both matrices have exactly the same number of rows and the same number of columns. Each entry in the result comes from combining the entry in the same position in each matrix, so there must be a corresponding position in both.
What is the formula for adding or subtracting two matrices?
Combine matrices entry by entry: (A + B)ᵢⱼ = Aᵢⱼ + Bᵢⱼ and (A − B)ᵢⱼ = Aᵢⱼ − Bᵢⱼ, where i is the row and j is the column. For example, if A = [[4,−2],[1,3]] and B = [[1,7],[0,2]], then A + B = [[5,5],[1,5]].
Is matrix subtraction commutative or associative?
No. Matrix subtraction is neither commutative nor associative: A − B is generally not equal to B − A (in fact B − A = −(A − B)). Matrix addition, by contrast, is both commutative (A + B = B + A) and associative ((A + B) + C = A + (B + C)).
What is the identity element for matrix addition?
The zero matrix, in which every entry is 0. Adding or subtracting the zero matrix leaves a matrix unchanged: A + 0 = A and A − 0 = A.