On Sun, Nov 2, 2008 at 11:58 AM, Kevin Buzzard <[EMAIL PROTECTED]> wrote:
>> That would be inconsistent with the choice made by every other
>> math software system ever written and with common mathematical
>> usage as well.  It would thus cause excessive confusion, and likely
>> not be very useful.
>
> I can believe this. And yet if there's an "IsPositive" command in sage, what
> does IsPositive(Sqrt(5)) give?

There is no IsPositive (or is_positive) command in Sage.  If there
were it would definitely give True because

sage: float(sqrt(5))
2.2360679774997898

>
> I think that my main problem is that I am not used to maths packages that
> think sqrt(5) is anything other than a positive real.

Sage does think it is a positive real.  You're used to math packages like Pari
and Magma that both think sqrt(5) is a "positive rational", by which I somewhat
sarcastically mean a finite-precision floating point number.  Also, I
bet you're also used
to Magma, which thinks of sqrt(5) alternatively as a number field element which
doesn't have a choice of sign.  In Sage, sqrt(5) is the exact positive
sqrt of 5.

sage: a = sqrt(5)
sage: a
sqrt(5)
sage: a^2
5
sage: expand((a+1)^2)
2*sqrt(5) + 6
sage: float(a)
2.2360679774997898
sage: numerical_approx(a, digits=40)
2.236067977499789696409173668731276235441
sage: QQ[a]
Number Field in sqrt5 with defining polynomial x^2 - 5

Actually, at the point when I do QQ[a] and get a number field, a looses
the choice of sign.  That's changing in the next version of Sage though,
due to work of Robert Bradshaw.

> I'm just getting my
> head around the consequences of the decision that it be an abstract object.
> I can totally envisage someone writing some loop for m=1 to 100000, n=crazy
> function of m, t=sqrt(n), blah blah computations with t, and the loop
> bombing out because for some random big value of m, n turned out to be an
> exact square.

True.  One big problem right now is the exact sqrt(5) in Sage is computed with
behind the scenes using a pexpect interface to a slow lisp-based version
of Maxima.  This will change soon (we're moving to a C++ based backend
for symbolic manipulation).  There's a first version of the new backed
in sage-3.2.

> But I'll get used to it over time!
>
> Kevin

If things are truly sufficiently annoying, they can be changed.  (1) you can put
a customization file $HOME/.sage/init.sage and it gets run when sage starts
up, and (2) Sage is open source -- any compelling argument for changes is
seriously considered (especially when the person making the argument is
willing to do all the work).

You can also do n.sqrt(prec=bits_of_precision) and n.isqrt() for the
integer floor of
the sqrt, quickly computed directly by gmp.

sage: n = 9239082304
sage: n.sqrt(prec=30)
96120.145
sage: n.isqrt()
96120

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to