ZVON > References > Haskell reference
| 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:

Example 1

Input: approxRational 4.3 0.001

Output: 43 % 10

Example 2

Input: approxRational 4.3 0.1

Output: 13 % 3

Example 3

Input: approxRational 4.3 1

Output: 4 % 1

Example 4

Input: approxRational 4.3 10

Output: 0 % 1