What is the Hadamard Product?
The Hadamard product, also called the element-wise or Schur product, multiplies two matrices of identical dimensions entry by entry. Unlike standard matrix multiplication, it does not combine rows and columns — instead each output element is simply the product of the two values in the same position. It is written \(A \circ B\) and is widely used in machine learning, signal processing, and image manipulation.
How to Use This Calculator
Set the number of rows and columns, then type the values of Matrix A and Matrix B. Put one matrix row on each line, separating numbers with spaces or commas. The calculator returns the resulting matrix where every entry equals \(A_{ij} \times B_{ij}\), plus the sum of all resulting elements.
The Formula Explained
For two \(m \times n\) matrices A and B, the Hadamard product \(C = A \circ B\) is the \(m \times n\) matrix defined by $$\left(\text{A} \circ \text{B}\right)_{ij} = A_{ij} \cdot B_{ij}\qquad 1 \le i \le \text{Rows},\; 1 \le j \le \text{Cols}$$ Both matrices must share the same shape; there is no row–column dot product as in ordinary multiplication.
Worked Example
Let \(A = [[1, 2], [3, 4]]\) and \(B = [[5, 6], [7, 8]]\). Then $$A \circ B = [[1\times5, 2\times6], [3\times7, 4\times8]] = [[5, 12], [21, 32]].$$ The sum of all elements is \(5 + 12 + 21 + 32 = 70\).
FAQ
How is it different from normal matrix multiplication? Matrix multiplication takes dot products of rows and columns and requires inner dimensions to match. The Hadamard product just multiplies aligned entries and requires identical dimensions.
What if my matrices are different sizes? The Hadamard product is only defined for equal-size matrices. This tool fills missing entries with 0 based on the dimensions you set.
Where is it used? Common in neural networks (e.g., gating, dropout masks), covariance computations, and pixel-wise image operations.