Select Page

MATLAB uses floating-point arithmetic for its calculations.
Using the Symbolic Math Toolbox, we can also do exact arithmetic with symbolic expressions. For example:

</p>
x = cot(pi/2)

Output:
x =
6.1232 e-17

The value of x is in floating-point format that is 6.1232^10-17.
However, we know that   is equal to 0. This inaccuracy is due to the fact that typing pi in MATLAB gives an approximation to  accurate to about 15 digits, not its exact value. To compute an exact value, we must type sym(pi/2).
For example:

</p>
x = cot(sym(pi/2))
Output:
x =
0