Last verified · v1.0
Calculator · math
Hadamard Product Calculator (2×2 Matrices)
Compute the Hadamard (element-wise) product of two 2×2 matrices by multiplying corresponding elements. Instant results with full matrix output.
Inputs
Hadamard Product Result
—
Explain my result
Get a plain-English breakdown of your result with practical next steps.
The formula
How the
result is
computed.
What Is the Hadamard Product?
The Hadamard product, also called the element-wise product or Schur product, is a binary operation on two matrices of identical dimensions that produces a third matrix of the same size. Each element of the result equals the product of the corresponding elements from the two input matrices. Named after French mathematician Jacques Hadamard, this operation is fundamental in linear algebra, signal processing, and machine learning.
The Hadamard Product Formula
For two matrices A and B of equal dimensions m×n, the Hadamard product is defined element-wise as:
(A ∘ B)ij = Aij · Bij
For two 2×2 matrices specifically, the complete output matrix is:
Given A = [[a11, a12], [a21, a22]] and B = [[b11, b12], [b21, b22]], the result is:
A ∘ B = [[a11·b11, a12·b12], [a21·b21, a22·b22]]
As documented in the UC Davis Mathematics Linear Algebra Glossary, the Hadamard product is entirely distinct from standard matrix multiplication and requires both input matrices to share identical dimensions.
Variables Defined
- a11: Element at row 1, column 1 of matrix A
- a12: Element at row 1, column 2 of matrix A
- a21: Element at row 2, column 1 of matrix A
- a22: Element at row 2, column 2 of matrix A
- b11: Element at row 1, column 1 of matrix B
- b12: Element at row 1, column 2 of matrix B
- b21: Element at row 2, column 1 of matrix B
- b22: Element at row 2, column 2 of matrix B
Step-by-Step Calculation for 2×2 Matrices
- Enter the four elements of matrix A: a11, a12, a21, a22.
- Enter the four elements of matrix B: b11, b12, b21, b22.
- Multiply each pair of corresponding elements: a11×b11, a12×b12, a21×b21, a22×b22.
- Arrange the four products into a 2×2 result matrix at their matching positions.
Worked Example
Let A = [[3, 1], [4, 2]] and B = [[5, 6], [0, 8]]. Applying the Hadamard product formula position by position:
- Position (1,1): 3 × 5 = 15
- Position (1,2): 1 × 6 = 6
- Position (2,1): 4 × 0 = 0
- Position (2,2): 2 × 8 = 16
Result: A ∘ B = [[15, 6], [0, 16]]
Key Properties of the Hadamard Product
- Commutativity: A ∘ B = B ∘ A — element-wise multiplication is order-independent.
- Associativity: (A ∘ B) ∘ C = A ∘ (B ∘ C) for matrices of identical dimensions.
- Distributivity over addition: A ∘ (B + C) = (A ∘ B) + (A ∘ C).
- Identity element: The all-ones matrix J satisfies A ∘ J = A.
- Zero element: The all-zeros matrix O satisfies A ∘ O = O for any matrix A.
Real-World Applications
The Hadamard product appears across a broad range of disciplines. Stanford CS231n lecture materials on backpropagation and gradients show how element-wise multiplication of activation and gradient matrices drives weight updates in neural networks, including LSTM gating mechanisms and transformer attention masks. Additional applications include:
- Image processing: Multiplying pixel intensity matrices by binary or weighted mask matrices to isolate regions of interest or apply convolution filters.
- Signal processing: Applying windowing functions element-by-element to time-domain signal vectors to reduce spectral leakage in fast Fourier transform (FFT) analysis.
- Genomics: Computing epistatic genomic relationship matrices via Hadamard products of SNP genotype matrices to model gene-gene interactions.
- Statistics: Scaling covariance matrices element-wise in weighted regression and variance component estimation.
According to The Matrix Cookbook, the Hadamard product satisfies the trace identity tr(AT(B ∘ C)) = tr((A ∘ B)TC), linking element-wise and standard matrix products in optimization and gradient derivations.
Reference