Georg wrote :
while calculating the integer part of square roots I realized that
sqrt() returns wrong results for large inputs (although the sqrt()
command itself accepts "bignum" values).
example: int(sqrt(2^94533))
int isn't a "mathematical" Sage type, but  Integer is a Sage type.
And Integer (sqrt(2^1234567)) fails

But floor over Integer seems fine :

n=10001 ; res=floor(sqrt(2^n)) ; sign(res^2-2^n) ; sign((res+1)^2-2^n)
I get -1 and 1.

but it fails around n=30000 or 40000.

You may also get a precise numerical approximation by the method _____.n(digits=....). By example : sqrt(2).n(digits=10000). But in this case you must compute "by pen" the digit value.

A very similar exercice : Is the number of digits of 123^456^789 even or odd ?
Of course you must read 123^(456^789), not (123^456)^789 !

I hope this help you...

F. (in France)

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to