Understanding matrix addition and multiplication
A matrix is a rectangle of numbers, and a 2 × 2 matrix is the smallest one that is still interesting: four numbers arranged in two rows and two columns. Matrices show up wherever several quantities move together — rotating a shape on a screen, solving two equations at once, or tracking how two things change in step. The four numbers look plain, but the rules for combining them are not the rules of ordinary arithmetic, and that is where most mistakes happen.
Formula and method
C(i, j) = Σ A(i, k) × B(k, j), so C = [[a×e + b×g, a×f + b×h], [c×e + d×g, c×f + d×h]]
A and B — the two 2 × 2 matrices, each entered as four comma-separated values in row order
Addition (entry by entry): Multiplication (row by column): a, b, c, d — the entries of the first matrix: a top-left, b top-right, c bottom-left, d bottom-right. e, f, g, h — the entries of the second matrix, in the same positions. C(i, j) — the entry in row i, column j of the product, combining row i of A with column j of B. Why addition is simple and multiplication is not. Addition never mixes positions: the top-left entry of the sum only ever involves the two top-left entries, and the same holds for the other three. Multiplication mixes them deliberately. The top-left entry of the product takes the first row of A, 1 and 2 in the live example, and the first column of B, 5 and 7, and forms 1 × 5 + 2 × 7 = 19. Every entry of the product is that kind of combination — a row meeting a column, multiplied pair by pair, added up. Reading the result. The answer is itself a 2 × 2 matrix, written in the same row order as the inputs: the first two numbers are the top row, the last two are the bottom row. For the live example the addition gives 6, 8 on the top row and 10, 12 on the bottom row.
Worked example
Example 1 — Adding A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]] (the live-page example) Matrix A entered as 1,2,3,4 and matrix B as 5,6,7,8, with the operation Addition. Top-left: 1 + 5 = 6 Top-right: 2 + 6 = 8 Bottom-left: 3 + 7 = 10 Bottom-right: 4 + 8 = 12 Result matrix: 6, 8 / 10, 12 This is the stored example on the live page, and the arithmetic above reproduces it. Each entry of the answer comes from exactly one pair of entries in the same position, which is the whole rule for addition: nothing crosses over, nothing is mixed. The result is written as two rows, 6 and 8 on top, 10 and 12 below, matching the layout of the inputs.