# Toppling the numeric tower

David Eppstein eppstein at ics.uci.edu
Thu Jul 26 19:35:36 CEST 2001

```In article <cp7kwv7iag.fsf at cj20424-a.reston1.va.home.com>,
Guido van Rossum <guido at python.org> wrote:

> > (2) should isintegral() return true for algebraic integers that are not
> > rational integers?
>
> Sorry, you lost me there.  What are these?

Roots of polynomials with integer coefficients, leading coefficient = 1.
E.g. the golden ratio 1+sqrt(5)/2 is a root of the polynomial
x^2-x-1, so it is an algebraic integer.  When mathematicians want to
specify that a number is what you would call an integer, in the context of
algebraic numbers, they say "rational integer" to be more specific.

This is irrelevant to the proposed numeric tower int-long-rat-float-complex
since that doesn't include exact algebraic computation at all, but some
users would find it useful to be able to add to the tower.  As an example,
I recently wanted to work with a program for computing the sets of faces of
a polyhedron -- this was in 4d but to keep things simple I'll talk about
3d.  A cube or cuboid has the property that three edges and faces meet at
every vertex, and I wanted to verify that certain polyhedra had similar
properties.  It would be incorrect to approximate the vertex coordinates by
floats, because that would change the set of faces -- if you shift a
cuboid's vertices even a little bit, its nice quadrilateral faces get
broken into pairs of triangles.  For the cube, this is not a problem, just
use integers, but the polyhedra I was interested in could not be expressed
by integer coordinates, they needed exact computation with numbers like
sqrt(3).  Unfortunately, the program I wanted to use had not been written
in a way that made it easy to implement and add my own numeric types.  But
if it had been written in Python 3.0 ...
--
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/

```