2.2 Exact and Approximate Results
A standard electronic calculator does all your calculations to a particular accuracy, say ten decimal digits. With Mathematica TE, however, you can often get exact results.
Mathematica TE gives an exact result for , even though it has 31 decimal digits.
In[1]:= 2 ^ 100
Out[1]=
You can tell Mathematica TE to give you an approximate numerical result, just as a calculator would, by putting N[ ] around your input. The N stands for "numerical". It must be a capital letter.
This gives an approximate numerical result.
In[2]:= N[ 2 ^ 100 ]
Out[2]=
Mathematica TE can give results in terms of rational numbers.
In[3]:= 1/3 + 2/7
Out[3]=
N always gives the approximate numerical result.
In[4]:= N[ 1/3 + 2/7 ]
Out[4]=
Getting numerical approximations.
When you type in an integer like 7, Mathematica TE assumes that it is exact. If you type in a number like 4.5, with an explicit decimal point, Mathematica TE assumes that it is accurate only to a fixed number of decimal places.
This is taken to be an exact rational number, and reduced to its lowest terms.
In[5]:= 452/62
Out[5]=
Whenever you give a number with an explicit decimal point, Mathematica TE produces an approximate numerical result.
In[6]:= 452.3/62
Out[6]=
Here again, the presence of the decimal point makes Mathematica TE give you an approximate numerical result.
In[7]:= 452./62
Out[7]=
When any number in an arithmetic expression is given with an explicit decimal point, you get an approximate numerical result for the whole expression.
In[8]:= 1. + 452/62
Out[8]=