I am trying to find a proper way to calculate the scalar product of two ranges. For instance, the product of A1:A3
and B1:B3
would be A1*B1 + A2*B2 + A3*B3
. Is there a good way to do this? Hardcoding this calculation is quite a tedious thing to do with large ranges.
The dot product is the sum of the product of two vectors. For example, two vectors are v1 = [2, 3, 1, 7] and v2 = [3, 6, 1, 5]. The sum of the product of two vectors is 2 × 3 + 3 × 6 + 1 × 1 = 60. We can use the = SUMPRODUCT(Array1, Array2) function to calculate dot product in excel.
Select the cell with the constant number (B1), and press Ctrl + C to copy it to the clipboard. Select the cells you want to multiply (C4:C7). Press Ctrl + Alt + V, then M, which is the shortcut for Paste Special > Multiply, and then press Enter.
The SUMPRODUCT function returns the sum of the products of corresponding ranges or arrays. The default operation is multiplication, but addition, subtraction, and division are also possible.
Use this one
=SUMPRODUCT(A1:A3,B1:B3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With