acalculator

What is the dot product?

Free online matrix dot product calculator: it multiplies two matrices, and a row times a column gives the dot product of two vectors. Fast, accurate, and easy to use math tool.

Your numbers

Matrix A
Matrix B
Give B as many rows as A has columns.
A × B
[19, 22; 43, 50]

A × B = [19, 22; 43, 50].

Size of A × B
2×2
Working
c1,1 = 1×5 + 2×7 = 19; c1,2 = 1×6 + 2×8 = 22; c2,1 = 3×5 + 4×7 = 43; c2,2 = 3×6 + 4×8 = 50

A × B: [19, 22; 43, 50]. A × B = [19, 22; 43, 50].

How it is worked out

How to calculate

Multiplies matrix A by matrix B: each entry of A × B is the dot product of a row of A with a column of B, and a 1 × n row times an n × 1 column gives the vector dot product.

Example with the default inputs (Matrix A [1, 2; 3, 4], Matrix B [5, 6; 7, 8]): A × B = [19, 22; 43, 50].

Method: The entry in row i, column j of A × B is the dot product of row i of A with column j of B: cᵢⱼ = Σₖ aᵢₖbₖⱼ.

  • A has m rows and n columns, B has n rows and p columns, so A × B has m rows and p columns (1 to 10 each).
  • A 1 × n matrix A times an n × 1 matrix B is the vector dot product a₁b₁ + … + aₙbₙ.
  • The product text rounds each number to 10 significant figures; the dot product is shown at full precision.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Matrix A 1, 2; 3, 4, Matrix B 5, 6; 7, 8 gives A × B [19, 22; 43, 50], Size of A × B 2×2.Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
  2. Matrix A 1, 2, 3, Matrix B 4; 5; 6 gives Dot product 32, A × B [32], Size of A × B 1×1.Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
  3. Matrix A 1, 2, 3; 4, 5, 6, Matrix B 7, 8; 9, 10; 11, 12 gives A × B [58, 64; 139, 154], Size of A × B 2×2.Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
  4. Matrix A -1.5, 2, Matrix B 4; 0.5 gives Dot product -5.Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product

How it works

The calculator multiplies matrix A (m rows, n columns) by matrix B (n rows, p columns). The result C = A × B has m rows and p columns. Each entry is the dot product of a row of A with a column of B:

cᵢⱼ = aᵢ₁b₁ⱼ + aᵢ₂b₂ⱼ + … + aᵢₙbₙⱼ

Vector dot product. When A is one row (1 × n) and B is one column (n × 1), the result is a single number, a₁b₁ + a₂b₂ + … + aₙbₙ. This is the dot product of the two vectors, and the page shows it as Dot product.

The page shows:

  • A × B: the product matrix, written row by row, rows separated by semicolons and numbers by commas, for example [19, 22; 43, 50]. Each number in this text is rounded to 10 significant figures, with no thousands separators or trailing zeros. Numbers of 10²¹ or more, or under 10⁻⁶ (other than 0), are written in e-notation, for example 1.4e+22 or 1.5e-7.
  • Dot product: the full-precision value, only when the result is 1 × 1.
  • Size of A × B: rows × columns, for example 2×2.
  • Working: each entry as a row of A times a column of B, for the first 25 entries. A negative factor is in brackets: 1×(-1) + (-2)×2 = -5. A larger product ends with "and N more entries the same way", where N is the number of entries not listed. The same text is listed step by step under "How it is worked out".

Assumptions

  • Each matrix has 1 to 10 rows and 1 to 10 columns, with real numbers.
  • The columns of A must equal the rows of B. When they do not match, there is no answer, and the page names both sizes. Nothing is added to or dropped from either matrix.
  • Old links from the previous version of this page (rowsA, colsA, rowsB, colsB, and cells a00 to b99) still open the same matrices. A missing cell counts as 0.

Worked examples by hand

The default matrices. A = [1, 2; 3, 4], B = [5, 6; 7, 8].

  • c₁₁ = 1×5 + 2×7 = 5 + 14 = 19
  • c₁₂ = 1×6 + 2×8 = 6 + 16 = 22
  • c₂₁ = 3×5 + 4×7 = 15 + 28 = 43
  • c₂₂ = 3×6 + 4×8 = 18 + 32 = 50

So A × B = [19, 22; 43, 50].

Two vectors. A = [1, 2, 3] (1 × 3) and B = [4; 5; 6] (3 × 1). The dot product is 1×4 + 2×5 + 3×6 = 4 + 10 + 18 = 32.

A 2 × 3 times a 3 × 2 matrix. A = [1, 2, 3; 4, 5, 6], B = [7, 8; 9, 10; 11, 12].

  • c₁₁ = 1×7 + 2×9 + 3×11 = 58; c₁₂ = 1×8 + 2×10 + 3×12 = 64
  • c₂₁ = 4×7 + 5×9 + 6×11 = 139; c₂₂ = 4×8 + 5×10 + 6×12 = 154

So A × B = [58, 64; 139, 154].

Decimals. A = [−1.5, 2], B = [4; 0.5]: −1.5×4 + 2×0.5 = −6 + 1 = −5.

Other questions people ask

What is matrix dot product (matrix multiplication)?

Matrix dot product, also called matrix multiplication, is a fundamental operation in linear algebra where two matrices are combined to produce a third matrix. For matrices A and B, the dot product A × B is defined only when the number of columns in A equals the number of rows in B. The result is a matrix with the same number of rows as A and the same number of columns as B.

How do I know if two matrices can be multiplied?

Two matrices A and B can be multiplied (A × B) if and only if the number of columns in matrix A equals the number of rows in matrix B. For example, if A is a 3×4 matrix and B is a 4×2 matrix, they can be multiplied because A has 4 columns and B has 4 rows. The result will be a 3×2 matrix.

What is the formula for matrix multiplication?

For matrices A (m×n) and B (n×p), the element at position [i,j] in the result matrix C = A × B is calculated as: C[i,j] = Σ(A[i,k] × B[k,j]) for k = 1 to n. This means you multiply each element of row i from A by the corresponding element of column j from B, then sum all the products.

Is matrix multiplication commutative?

No, matrix multiplication is not commutative in general. This means A × B ≠ B × A for most matrices. Even when both products are defined, they often produce different results. For example, if A is 2×3 and B is 3×2, then A × B is 2×2 but B × A is 3×3.

What are some real-world applications of matrix multiplication?

Matrix multiplication is used in computer graphics (transformations, rotations), machine learning (neural networks, data processing), physics (quantum mechanics, mechanics), economics (input-output models), cryptography (encryption algorithms), and many other fields where linear transformations and systems of equations are important.

How do I calculate the dot product of vectors using matrix multiplication?

Treat the first vector as a 1×n row matrix A and the second as an n×1 column matrix B. Their product is a 1×1 matrix, a single number, which is the dot product. For example, vectors [a,b,c] and [x,y,z] have dot product a×x + b×y + c×z. Set Matrix A to 1 row and Matrix B to 1 column to get it.

What if I get an error about matrix dimensions not matching?

The number of columns in Matrix A must equal the number of rows in Matrix B. When they do not match, the page says so (for example, A has 2 columns but B has 3 rows) and gives no answer; set the Rows of Matrix B to the Columns of Matrix A.