<- previous    index    next ->

Lecture 15, Multiple precision


When 64-bit floating point is not accurate enough 
When 64-bit integers are way too small 

"C" has gmp, gnu multiple precision. 

Java has a bignum package.

Ada has arbitrary decimal digit precision floating point.

Fortran has a multiple precision library.

Hmmm? Multiple precision must be important and have a use.

Computing Pi to a million places is a demonstration, but there
are more reasonable uses.

Types of multiple precision:
  Unlimited length integers
  Unlimited length fractions  1/integer
  Unlimited length rationals  integer/integer
  Unlimited length floating point
  Arbitrary yet fixed number of digits floating point


for "C" get gmp, GNU Multiple Precision!
download gmp from www.swox.com/gmp
gmp.guide

Here are a few simple gmp samples

test_mpf.c
test_mpf.out
test_mpq.c
test_mpq.out
test_mpz.c
test_mpz.out
gmp fact.c
fact_gmp.out


Java BigDecimal that is BigInteger with a scale factor
Big_pi.java test program
Big_pi_java.out test results

Fortran 95 module that implements big integers
big_integers_module.f90
test_big.f90  test program
test_big_f90.out  test results

Ada 95 precise, rational and digits arithmetic
directory of Ada 95 files

A quick conversion of simeq.c to mpf_simeq.c solves simultaneous
equations with 50 digits, could be many more digits using gmp mpf_t.

Using the very difficult to get accurate answers matrix:

test_mpf_simeq.c
mpf_simeq.c
mpf_simeq.h
test_mpf_simeq.out
test_mpf_simeq_300.out


Can irrational numbers be combined to produce an integer?

It appears that  e^(Pi*sqrt(163)) is the integer 262,537,412,640,768,744
and that is rather amazing to me.

How might this be validated? It has been tried using higher and
higher precision and the value computes to about
262,537,412,640,768,743.999,999,999,999,999,999,999

We know 1.5 base 10 can be represented as  1.1 base 2 exactly.
We know 1/3 can not be represented exactly in a finite number of
decimal digits or a finite number of binary digits
   1/3 = 0.3333333333333333333333333333333  decimal approximately
   1/3 = 0.0101010101010101010101010101010  binary approximately
And, for what it is worth
We know 1/3 can be represented exactly as  0.1 base 3.

A quick "C" program gives the first 14 digits, using IEEE 64-bit floating point

 /* irrational.c  e^(Pi*sqrt(163)) is an integer?  */
 #include <math.h>
 #include <stdio.h>

 #define e  2.7182818284590452353602874713526624977572
 #define Pi 3.1415926535897932384626433832795028841971

 int main(int argc, char * argv[])
 {
   printf("e^(Pi*sqrt(163)) is an integer? \n");
   printf("  262537412640768744.0000000  check \n");
   printf("%28.7f  using 15 digit arithmetic \n",pow(e,Pi*sqrt(163.0)));
   return 0;
 }
With output:
 e^(Pi*sqrt(163)) is an integer? 
   262537412640768744.0000000  check 
   262537412640767712.0000000  using 15 digit arithmetic 
   262537412640768743.99999999999925007259719818568887935385633733699 using 300 digit

What is needed is to show convergence from above and below,
and it would be nice if the convergence was uniform. This
could use 50, 100, 150, 200 digit precision for the computation.
Pick a number of digits. Increment the bottom digit of e, Pi and 163
then do the computation. Decrement the bottom digit of e, Pi and 163
then do the computation. Check if the upper and lower values of
the fraction are converging toward zero. Check if the convergence
is uniform, balanced, for the upper and lower values.

This is left as an exercise to the student.

    <- previous    index    next ->

Other links

Go to top