ZVON > References > Haskell reference |
Intro / Search / ZVON |
| Indexes | Syntax | Prelude | >> Ratio << | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random |
Module: | Ratio |
---|---|
Function: | approxRational |
Type: | RealFrac a => a -> a -> Rational |
Description: | The approxRational function, applied to two real fractional numbers x and epsilon, returns the simplest rational number within the open interval (x-epsilon, x+epsilon). A rational number n/d in reduced form is said to be simpler than another n'/d' if |n| <=|n'| and d <=d'. Note that it can be proved that any real interval contains a unique simplest rational. |
Related: |
Input: approxRational 4.3 0.001
Output: 43 % 10
Input: approxRational 4.3 0.1
Output: 13 % 3
Input: approxRational 4.3 1
Output: 4 % 1
Input: approxRational 4.3 10
Output: 0 % 1