Mathwords logoMathwords

Hadamard Product — Definition, Formula & Example

The Hadamard product is a way to multiply two matrices of the same size by multiplying the entries in matching positions. The result is a new matrix of that same size. It is also called the Schur product or the elementwise product.

For A=[aij]A = [a_{ij}] and B=[bij]B = [b_{ij}], both m×nm \times n, the Hadamard product A∘BA \circ B (also written A⊙BA \odot B) is the m×nm \times n matrix with entries (A∘B)ij=aijbij(A \circ B)_{ij} = a_{ij}b_{ij}. The operation is commutative, associative, and distributive over matrix addition. Its identity is the all-ones matrix JJ, not the identity matrix II. The matrix A∘BA \circ B appears inside the Kronecker product A⊗BA \otimes B as a submatrix. The Schur product theorem states that if AA and BB are positive semidefinite, then so is A∘BA \circ B.

Key Formula

(A∘B)ij=aij bij,1≤i≤m,  1≤j≤n(A \circ B)_{ij} = a_{ij}\,b_{ij}, \qquad 1 \le i \le m,\; 1 \le j \le n
Where:
  • A,BA, B = Two matrices with the same dimensions, m rows by n columns
  • aij,bija_{ij}, b_{ij} = The entries in row i, column j of A and of B
  • (A∘B)ij(A \circ B)_{ij} = The entry in row i, column j of the Hadamard product

Worked Example

Problem: Let A=(2−135)A = \begin{pmatrix} 2 & -1 \\ 3 & 5 \end{pmatrix} and B=(4602)B = \begin{pmatrix} 4 & 6 \\ 0 & 2 \end{pmatrix}. Find A∘BA \circ B, and compare it with the ordinary matrix product ABAB.
Step 1: Multiply the entries that sit in the same position. Nothing is summed.
A∘B=(2⋅4(−1)⋅63⋅05⋅2)=(8−6010)A \circ B = \begin{pmatrix} 2\cdot 4 & (-1)\cdot 6 \\ 3\cdot 0 & 5\cdot 2 \end{pmatrix} = \begin{pmatrix} 8 & -6 \\ 0 & 10 \end{pmatrix}
Step 2: For contrast, compute the ordinary product. Each entry is a row of A times a column of B, added up.
AB=(2⋅4+(−1)⋅02⋅6+(−1)⋅23⋅4+5⋅03⋅6+5⋅2)=(8101228)AB = \begin{pmatrix} 2\cdot4 + (-1)\cdot0 & 2\cdot6 + (-1)\cdot2 \\ 3\cdot4 + 5\cdot0 & 3\cdot6 + 5\cdot2 \end{pmatrix} = \begin{pmatrix} 8 & 10 \\ 12 & 28 \end{pmatrix}
Answer: A∘B=(8−6010)A \circ B = \begin{pmatrix} 8 & -6 \\ 0 & 10 \end{pmatrix}. The ordinary product is AB=(8101228)AB = \begin{pmatrix} 8 & 10 \\ 12 & 28 \end{pmatrix}, so the two operations give different matrices.

Why It Matters

In machine learning, the gates of an LSTM neural network and the masks applied to images are Hadamard products: each entry is scaled or switched off independently of the others. In statistics and kernel methods, the Schur product theorem guarantees that multiplying two valid covariance matrices entry by entry gives another valid covariance matrix.

Common Mistakes

Mistake: Treating A∘BA \circ B like ordinary matrix multiplication, or trying to compute it for a 2×32 \times 3 matrix and a 3×23 \times 2 matrix.
Correction: The Hadamard product requires identical dimensions, and each output entry uses only one pair of numbers. Ordinary multiplication requires the number of columns of A to equal the number of rows of B, and each entry is a sum of row-times-column products.

Related Terms

  • Kronecker Product — Builds a larger block matrix; contains the Hadamard product as a submatrix
  • Compatible Matrices — Size rule for ordinary multiplication, unlike Hadamard's same-size rule
  • Dot Product — Equals the sum of entries of two vectors' Hadamard product
  • Inner Product — Frobenius inner product sums the Hadamard product's entries
  • Product — The scalar multiplication applied at each matrix position
  • Matrix Multiplication — Different, row-by-column way to multiply matrices
  • Matrix Addition — Another entry-by-entry operation on same-size matrices