# If dot product is commutative, why does MATLAB give different answers?

Why does the dot() function in MATLAB return different expressions based on the order in which I pass vectors?

• The premise of your question is incorrect. The "dot product" of complex vectors is not commutative. – Brian Borchers Nov 4 '20 at 19:15
• I guess the confusion arises because f is symbolic (x and y could be complex) whereas u is explicitly real-valued. – Charlie S Nov 4 '20 at 19:53
• I don't have matlab, but according to this link mathworks.com/help/symbolic/… you can add assumptions to symbolic variables. x = sym('x', 'real');y = sym('y', 'real'); That may clear things up. – Charlie S Nov 4 '20 at 19:56
• You can declare that x and y are real using "syms x y real". – Chenna K Nov 4 '20 at 20:33
• Sorry for the shorthand. The point is that depending on your convention you take either the conjugate of the first vector or the second vector in the product. The point remains that this can cause confusion... – Brian Borchers Nov 4 '20 at 22:35