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.
Matrix addition — combining two matrices of the same shape into a third matrix by adding paired entries: ci,j=ai,j+bi,j.
Matrix subtraction — combining two matrices of the same shape by subtracting paired entries: ci,j=ai,j−bi,j.
Element-wise operation — an operation applied independently to each entry; the result at position (i,j) depends only on the inputs at position (i,j).
Same-shape requirement — both operand matrices must have identical row and column counts. A 2×3 matrix cannot be added to a 3×2 matrix.
Result shape — the output matrix C inherits the shape of the operands. If A and B are m×n, then C is m×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 A and B 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 C, or use the speed selector to slow down or speed up the animation
The hover ? icon next to the dimensions label explains why A and B 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 C and shows three pieces of information at once.
• Highlighted cells — the active cell in A is colored as primary, the matching cell in B as secondary, and the destination cell in C as accent • Curved arrows — two arrows flow from ai,j and bi,j into ci,j, making the data flow explicit • Formula caption — the title shows the cell-level equation, for example c2,3=a2,3+b2,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 C 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 A and B side by side and C waiting empty on the right. At the default dimensions all three are 2×3, and every cell of C shows a placeholder rather than a value.
Nothing has been computed yet. What the scene establishes is the precondition: A and B have identical dimensions, so there is a cell of B sitting opposite every cell of A.
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×3 matrix simply has no entry to pair with the [3,1] entry of a 3×3 one.
The result C 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×3 times a 3×4 produces a 2×4.
One Cell at a Time
Each step highlights one cell of A, the cell directly opposite it in B, and the destination cell in C, then writes ai,j+bi,j into that destination.
The frozen picture below is a step partway through the 2×3 run: some cells of C already hold their sum, one pair is being combined now, and the rest are still placeholders.
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 B that sits somewhere else. The entry b2,3 can only ever meet a2,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 C, so the whole matrix reads ci,j=ai,j+bi,j across all six positions.
C has exactly the shape it started with, 2×3, and each of its entries depends on precisely two numbers.
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+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 — 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,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.
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−B is defined as A+(−B), where −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−B and B−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 C.
• Selecting A + B displays ci,j=ai,j+bi,j in every filled cell • Selecting A − B displays ci,j=ai,j−bi,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 A, B, and C are linked, changing rows or columns updates all of them at once.
• Start with a small shape like 2×2 or 2×3 to see the per-cell flow clearly • Increase to 4×4 or 5×5 to see how the same rule scales — the number of scenes grows as m×n • Symbolic cell contents in C shrink automatically when the matrix is larger, so ai,j+bi,j stays readable even at 5×5 • A square shape (n×n) and a rectangular shape (m×n, m=n) follow the same rule, since dimensions never need to match across rows and columns for addition
There is no separate control for C 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 A and B are both m×n matrices, then A+B is also m×n, and its entry at row i, column j is
ci,j=ai,j+bi,j
This makes matrix addition an element-wise operation: each entry of the result depends only on the matching entries in A and B, 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×n matrices A and B:
A+B=C,ci,j=ai,j+bi,j for all 1≤i≤m,1≤j≤n
Matrix subtraction:
A−B=C,ci,j=ai,j−bi,j
Matrix addition satisfies the same algebraic properties as ordinary addition:
• Commutativity: A+B=B+A • Associativity: (A+B)+C=A+(B+C) • Identity: A+0=A, where 0 is the zero matrix of the same shape • Inverse: A+(−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 A is 2×3 and B is 2×4, then a1,4 does not exist while b1,4 does. There is no entry in A to pair with b1,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×3 and a 3×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 k to A means adding k 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−A in general • Mixing row vectors and column vectors — a 1×n row vector cannot be added to an n×1 column vector even when they have the same number of entries
Worked Example
Take A and B as 2×3 matrices:
A=(142536),B=(708192)
Then C=A+B is computed cell by cell:
C=(1+74+02+85+13+96+2)=(84106128)
For D=A−B:
D=(1−74−02−85−13−96−2)=(−64−66−64)
The visualizer above mirrors this process symbolically — set the dimensions to 2×3 and step through to see each pairing in turn.
Related Concepts
Matrix operations — the broader family that includes addition, subtraction, multiplication, transposition, and inversion.
Scalar multiplication — multiplying every entry of a matrix by a number; like addition, it is element-wise and preserves shape.
Matrix multiplication — a non-element-wise operation with different conformability rules and very different geometric meaning.
Hadamard product — element-wise multiplication of two matrices of the same shape, the multiplicative analogue of matrix addition.
Vector addition — the special case where both matrices are row or column vectors; the same element-wise rule applies.
Zero matrix — the additive identity, with every entry equal to zero.
Transpose — reflecting a matrix across its main diagonal; useful when combining matrices of incompatible shapes through related operations.