Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Matrix Addition&Subtraction


Symbolic visualization of A ± B = C, cell by cell.

Operation
Dimensions (shared by A and B)?A and B must have the same dimensions — the same number of rows and the same number of columns. The result C has that same shape, and each cell of C is computed from the corresponding pair of cells in A and B.
A, B2×3
A2×3
a1,1
a1,2
a1,3
a2,1
a2,2
a2,3
+
B2×3
b1,1
b1,2
b1,3
b2,1
b2,2
b2,3
=
C2×3
?
?
?
?
?
?
Step 1 / 8

Step explanations

1Matrix addition
Both A and B are 2×3. To compute C = A + B, pair up each cell of A with its counterpart in B and add them.
Matching dimensions give every entry of A a partner in B - that is the whole precondition. Learn more about the opening scene · what addition is














Key Terms

Matrix addition — combining two matrices of the same shape into a third matrix by adding paired entries: ci,j=ai,j+bi,jc_{i,j} = a_{i,j} + b_{i,j}.

Matrix subtraction — combining two matrices of the same shape by subtracting paired entries: ci,j=ai,j−bi,jc_{i,j} = a_{i,j} - b_{i,j}.

Element-wise operation — an operation applied independently to each entry; the result at position (i,j)(i,j) depends only on the inputs at position (i,j)(i,j).

Same-shape requirement — both operand matrices must have identical row and column counts. A 2×32 \times 3 matrix cannot be added to a 3×23 \times 2 matrix.

Result shape — the output matrix CC inherits the shape of the operands. If AA and BB are m×nm \times n, then CC is m×nm \times n.

Conformability — the condition under which an operation is defined. For addition and subtraction, conformability means matching dimensions.

Getting Started with the Visualizer

Choose an operation and a shape, then watch the result build up one cell at a time.

• Use the Operation segmented control to switch between A + B and A − B
• Set the shared shape of AA and BB with the Dimensions steppers — rows and columns each range from 1 to 5
• Click play on the scene player to step through each cell of CC, or use the speed selector to slow down or speed up the animation

The hover ? icon next to the dimensions label explains why AA and BB must share the same shape. Because the operation is element-wise, no other configuration is needed — the visualizer fully determines the symbolic flow from the operation and shape alone.

Reading the Scene Player

Each scene focuses on a single cell of CC and shows three pieces of information at once.

• Highlighted cells — the active cell in AA is colored as primary, the matching cell in BB as secondary, and the destination cell in CC as accent
• Curved arrows — two arrows flow from ai,ja_{i,j} and bi,jb_{i,j} into ci,jc_{i,j}, making the data flow explicit
• Formula caption — the title shows the cell-level equation, for example c2,3=a2,3+b2,3c_{2,3} = a_{2,3} + b_{2,3}
• Step log — a running record of completed steps appears below the matrices, so you can scroll back through what has been filled in

By the final scene, every cell of CC holds its symbolic sum or difference and the matrices visualize the complete operation.

The Opening Scene: Two Matrices of the Same Shape

The player starts with AA and BB side by side and CC waiting empty on the right. At the default dimensions all three are 2×32 \times 3, and every cell of CC shows a placeholder rather than a value.

Nothing has been computed yet. What the scene establishes is the precondition: AA and BB have identical dimensions, so there is a cell of BB sitting opposite every cell of AA.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3+B2×3b1,1b1,2b1,3b2,1b2,2b2,3=C2×3??????
Opening scene, frozen

A and B at 2×3 with C empty beside them. Every cell of C shows the placeholder, and the matching dimensions are the only thing established so far.

That pairing is the whole reason the same-shape rule exists. Addition is defined entry by entry, so it needs a partner for each entry — and a 2×32 \times 3 matrix simply has no entry to pair with the [3,1][3,1] entry of a 3×33 \times 3 one.

The result CC is created at the same shape as its inputs, which is worth stating explicitly: addition never changes dimensions. That is unlike multiplication, where a 2×32 \times 3 times a 3×43 \times 4 produces a 2×42 \times 4.

One Cell at a Time

Each step highlights one cell of AA, the cell directly opposite it in BB, and the destination cell in CC, then writes ai,j+bi,ja_{i,j} + b_{i,j} into that destination.

