How the Hadamard Product works
The Hadamard product (also called the Schur product or entrywise product) combines two matrices of identical dimensions by multiplying each pair of corresponding entries. For matrices A and B that are both m × n, the Hadamard product A∘B is also m × n, defined entry-by-entry as (A∘B)ij = Aij × Bij. This calculator parses the two matrices you enter, checks that their dimensions match, and multiplies them element-wise to produce A∘B, along with its entry sum and Frobenius norm.
Formula and method
Every entry in the result matrix comes from multiplying the entry in the same row-and-column position from A and from B — there is no summing across a row or column, unlike standard matrix multiplication. Because the operation works position-by-position, A and B must have exactly the same number of rows and the same number of columns; neither matrix needs to be square. The Hadamard product is commutative (A∘B = B∘A), associative ((A∘B)∘C = A∘(B∘C)), and distributes over matrix addition (A∘(B+C) = A∘B + A∘C).
Hadamard product vs. matrix multiplication
Don't confuse the Hadamard product with standard matrix multiplication A×B, which requires the number of columns in A to equal the number of rows in B and computes each output entry as a dot product — a sum of pairwise products — across a row of A and a column of B. The Hadamard product instead requires identical dimensions in both matrices and never sums across positions; it is a simpler, purely elementwise operation, and the result is always the same size as the two inputs.
Common mistakes
- Mismatched dimensions: attempting A∘B when A is 2×3 and B is 3×2 — dimensions must match exactly, row-for-row and column-for-column.
- Confusing it with matrix multiplication: applying the row-by-column dot-product rule instead of simple position-by-position multiplication.
- Ragged rows: entering a matrix where one row has a different number of values than another — every row must have the same number of entries.
Applications
- Neural networks: gating mechanisms in LSTM and GRU networks, dropout masks, and attention mechanisms multiply activations elementwise using the Hadamard product.
- Image processing: applying a mask or filter to an image elementwise, such as blending or masking pixel intensities.
- Statistics: scaling a covariance or correlation matrix entrywise, or computing entrywise variances.
- Signal processing: windowing a signal by multiplying it elementwise with a window function.