Arbitrary Precision Floating Point (APFP)

by Dennis Darland - pal at dennisdarland dot com
dennisdarland.com
Comments welcome
  1. Initially developed as procedures in Icon then reworked as classes & overloaded operators in Unicon.
  2. Reworked much more elegantly in Ruby. Mostly because of greatly increased knowledge of problem from having done it before. Also conciseness of Ruby.
  3. 2/25/2015 added ruby on rails calculators
  4. 3/1/2015 Setup and ran aptst.rb
    Found I had to change some "require" statements to "require_relative".
  5. Then reworked totally the error handling in Apfp.rb
    Added error_flag to class - always initialized to false/
    Added function to report error - or if method is given value that had error previously.
    Added function to set error and then call function reporting it.
    All errors seem to be because of domain errors.
    The check is not catching all cases - because of "fuzziness" of comparisons - (or some may be missing) - doesn't always catch very close cases.
    I think I already have functions that can do tests - but I will have to examine each case carefully.
  6. Then I will have to make the rails code use this error handling also.
  7. It is past 5:00am (3/1/2015) so I am done for the night - as was on a roll, I did not want to quit - I will sleep better.
  8. Worked till 4:00am (3/2/2015) then again in afternoon - uploaded new versions realcalc0004.zip, compcalc0004.zip, and also batch test aptst0004.zip
    Also text files of batch tests below
  9. Need to redo demos - but too tired - will wait until I am fresher.

Demos of Complex Number Calculator (version 0006 on 3/5/2015) with everything that was wrong fixed as far as I know

I can thing of improvements - such as red error messages
  1. Complex Number Calculator 6 Demo 1 simple imaginary values
  2. Complex Number Calculator 6 Demo 2 simple complex arithmetic
  3. Complex Number Calculator 6 Demo 3 trig functions (some had trouble before - now work)
  4. Complex Number Calculator 6 Demo 4 trig, inverse trig, hyperbolic, and inverse hyperbolic functions of complex values
  5. Complex Number Calculator 6 Demo 5 some log and exponentiation
  6. Complex Number Calculator 6 Demo 6 misc functions
  7. Complex Number Calculator 6 Demo 7 calculating with lower precision

Original Demos of Complex Number Calculator - I'm not used to doing this as you can tell.

  1. Complex Number Calculator Demo 1 - The values were at least approximate - compared with Maple - but I later discovered I used wrong version of library
  2. Complex Number Calculator Demo 2 - with correct library - the problem had been noticed with asin
  3. Complex Number Calculator Demo 3 - add, subtract, multiply divide
  4. Complex Number Calculator Demo 4 - trig - worked until 5 minute video time limit ran out on tan of pi/2 which failed
  5. Complex Number Calculator Demo 5 - trig - tan pi/2 failing
  6. Complex Number Calculator Demo 6 - trig - tan pi/4 worked but arctan of result failed
  7. Complex Number Calculator Demo 7 - trig and arc-trig of 0.1
  8. Complex Number Calculator Demo 8 - trig and arc-trig of complex value (0.1 + 0.2i)
  9. Complex Number Calculator Demo 9 - hyperbolic and arc-hyperbolic of complex values - also log and exp (0.3 + 0.2i)
  10. Complex Number Calculator Demo 10 - other functions
  11. Complex Number Calculator Demo 11 - entering using scientific notation
  12. Complex Number Calculator Demo 12 - entering data less accurately known

For Comparison to Maple

  1. Values for comparison from Maple 18 for Demo 1
  2. Values for comparison from Maple 18 for Demo 2
  3. Values for comparison from Maple 18 for Demo 3
  4. Values for comparison from Maple 18 for Demos 4 to 10
I compared all the cases where APFP returned numeric answers for demos 2-10 and the answers were very accurate.
Demo 1 was using a wrong library and arcsin was off & threw off subsequent answers in that demo.
It appeared that deviations were on the order of magnitude of the estimated error but I would have to rely on an automated test to determine that conclusively.
There were execution errors on tan(pi/2), and arctan(1)

Experimenting with Maple 18 Interval Arithmetic

3/2/2015 Extensive Batch Tests

The Ruby Program to generate a Ruby program to generate a Maple test program
The generated Ruby program to generate a Maple test program
The generated Maple test program
Test Results - Just all functions
Test Results EXCEPTIONS - all functions
Ap.rb
ApConfig.rb
Apc.rb
Apfp.rb
Real.rb

3/3/2015 Extensive Batch Tests of IMPROVED library

The Ruby Program to generate a Ruby program to generate a Maple test program
The generated Ruby program to generate a Maple test program
The generated Maple test program
Test Results - Just all functions
Test Results EXCEPTIONS - all functions
Ap.rb
ApConfig.rb
Apc.rb
Apfp.rb
Real.rb

README for Installing


2/26/2015 - Fixed a couple bugs in installation procedure and updated README for Installing above.
Later discovered that version on rapfp library I grabbed for rails - switched to one which I ran tests below on.
Had noticed error in asin which was correct in this version.
Doing more testing while working also on more demos.
Use realcalc0003.zip and compcalc00031.zip
  1. 2/3/2010 Start development of regression test for APFP (Ruby program to generate a Ruby Program to generate a Maple Program to compare answers.
  2. 2/5/2010 Test program for APFP almost finished.
  3. 2/6/2010 Test program basically finished - tests ran OK on sin, cos and tan.
  4. 2/7/2010 Tested all functions - fixed some problems - log, log10 and sqrt not as accurate as desired.
    sinh and tanh also had one problem.
  5. 2/8/2010 Enhanced information in Exception file and added time info. Maple took about 16 minutes clock time - but I didn't find a function for that.
  6. 2/13/2010 Struggling with how to compute logarithms - I see what is wrong - but not how to fix it.
  7. 2/13/2010 Fixed problems with logarithms and other less difficult problems. Links to programs and results below.
    Maple produces results almost immediately if screen output is suppressed by using ":" instead of ";"
  8. 2/15/2010 Correction to calculation of percentage
  9. Samples:
    The Ruby Program to generate a Ruby program to generate a Maple test program
    The generated Ruby program to generate a Maple test program
    The generated Maple test program
    Test Results - Just all functions
    Test Results EXCEPTIONS - all functions
    Ap.rb
    ApConfig.rb
    Apc.rb
    Apfp.rb
    Real.rb
  10. NOTE about purpose of Apfp. I am trying to write an arbitrary precision floating point with a capability of tracking the possible error in values calculated from possible error in input or through rounding error. It is very slow, but its purpose is not speed. It is mainly an experiment to see how errors may propagate in calculations. In fact, in the tests above I am calculating to only 16 digits. But in practical applications I doubt if inputs are often known to this accuracy. Larger input errors can be specified as +/-error in literals. I think some improvements in both speed and accuracy are still possible - but it will never be very fast.
  11. Worked on Documentation: (via simple sample program)
    Sample program with comments
    Results are in: (I haven't checked all of them closely - I did check the comparison operators and made some improvements
    The tests above were also updated.
    Results from sample program.
    Generated rdoc files (documentation)
  12. Sourceforge Project Apfp page APFP PAGE
Dennis J. Darland
SourceForge Logo