Speed Fraction!





Introduction: Here are some programs that I wrote a long time ago that find fractional approximations for decimal numbers. For example, here is the output for 'spfrcn 3.14159265358979323':

Hit return at any time to stop...
Ok: 3.1415926535897931
3 / 1  :  3.0000000000000000
22 / 7  :  3.1428571428571428
289 / 92  :  3.1413043478260869
355 / 113  :  3.1415929203539825
59973 / 19090  :  3.1415924567836564
69913 / 22254  :  3.1415925226925498
79853 / 25418  :  3.1415925721929341
89793 / 28582  :  3.1415926107340284
99733 / 31746  :  3.1415926415926414
104348 / 33215  :  3.1415926539214212
208341 / 66317  :  3.1415926534674368
312689 / 99532  :  3.1415926536189365
833719 / 265381  :  3.1415926535810779
1146408 / 364913  :  3.1415926535914038
3126535 / 995207  :  3.1415926535886505
4272943 / 1360120  :  3.1415926535893890
5419351 / 1725033  :  3.1415926535898153
47627751 / 15160384  :  3.1415926535897771
58466453 / 18610450  :  3.1415926535897842
69305155 / 22060516  :  3.1415926535897891
74724506 / 23785549  :  3.1415926535897909
80143857 / 25510582  :  3.1415926535897927
245850922 / 78256779  :  3.1415926535897931

Note that the programs in the gmpspfrcn directory use the GNU precision library. It doesn't take long to generate a fractional approximate for a decimal when you only have 16 significant digits, so I've used the GNU precision library to allow for more significant digits in the decimal and fractional components.

Here is an example of the output I got when I tried to approximate pi using gmpspfrcn:

Hit return at any time to stop...
0.31415926535897932384626433832795028842e1
3 / 1  :  0.3e1
22 / 7  :  0.31428571428571428571428571428571428571e1
289 / 92  :  0.31413043478260869565217391304347826087e1
355 / 113  :  0.31415929203539823008849557522123893805e1
59973 / 19090  :  0.31415924567836563645887899423782084861e1
99733 / 31746  :  0.31415926415926415926415926415926415926e1
104348 / 33215  :  0.31415926539214210447087159415926539214e1
208341 / 66317  :  0.31415926534674367055204547853491563249e1
312689 / 99532  :  0.31415926536189366233975003014106016156e1
833719 / 265381  :  0.31415926535810777712044193065818577818e1
1146408 / 364913  :  0.31415926535914039784825424142192796639e1
3126535 / 995207  :  0.3141592653588650401373784549345010636e1
4272943 / 1360120  :  0.3141592653589389171543687321706908214e1
5419351 / 1725033  :  0.31415926535898153832419437773074486111e1
47627751 / 15160384  :  0.31415926535897771454865523195190834216e1
58466453 / 18610450  :  0.3141592653589784234126525688524458033e1
80143857 / 25510582  :  0.31415926535897926593756269457121754415e1
165707065 / 52746197  :  0.31415926535897934025461589202345716033e1
245850922 / 78256779  :  0.3141592653589793160283277184204067484e1
411557987 / 131002976  :  0.31415926535897932578264481564144008454e1
657408909 / 209259755  :  0.31415926535897932213482711952902745203e1
1068966896 / 340262731  :  0.31415926535897932353925649294809192606e1
2549491779 / 811528438  :  0.31415926535897932390140097591995907357e1
3618458675 / 1151791169  :  0.31415926535897932379441606918588902638e1
6167950454 / 1963319607  :  0.3141592653589793238386377506390379567e1





charlton@dynet.com


This page has been hit times since March 1, 2001.



Back to bach