Rational approximation

### 8.4.7 Rational approximation

Floating point numbers are considered approximations, while integers and rational numbers are considered exact. The float2rational or exact command finds a rational approximation to a floating point number.

- float2rational takes expr, an expression.
- float2rational(expr) returns expr with all the floating point numbers in expr replaced by rational numbers; any floating point number x is replaced by a rational r with |r−x|<ε, where ε is given by epsilon in the CAS configuration (see Section 2.5.7, item 2.5.7).

#### Examples

float2rational(1.5)

3
2

float2rational(1.414)

707
500

float2rational(0.156381102937*2)

5144
16447

float2rational(1.41421356237)

114243
80782

float2rational(1.41421356237^2)

2 |  |  |  |  |  |  |  |  |  |