Home Â» How to Easily Calculate the Dot Product in Excel

# How to Easily Calculate the Dot Product in Excel

This tutorial explains how to calculate the dot product in Excel.

### What is the Dot Product?

Given vector a = [a1, a2, a3] and vector b = [b1, b2, b3], theÂ dot productÂ of vector a and vector b, denoted asÂ a Â· b, is given by:

a Â· bÂ = a1Â * b1Â + a2Â * b2Â + a3Â * b3

For example, if a = [2, 5, 6] and b = [4, 3, 2], then the dot product of a and b would be equal to:

a Â· b =Â 2*4 + 5*3 + 6*2

a Â· b =Â 8 + 15 + 12

a Â· b =Â 35

In essence, theÂ dot productÂ is the sum of the products of the corresponding entries in two vectors.

### How to Find the Dot Product in Excel

To find the dot product of two vectors in Excel, we can use the followings steps:

1. Enter the data. Enter theÂ  data values for each vector in their own columns. For example, enter the data values for vector a = [2, 5, 6] into column A and the data values for vector b = [4, 3, 2] into column B:

2. Calculate the dot product. To calculate the dot product, we can use the Excel functionÂ SUMPRODUCT(), which uses the following syntax:

SUMPRODUCT(array1, [array2], â€¦)

• arrayÂ â€“ the first array or range to multiply, then add.
• array2Â â€“ the second array or range to multiply, then add.

In this example, we can type the following into cell D1 to calculate the dot product between vector a and vector b:

=SUMPRODUCT(A1:A3, B1:B3)

This produces the valueÂ 35, which matches the answer we got by hand.

Note that we can useÂ SUMPRODUCT()Â to find the dot product for any length of vectors. For example, suppose vectorÂ aÂ andÂ bÂ were both of length 20. Then we could enter the following formula in cell D1Â to calculate their dot product:

=SUMPRODUCT(A1:A20, B1:B20)

### Potential Errors in Calculating the Dot Product

The functionÂ SUMPRODUCT()Â will return a #VALUE! error if the vectors do not have equal length.

For example, if vector a has length 20 and vector b has length 19, then the formula =SUMPRODUCT(A1:A20, B1:B19) will return an error.

The two vectors need to have the same length in order for the dot product to be calculated.