The frozen picture below is a step partway through the 2×32 \times 3 run: some cells of CC already hold their sum, one pair is being combined now, and the rest are still placeholders.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3+B2×3b1,1b1,2b1,3b2,1b2,2b2,3=C2×3a1,1+b1,1a1,2+b1,2a1,3+b1,3a2,1+b2,1a2,2+b2,2?
Mid-sweep, frozen

One cell of A, the cell opposite it in B, and the destination in C are highlighted together. Earlier cells of C already read a + b; later ones are still placeholders.

Notice what the sweep never does: it never looks at a cell of BB that sits somewhere else. The entry b2,3b_{2,3} can only ever meet a2,3a_{2,3}. There is no mixing across positions, no row-times-column pairing, nothing resembling the machinery of matrix multiplication.

That independence has a practical consequence. Because no cell's result depends on any other cell's result, the six steps could run in any order — or all at once. The left-to-right sweep is a teaching device, not an algorithm the operation requires.

The Completed Sum

The final scene fills every cell of CC, so the whole matrix reads ci,j=ai,j+bi,jc_{i,j} = a_{i,j} + b_{i,j} across all six positions.

CC has exactly the shape it started with, 2×32 \times 3, and each of its entries depends on precisely two numbers.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3+B2×3b1,1b1,2b1,3b2,1b2,2b2,3=C2×3a1,1+b1,1a1,2+b1,2a1,3+b1,3a2,1+b2,1a2,2+b2,2a2,3+b2,3
Completed sum, frozen

All six cells of C filled, each holding the sum of the two entries directly above it. C is 2×3, the same shape it started as.

From the completed picture the algebraic properties are easy to believe. Addition is commutative, A+B=B+AA + B = B + A, because each cell reduces to an ordinary sum of two numbers and those commute. It is associative for the same reason. The zero matrix acts as an identity, and −A-A — negate every entry — is an additive inverse.

Every one of those follows from the entrywise definition rather than from anything matrix-specific. Matrix addition inherits its structure wholesale from the arithmetic of its entries, which is exactly why it is the easiest matrix operation to reason about.

Switching to Subtraction

The operation toggle replaces every ++ with a −-, and nothing else about the run changes: same shapes, same pairing, same one-cell-at-a-time sweep, with each destination now reading ai,j−bi,ja_{i,j} - b_{i,j}.

The still below is the subtraction run at the same point in the sweep, so it can be compared directly against the addition step above.
A2×3a1,1a1,2a1,3a2,1a2,2a2,3−B2×3b1,1b1,2b1,3b2,1b2,2b2,3=C2×3a1,1−b1,1a1,2−b1,2a1,3−b1,3a2,1−b2,1a2,2−b2,2?
Subtraction, same point in the sweep

Identical choreography with the operator flipped: each destination cell now reads a - b. Shapes and pairing are unchanged.

Subtraction is not really a separate operation. A−BA - B is defined as A+(−B)A + (-B), where −B-B negates every entry, so the toggle is shorthand for negating one input and reusing addition.

That framing explains which properties survive and which do not. Subtraction is not commutative — A−BA - B and B−AB - A differ by a sign in every entry — and it is not associative either. The same-shape requirement is untouched, because the pairing argument never depended on which sign sits between the two entries.

Switching Between Addition and Subtraction

The operation toggle changes both the symbol in the equation and the contents of each cell of CC.

• Selecting A + B displays ci,j=ai,j+bi,jc_{i,j} = a_{i,j} + b_{i,j} in every filled cell
• Selecting A − B displays ci,j=ai,j−bi,jc_{i,j} = a_{i,j} - b_{i,j} in every filled cell
• The intro and outro scene captions update to use the words "addition" or "subtraction" accordingly
• The per-cell scene titles also update their operator

Toggling the operation rebuilds the full sequence of scenes, so you can compare how addition and subtraction differ purely in operator while sharing the exact same element-wise structure.

Choosing Dimensions

The dimension steppers control the shape shared by all three matrices. Because AA, BB, and CC are linked, changing rows or columns updates all of them at once.

• Start with a small shape like 2×22 \times 2 or 2×32 \times 3 to see the per-cell flow clearly
• Increase to 4×44 \times 4 or 5×55 \times 5 to see how the same rule scales — the number of scenes grows as m×nm \times n
• Symbolic cell contents in CC shrink automatically when the matrix is larger, so ai,j+bi,ja_{i,j} + b_{i,j} stays readable even at 5×55 \times 5
• A square shape (n×nn \times n) and a rectangular shape (m×nm \times n, m≠nm \neq n) follow the same rule, since dimensions never need to match across rows and columns for addition

