In Google Sheets, the dot product of two vectors can be calculated using the MMULT and TRANSPOSE functions together. The dot product, a key operation in linear algebra, involves multiplying corresponding entries of two vectors and then summing those products.
It's used in various fields, including mathematics, physics, and engineering, to calculate the similarity between vectors, project one vector onto another, or find the angle between vectors, among other applications.
Below is the formula syntax for calculating the dot product of two vectors, A and B:
=MMULT(TRANSPOSE(A1:A4), B1:B4)
In this formula, A1:A4 represents the range of the first vector and B1:B4 represents the range of the second vector. The TRANSPOSE function changes the row vector A into a column vector. This allows the MMULT function to perform matrix multiplication which results in the dot product of vectors A and B.
Make sure to replace A1:A4 and B1:B4 with the actual cell ranges of your vectors. Note that for MMULT to work as expected, both vectors should have the same dimension, i.e., the same number of elements.
Follow the steps below to calculate dot product in Google Sheets.
For our example, we have listed vector A's components into cells A1 through A4 and vector B's components into cells B1 through B4.
Find an empty cell where the dot product calculation will be displayed. This cell is where you will input the formula to calculate the dot product.
In the cell selected for the dot product result, type the formula =MMULT(TRANSPOSE(A1:A4), B1:B4). This formula tells Google Sheets to multiply the transpose of vector A (cells A1 to A4) by vector B (cells B1 to B4), which computes their dot product.
Image Placeholder
Press Enter to execute the formula. Google Sheets will calculate the dot product of vectors A and B.
The resulting value in the cell is the dot product of vectors A and B, calculated by summing the products of their corresponding components. The dot product result of 33 suggests that vectors A and B are somewhat aligned, indicating they point in roughly the same direction. A positive value like this also implies the angle between them is less than 90 degrees which highlights a degree of similarity or correlation between the vectors.
We hope that you now have a better understanding of how to calculate dot product in Google Sheets. If you enjoyed this article, you might also like our article on how to convert radians to degrees in Google Sheets or our article on how to get dividend yield in Google Sheets.