# What is the dot product?

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.

- Page: https://www.acalculator.org/math/dot-product-calculator
- JSON spec: https://www.acalculator.org/math/dot-product-calculator.json
- Version: 112a6ad95566

## Default answer

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

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| a | Matrix A | The first matrix, 1 to 10 rows and columns. |
| b | Matrix B | The second matrix. It needs as many rows as A has columns. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| product | A × B | The product matrix, rows separated by semicolons, each number rounded to 10 significant figures. |
| dot | Dot product | The single number of a 1 × 1 result: the dot product of the row A with the column B. |
| size | Size of A × B | Rows × columns of the product. |
| steps | Working | Each entry as a row of A times a column of B, for the first 25 entries. |

## 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ₖⱼ.

## Assumptions

- 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.

## Worked examples

1. a = 1 or 2 or 3 or 4, b = 5 or 6 or 7 or 8 gives product = [19, 22; 43, 50], size = 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. a = 1 or 2 or undefined, b = 4 or undefined or 5 or undefined gives dot = 32, product = [32], size = 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. a = 1 or 2 or 4 or 5, b = 7 or 8 or 9 or 10 gives product = [58, 64; 139, 154], size = 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. a = -1.5 or 2 or undefined, b = 4 or undefined or 0.5 or undefined gives dot = -5. Source: OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product.

## FAQ

### 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.

## Sources

- OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
