Arbitrary Precision Floating Point (APFP)
by Dennis Darland - pal at dennisdarland dot com
Dennis J. Darland
- Initially developed as procedures in Icon then reworked as classes & overloaded operators in Unicon.
Reworked much more elegantly in Ruby. Mostly because of greatly increased
knowledge of problem from having done it before. Also conciseness of Ruby.
- 2/25/2015 added ruby on rails calculators
- 3/1/2015 Setup and ran aptst.rb
Found I had to change some "require" statements to "require_relative".
- 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.
- Then I will have to make the rails code use this error handling also.
- 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.
Demos of Complex Number Calculator - I'm not used to doing this as you can tell.
- Complex Number Calculator Demo 1 - The values were at least approximate - compared with Maple - but I later discovered I used wrong version of library
- Complex Number Calculator Demo 2 - with correct library - the problem had been noticed with asin - which wasn't used in demo 1
- Complex Number Calculator Demo 3 - add, subtract, multiply divide
- Complex Number Calculator Demo 4 - trig - worked until 5 minute video time limit ran out on tan of pi/2 which failed
- Complex Number Calculator Demo 5 - trig - tan pi/2 failing
- Complex Number Calculator Demo 6 - trig - tan pi/4 worked but arctan of result failed
- Complex Number Calculator Demo 7 - trig and arc-trig of 0.1
- Complex Number Calculator Demo 8 - trig and arc-trig of complex value (0.1 + 0.2i)
- Complex Number Calculator Demo 9 - hyperbolic and arc-hyperbolic of complex values - also log and exp (0.3 + 0.2i)
- Complex Number Calculator Demo 10 - other functions
- Complex Number Calculator Demo 11 - entering using scientific notation
- Complex Number Calculator Demo 12 - entering data less accurately known
For Comparison to Maple
I compared all the cases where APFP returned numeric answers for demos 2-10 and the answers were very accurate.
- Values for comparison from Maple 18 for Demo 1
- Values for comparison from Maple 18 for Demo 2
- Values for comparison from Maple 18 for Demo 3
- Values for comparison from Maple 18 for Demos 4 to 10
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)
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
- 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/5/2010 Test program for APFP almost finished.
- 2/6/2010 Test program basically finished - tests ran OK on sin, cos and tan.
- 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.
- 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.
- 2/13/2010 Struggling with how to compute logarithms - I see what is wrong - but not how to fix it.
- 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 ";"
- 2/15/2010 Correction to calculation of percentage
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
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.
- 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)
- Sourceforge Project Apfp page APFP PAGE