Request a trial

Dot Product, A Riddle

Earlier this month we received an interesting technical query about the dot() function in MATLAB. Our peer from The MathWorks, Paul Kassebaum, took a unique approach to this riddle – by looking at the history.

The Riddle

When calculating the dot product of a complex and real number one might expect to calculate it algebraically as such: C = (A1*B1) + (A2*B2) + (A3*B3), as shown in the example below. Alternatively you can calculate C using the dot() function which takes the two vectors to produce a scalar value.

MATLAB Example






You will see that using dot() produces a different answer to how one might implement it from its algebraic definition.

So… which is correct?

Paul’s Thoughts

As is pointed out, the documentation for dot() explains how it acts differently on complex versus real vectors. However, this Wikipedia page on the dot product uses the action the customer expects. The difference is due to a historical choice in convention in the development of Quantum Mechanics (originally called Matrix Mechanics by Heisenberg and Born), which was among the first applied uses of matrices in the sciences, although they were well known in math for at least a century prior. The physicists laid the path for engineers as they took up linear algebra, carrying on the conventions physicists had chosen.

And so, the way MATLAB dot() acts is how physicists and engineers expect it to act. I went to school for engineering and physics, so I agree with that design choice, but to each their own!



What Can I Do Next?

Follow us