Hadamard積計算器:逐元素相乘
逐元素相乘兩個向量,快速驗證長度並查看結果。
Hadamard積計算器:逐元素相乘
逐元素相乘兩個向量,快速驗證長度並查看結果。
About the Hadamard product calculator
The Hadamard product is the simplest way to multiply two vectors or matrices when you want corresponding entries to interact directly. Instead of combining rows and columns the way standard matrix multiplication does, the Hadamard product pairs the first value with the first value, the second with the second, and so on. For vectors A = [a1, a2, a3] and B = [b1, b2, b3], the result is [a1×b1, a2×b2, a3×b3]. This calculator focuses on that exact operation for one-dimensional vectors.
Element-wise multiplication appears everywhere once you start looking for it. In statistics and data science, it is used when scaling feature vectors or applying weights to observations. In signal processing, it can represent point-by-point modulation of sampled data. In machine learning, the Hadamard product shows up in attention masks, gating mechanisms, and neural-network operations where one vector selectively amplifies or suppresses another. In finance, you might use it to multiply unit holdings by per-asset returns or prices to inspect contribution by position before summing anything.
One important detail is that the two vectors must have the same length. Because each output entry needs one value from the first vector and one value from the second vector, there must be a perfect one-to-one pairing across the whole sequence. If one vector has four values and the other has three, the operation is undefined. That is why the calculator validates matching lengths before producing a result.
This is also a good place to distinguish the Hadamard product from the dot product. A dot product multiplies corresponding entries and then adds the products to produce a single scalar. The Hadamard product stops one step earlier and returns the full vector of pairwise products. If you later want the dot product, you could sum the entries of the Hadamard result. Keeping the intermediate vector is useful because it shows how each position contributes.
Because the inputs accept comma-separated or space-separated numbers, you can paste values from spreadsheets, notes, or code with minimal cleanup. Use the tool whenever you need a fast, transparent way to inspect element-wise multiplication without writing a script or opening a larger numerical package.
Hadamard product examples
These examples show how element-wise multiplication preserves vector length and multiplies matching positions only.
| Input | Output | Notes |
|---|---|---|
| A = [1, 2, 3], B = [4, 5, 6] | [4, 10, 18] | Multiply each pair in place: 1×4, 2×5, and 3×6. The result stays a three-entry vector. |
| A = [2, -1, 0.5], B = [3, 8, 10] | [6, -8, 5] | Negative and decimal values work naturally. Each sign and magnitude is determined independently at its matching position. |
| A = [0, 7, 9], B = [12, 2, -3] | [0, 14, -27] | A zero in either vector forces that output entry to zero, which is useful when applying masks or switches. |
How to use the Hadamard product calculator
- Enter the first vector in the top field using commas or spaces between numbers.
- Enter the second vector with the same number of values as the first vector.
- Click "Calculate Hadamard Product" to compute the element-wise products.
- Use "Reset" to clear both vectors and start a new calculation.
Hadamard product FAQ
What is the Hadamard product?
The Hadamard product multiplies corresponding entries of two vectors or matrices of the same shape. It is different from ordinary matrix multiplication because it does not mix rows and columns; every output position depends only on the matching input positions.
Why must the vectors have the same length?
Each result entry needs exactly one value from the first vector and one from the second vector. If the lengths differ, there is no consistent way to pair every value, so the operation is undefined.
How is this different from the dot product?
The dot product multiplies matching entries and then adds them to produce a single number. The Hadamard product stops before the sum and returns the full vector of pairwise products, which is often more informative.
Where is element-wise multiplication used in practice?
It is common in data science, graphics, physics simulations, and machine learning whenever one vector acts as a mask, weight set, or gate for another. It is also useful in spreadsheets and quick numerical checks because you can see each contribution separately before any aggregation.
相關工具
負對數計算機:任意底數 −log(x)
計算 pH、資訊量和自訂底數的 −log_b(x)。支援底數 10、2、e 及所有不等於 1 的正底數,快速取得精確結果。
工具計算器:健康與規劃
使用點積公式計算兩個向量之間的夾角,支援 2D 和 3D 向量,即時顯示度數、弧度、向量長度、點積與餘弦值,步驟清楚且結果準確。
工具計算器:健康與規劃
計算正方形、長方形、圓形、三角形、平行四邊形和梯形的面積。輸入尺寸以套用公式並立即得到結果。輸入數值即可快速獲得清晰、準確的計算結果。
大於或小於計算器
大於或小於計算器可比較任意兩個數(整數、小數或負數),並立即顯示正確符號 >、< 或 =。
Gamma函數計算器
使用 Lanczos 近似計算任意實數的 Gamma 函數 Γ(z),快速取得階乘、積分與特殊函數結果。
圓的切線計算器
快速求出圓在任一點的切線方程,支援一般式與斜截式,並提供詳細步驟。
分數比較計算器:哪個分數較大
使用小數、公分母或交叉相乘方法判斷兩個分數的大小,並附上清楚的步驟說明。
三角柱計算器 - 體積與表面積
計算任意三角柱的體積、底面積、側表面積與總表面積。輸入三個底邊和柱高即可立即取得結果。