[GAP Forum] Comparing real numbers

Christopher Jefferson caj21 at st-andrews.ac.uk
Mon Aug 21 21:06:43 BST 2017


Just as an extension to this, note that cyclotomics are also not in the order you might expect. We can see here that all the squares end up first, but the other square roots end up in an unexpected order.

Chris

gap> l := List([1..20], Sqrt);;
gap> Sort(l);
gap> List(l, x -> x*x);
[ 1, 4, 9, 16, 5, 20, 2, 8, 18, 12, 3, 13, 17, 6, 7, 10, 11, 14, 15, 19 ]

> On 21 Aug 2017, at 15:47, Joey Iverson <jiverson at math.umd.edu> wrote:
> 
> Dear GAP forum,
> 
> I was recently caught off guard by the following:
> 
> gap> Sqrt(2)<2;
> false
> 
> Now that I've read the manual more carefully, I don't think this is a
> malfunction. Instead, it looks like GAP will always report irrational
> cyclotomics to be larger than rationals.
> 
> Does anybody know of a workaround that compares real numbers with their
> usual ordering instead? Suppose we agree that E(n) = exp(2*pi*i/n).
> 
> As a last resort, I suppose I could run GAP inside of SAGE and get
> numerical approximations of everything, but I would like to avoid that if
> possible.
> 
> 
> Thanks for any advice!
> 
> Joey Iverson
> Research Associate
> University of Maryland, College Park
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum




More information about the Forum mailing list