Why does a'*b yield a (slightly) different result than dot(a,b)?
Show older comments
I was working an building a matrix entry-wise and checking two different methods against each other and eventually found that dot(a,b) is giving me a different answer than a'*b, where a and b are both real 9948x1 column vectors. I can see that the implementation of dot uses conj(a)*b, but my vectors are real. In one example, dot(a,b) = -1.0351e-11 and a'*b = -8.6402e-12.
I think it's likely a floating point precision issue, but I'm curious about the implementation of the "*" operator and what might be leading to it. Can anyone shed some light on this?
3 Comments
Guillaume
on 28 Nov 2017
Can you supply some example inputs that show the issue.
In my version (r2017b), dot is implemented as sum(conj(a).*b). With the few trial I have done, both dot(a, b) and a'*b produce the same result (but I haven't tried to create arguments whose dot product was nearly zero).
EQ
on 28 Nov 2017
Guillaume
on 28 Nov 2017
Indeed with your inputs I get the same discrepancy in R2017b. No idea why.
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!