Approximate evaluation

### 23.1.3 Approximate evaluation

The evalf or approx command evaluates a symbolic expression to a numeric approximation, if possible (see Section 7.3.1). The approximation is to Digits digits (see Section 2.5.1), this can be changed with an optional second argument.

#### Examples

Assuming that in the CAS configuration Digits=7, so hardware floats are used, and 7 digits are displayed:

evalf(sqrt(2))

1.414214 |  |  |  |  |  |  |  |  |  |

You can change the number of digits in a command line by assigning the variable DIGITS or Digits.

DIGITS:=20:; evalf(sqrt(2))

1.4142135623730950488 |  |  |  |  |  |  |  |  |  |

evalf(10^-5)

1e−05 |  |  |  |  |  |  |  |  |  |

evalf(10^15)

1e+15 |  |  |  |  |  |  |  |  |  |

evalf(sqrt(2))*10^-5

1.41421356237e−05 |  |  |  |  |  |  |  |  |  |