Ilya Zakharevich on Fri, 30 Jul 1999 20:13:03 -0400 (EDT)

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: ebcdic packed numbers

[A complimentary Cc of this posting was sent to Abigail
who wrote in article <>:
> _Finite_ or _repeated_ fractions can be. But I challenge you to find 2 bignums
> that form a ratio equal to the square root of 2.

Say, BignumSQRT(2)/1.  ;-)

> [Not that's it's impossible to do exact arithmetic on algebraic numbers.
>  C-K Yap had an interesting talk on CCCG'92 explaining how to do
>  arithmetic on algebraic numbers, using just integers. It's all based on
>  the fact that an algebraic number is a root of a polynomial of bounded
>  degree, and integer coefficients. But I disgress... ]

Well, Math::Pari module has no problem dealing with algebraic numbers:

perl -MMath::Pari=:DEFAULT,Mod -wle \
 ' $t = PARIvar("t"); $q = PARIvar("q"); \
   $root2 = Mod($t, $t**2 - 2); \
   $root3 = Mod($q, $q**2 - 3); \
   print "OK" if 24 == (($root2 - $root3)**2 - 5)**2'

However, not that these are "abstract" algebraic numbers, not complex
algebraic numbers.  Say, $root2 represents both -sqrt(2) and sqrt(2).

To do calculations with complex algebraic numbers, one needs to keep a
pair of an "abstract" algebraic number (an element of a
finite-dimensional commutative algebra over Q) and a complex
floating-point approximation to this number (a complex number which is
significantly closer to one embedding of the above number into C than
to other embeddings).

PARI has no built-in datatype for such pairs.  But since PARI supports
arbitrary-precision (complex) floating-point arithmetic as well, it
should be a quick exercise to write a Perl module which would use
Math::Pari and will make calculations with complex algebraic numbers.


P.S.  BTW, how hard is it to add a new datatype to PARI nowadays?