The Ruby Number gem is an arbitrary-precision complex interval number library for Ruby. The gem is intended to be a drop-in replacement for Ruby's Numeric classes when arbitrary-precision complex interval calculations are warranted. The basis of the arbitrary-precision calculations is the GNU MP, MPFR, and MPC libraries.
First, go grab the source code for the GMP, MPFR, and MPC libraries and install them (in that order) following the instructions on their websites. In Unix, you'd install them by entering the following into the command line:
cd /some_path/my_gmp_src_directory ./configure make sudo make install
After all 3 libraries are installed, grab the Number gem in the usual way:
gem install number
Now you should be ready to go!
Use the global function
Number() to create Number objects.
Pass a single argument to create a new Number from a Ruby object:
Number(1) => 1:1
Number(1.2) => 12:1
Number("1:5") => 1:5
Create complex numbers and interval numbers by passing multiple arguments to
Number(1,2) #=> 1:1+2:1i
Number(1,2,3) #=> [1:1 ≤ (2:1) ≤ 3:1]
Number(Number(1,2,3), Number(4,5,6)) #=> [1:1 ≤ (2:1) ≤ 3:1]+[4:1 ≤ (5:1) ≤ 6:1]i
Once a Number, Always a Number
Number objects coerce Numeric objects into Number objects.
Number(1) + 1 5 / Number(1,2,3)
Stay tuned. More documentation to come.