In[1]:= SameQ[Dot[1, 2], 1.2]
TrueQ[Dot[1, 2] == 1.2]
a = 1; b = 2;
SameQ[Dot[a, b], a.b]
TrueQ[Dot[a, b] == a.b]
Out[1]= False
Out[2]= False
Out[4]= True
Out[5]= True
I know this uses Dot
command wrong. Anybody can give me a clear reson for the above different results?
thanks!
a.b
is interpreted as Dot[a,b]
and then variables a
and b
are substituted, meaning Dot[1,2]
and thus equality holds. This is not the same as 1.2
where the dot stands for the decimal separator and not for the inline operator of Dot
.
When you write 1.2
, Mma understands a number (aka 6/5), but if you write {1, 1}.{2, 2} or a.b
Mma understands a scalar product, as usual in any book using vectors.
HTH!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With