I can't understand why is it that
In[88]:= Sin[2]
Out[88]= Sin[2]
while
In[89]:= Sin[2.0]
Out[89]= 0.909297
I even tried
In[90]:= 2 + Sin[2]
Out[90]= 2 + Sin[2]
thinking that it might force the evaluation, but apparently not...
Now, I know that I can just do this
In[91]:= N[Sin[2]]
Out[91]= 0.909297
but I am curious why doesn't just Sin[2] work.
Even though the Documentation Center page for Sin[x] contains Possible Issues examples this behavior is not mentioned.
I know from some experience with Python and C that expressing a integer number, e.g. 2, as a rational number, i.e. 2.0, can influence the way an expression is evaluated, e.g.
#Python code
>>> 5 / 2
2
>>> 5 / 2.0
2.5
Even though I personally don't agree with this behavior (I think there should be different operators for integer division and rational division since it will always cause some confusion) if you just see some examples it becomes clear what happens.
Here I don't have any idea what Mathematica thinks when it sees Sin[2]
Note:
- I'm using Mathematica v7.0
- I'm basically a beginner.
- I don't plan and have time to go through a tutorial, I just wanted to play around. I expected the simple/common things to behave intuitively enough.
- I also appreciate if you point me to some resources where this behavior is explained.
Sin[2]simply cannot be represented in decimal notation. It can only be approximated with a finite number of digits. If you give exact input to Mathematica (integers are considered exact) then it will give you an exact output, the simplest form of which here isSin[2].Sin[Pi]would give an exact0,Sin[Pi/3]would giveSqrt[3]/2, but you can't reduceSin[2]further without using approximations. – Szabolcs Feb 16 '14 at 17:04