Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A problem when wrongly using Dot command in Mma

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!

like image 942
FreshApple Avatar asked Dec 09 '22 08:12

FreshApple


2 Answers

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.

like image 71
Howard Avatar answered Dec 11 '22 21:12

Howard


enter image description here

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!

like image 42
Dr. belisarius Avatar answered Dec 11 '22 21:12

Dr. belisarius