Understanding science, for all. Home About
Novadette› ∑ Mathematics› Linear Algebra› Matrix Calculator› Two matrices
∑ Linear Algebra

Matrix Multiplication & Addition

Multiply, add or subtract two matrices of any size up to 6×6, with every entry worked out: row times column for a product, entry by entry for a sum. Fractions stay exact, and the picture shows which row and column make each entry — click an entry of the result to see its calculation.

Matrix productMatrix sumLinear AlgebraSteps
Inputs
Input examples
Operation
Matrix A×
Matrix B×
Entries can be whole numbers, decimals or fractions (1/3), which stay exact, or expressions such as sqrt(2). For A × B the number of columns of A must equal the number of rows of B; for A + B both must have the same size.

How Do You Multiply Matrices?

Each entry of the product AB comes from one row of A and one column of B: multiply them entry by entry and add up. Entry (1, 2) of AB is row 1 of A “dotted” with column 2 of B. That is why the rows of A must be as long as the columns of B: an m×n matrix times an n×p matrix gives an m×p matrix.

The order matters: in general AB ≠ BA, and BA may not even exist. Adding and subtracting are simpler: they work entry by entry and need two matrices of the same size.

(m×n)(n×p)= an m×p matrix
AB ≠ BAthe order matters
A + Bneeds the same size
AI = Athe identity changes nothing

Entry by Entry

entry
Result
Enter two matrices above

Step-by-Step Solution

    All Combinations

    Sources & Verification

    References
    1. G. Strang, Introduction to Linear Algebra, 5th ed., Wellesley-Cambridge Press, 2016 — Sec. 2.4 (rules for matrix operations).
    2. D. C. Lay, S. R. Lay & J. J. McDonald, Linear Algebra and Its Applications, 5th ed., Pearson, 2016 — Sec. 2.1 (matrix operations).

    Frequently Asked Questions

    How do you multiply two matrices?

    Every entry of the product is a row of the first matrix times a column of the second: multiply entry by entry and add up. Example: [[1, 2], [3, 4]] × [[5, 6], [7, 8]].

    1. Entry (1, 1): row 1 times column 1 = 1 · 5 + 2 · 7 = 19.

    2. Entry (1, 2): row 1 times column 2 = 1 · 6 + 2 · 8 = 22.

    3. Entry (2, 1): 3 · 5 + 4 · 7 = 43, and entry (2, 2): 3 · 6 + 4 · 8 = 50.

    So the product is [[19, 22], [43, 50]].

    When can two matrices be multiplied?

    When the number of columns of the first equals the number of rows of the second. An m×n matrix times an n×p matrix gives an m×p matrix: a 2×3 matrix times a 3×2 matrix is 2×2, while the other order, 3×2 times 2×3, is 3×3. A 2×3 matrix times a 2×2 matrix is not defined: 3 columns do not meet 2 rows.

    Is AB the same as BA?

    Usually not: matrix multiplication is not commutative. [[1, 2], [3, 4]] × [[5, 6], [7, 8]] = [[19, 22], [43, 50]], but in the other order the product is [[23, 34], [31, 46]]. Sometimes BA does not even exist while AB does.

    How do you add or subtract matrices?

    Entry by entry, and only when both matrices have the same size. [[1, 2, 3], [4, 5, 6]] + [[6, 5, 4], [3, 2, 1]] = [[7, 7, 7], [7, 7, 7]], and [[5, 7], [1, 0]] − [[2, 3], [4, 1]] = [[3, 4], [−3, −1]].

    What happens when you multiply a matrix by a vector?

    A vector is a matrix with one column, so the same rule applies, and the matrix transforms the vector. [[0, −1], [1, 0]] times the vector (3, 1) gives (−1, 3): the vector is rotated 90° counter-clockwise. That is why matrices describe rotations, reflections and scalings in graphics and physics.