closest_fractions - show the closest rational approximations to a real

Fetch the software.

Find the fractions closest in value to a given real number. Options:

-m
Specifies the maximum numerator and denominator for the fractions. The default is 100.
-n
Specifies how many nearby fractions to show, in each direction. The default is 5.

Here's an example:


% closest_fractions -m 1000 -n 2 2.718281828459045 1.414213562373095 1.732050807568877 1.618033988749895 3.141592653589793
2.718281828459045:
    685 / 252  =  2.718253968253968  (-2.78602e-05)
    878 / 323  =  2.718266253869969  (-1.55746e-05)
    193 /  71  =  2.71830985915493   (2.80307e-05)
    859 / 316  =  2.718354430379747  (7.26019e-05)
1.414213562373095:
    239 / 169  =  1.414201183431953  (-1.23789e-05)
    816 / 577  =  1.41421143847487   (-2.1239e-06)
    577 / 408  =  1.41421568627451   (2.1239e-06)
    915 / 647  =  1.414219474497682  (5.91212e-06)
1.732050807568877:
    627 / 362  =  1.732044198895028  (-6.60867e-06)
    989 / 571  =  1.732049036777583  (-1.77079e-06)
    362 / 209  =  1.732057416267943  (6.6087e-06)
    821 / 474  =  1.732067510548523  (1.6703e-05)
1.618033988749895:
    377 / 233  =  1.618025751072961  (-8.23768e-06)
    987 / 610  =  1.618032786885246  (-1.20186e-06)
    610 / 377  =  1.618037135278515  (3.14653e-06)
    843 / 521  =  1.618042226487524  (8.23774e-06)
3.141592653589793:
    333 / 106  =  3.141509433962264  (-8.32196e-05)
    688 / 219  =  3.141552511415525  (-4.01422e-05)
    355 / 113  =  3.141592920353983  (2.66764e-07)
    732 / 233  =  3.141630901287554  (3.82477e-05)

Try it out for yourself with this form interface:

Max term: Nearby:

Back to ACME Labs Software.
Back to ACME Labs.