There is no separate control for CC because its shape is forced by the operation.

What Matrix Addition Is

Matrix addition pairs up corresponding entries of two matrices and sums them. If AA and BB are both m×nm \times n matrices, then A+BA + B is also m×nm \times n, and its entry at row ii, column jj is

ci,j=ai,j+bi,jc_{i,j} = a_{i,j} + b_{i,j}


This makes matrix addition an element-wise operation: each entry of the result depends only on the matching entries in AA and BB, not on anything else in either matrix.

Matrix subtraction works identically, with subtraction replacing addition. The same-shape requirement is what makes the operation well-defined — without matched dimensions, there is no notion of "corresponding entry."

For a comprehensive treatment of matrix operations and properties, see matrix operations theory.

Key Formulas

The full definition of matrix addition for m×nm \times n matrices AA and BB:

A+B=C,ci,j=ai,j+bi,j for all 1≤i≤m, 1≤j≤nA + B = C, \quad c_{i,j} = a_{i,j} + b_{i,j} \text{ for all } 1 \leq i \leq m, \, 1 \leq j \leq n


Matrix subtraction:

A−B=C,ci,j=ai,j−bi,jA - B = C, \quad c_{i,j} = a_{i,j} - b_{i,j}


Matrix addition satisfies the same algebraic properties as ordinary addition:

• Commutativity: A+B=B+AA + B = B + A
• Associativity: (A+B)+C=A+(B+C)(A + B) + C = A + (B + C)
• Identity: A+0=AA + 0 = A, where 00 is the zero matrix of the same shape
• Inverse: A+(−A)=0A + (-A) = 0

Subtraction is neither commutative nor associative, just like with scalars.

Why the Same-Shape Rule Matters

Matrix addition is only defined when both operands have identical dimensions. This rule is not arbitrary — it follows directly from the element-wise definition.

If AA is 2×32 \times 3 and BB is 2×42 \times 4, then a1,4a_{1,4} does not exist while b1,4b_{1,4} does. There is no entry in AA to pair with b1,4b_{1,4}, so the sum at that position is undefined. The same problem arises for any mismatch in rows or columns.

This is fundamentally different from matrix multiplication, where the inner dimensions must match but the outer dimensions can differ. Addition demands strict equality of shape; multiplication allows asymmetry.

For comparison with matrix multiplication and other operations, see matrix multiplication.

Common Mistakes

Even though matrix addition is among the simplest matrix operations, a few mistakes appear regularly.

• Trying to add matrices of different shapes — a 2×32 \times 3 and a 3×23 \times 2 cannot be added even though both have six entries
• Adding a scalar to a matrix as if it were a matrix — adding a scalar kk to AA means adding kk to every entry, which is technically scalar shifting, not matrix addition
• Confusing element-wise multiplication with matrix multiplication — element-wise (Hadamard) product also requires matching shapes, but standard matrix multiplication does not
• Forgetting that subtraction is not commutative — A−B≠B−AA - B \neq B - A in general
• Mixing row vectors and column vectors — a 1×n1 \times n row vector cannot be added to an n×1n \times 1 column vector even when they have the same number of entries

Worked Example

Take AA and BB as 2×32 \times 3 matrices:

A=(123456),B=(789012)A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}, \quad B = \begin{pmatrix} 7 & 8 & 9 \\ 0 & 1 & 2 \end{pmatrix}


Then C=A+BC = A + B is computed cell by cell:

C=(1+72+83+94+05+16+2)=(81012468)C = \begin{pmatrix} 1+7 & 2+8 & 3+9 \\ 4+0 & 5+1 & 6+2 \end{pmatrix} = \begin{pmatrix} 8 & 10 & 12 \\ 4 & 6 & 8 \end{pmatrix}


For D=A−BD = A - B:

D=(1−72−83−94−05−16−2)=(−6−6−6464)D = \begin{pmatrix} 1-7 & 2-8 & 3-9 \\ 4-0 & 5-1 & 6-2 \end{pmatrix} = \begin{pmatrix} -6 & -6 & -6 \\ 4 & 6 & 4 \end{pmatrix}


The visualizer above mirrors this process symbolically — set the dimensions to 2×32 \times 3 and step through to see each pairing in turn.