Symbolic Math Toolbox |
 |
Another Example
The next example is perhaps more interesting. Start with the symbolic expression
f = sym('exp(pi*sqrt(163))')
The statement
double(f)
produces the printed floating-point value
2.625374126407687e+17
Using the second argument of vpa
to specify the number of digits,
vpa(f,18)
returns
262537412640768744.
whereas
vpa(f,25)
returns
262537412640768744.0000000
We suspect that f
might actually have an integer value. This suspicion is reinforced by the 30 digit value, vpa(f,30)
262537412640768743.999999999999
Finally, the 40 digit value, vpa(f,40)
262537412640768743.9999999999992500725944
shows that f
is very close to, but not exactly equal to, an integer.
| Example: Using the Different Kinds of Arithmetic | | Linear Algebra |  |