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 and , both , the Hadamard product (also written ) is the matrix with entries . The operation is commutative, associative, and distributive over matrix addition. Its identity is the all-ones matrix , not the identity matrix . The matrix appears inside the Kronecker product as a submatrix. The Schur product theorem states that if and are positive semidefinite, then so is .
Key Formula
Where:
- = Two matrices with the same dimensions, m rows by n columns
- = The entries in row i, column j of A and of B
- = The entry in row i, column j of the Hadamard product
Worked Example
Problem: Let and . Find , and compare it with the ordinary matrix product .
Step 1: Multiply the entries that sit in the same position. Nothing is summed.
Step 2: For contrast, compute the ordinary product. Each entry is a row of A times a column of B, added up.
Answer: . The ordinary product is , 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 like ordinary matrix multiplication, or trying to compute it for a matrix and a 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.
