Fraction Approximation Calculator
A JavaScript web page for finding fractional approximations to values.
Updated

This calculator attempts to find the best fractional approximation to some decimal value using integer values for the numerator and denominator.

Use of the calculator is as follows:

 Action Press the "Start" button to begin the calculation. Value Enter the decimal value of the number to be approximated. This can be up to 17 characters, including the decimal point. It is always interpreted as a positive number. Limit The maximum value allowed for the numerator and denominator of the approximating fraction. CAUTION: Don't enter numbers larger than 10,000 unless you are willing to allow very long run times, and then only if the "Only Better" box is checked. Otherwise your browser's textbox maximum may be over-run. Display If the "Only Better" check box is checked, fractional approximations will be displayed only if they represent an improvement over previous values. Otherwise, all values will be displayed. Output The values in the bottom text field are numerator, denominator, and the value entered minus the value of the fraction represented by the numerator and denominator.

 Rational Fraction Approximation Calculator Action Value Limit Display Only Better

 Interesting numbers to approximate Pi e Golden Ratio Sqrt(2) 3.141592653589793 2.718281828459 1.61803398875 1.414213562373

This calculator starts with a numerator of 1 and a denominator of 1. It performs the division, giving an initial approximation of one. It then calculates the value minus the approximation (the fraction), giving a difference. If the difference is positive, the numerator is increased by one for the next trial. If the difference is negative, the denominator is increased by one for the next trial. This continues until the limit is reached by the numerator or denominator.

Most of the work is in formatting the output. This is true for a lot of software packages.