Hello,

> while working a little with sage I encountered some problems sage has
> concerning numerical precision at very small numbers.
> I hope I can make my point with a little example.
>
> sage: a=1e-175
> sage: log(a)
> -402.952391273958

There are a few issues at hand here.  First, you have to be careful
when working with either really large or really small floating
numbers.  You can do a.parent() to figure out the data type of a.

sage: (1e-175).parent()
Real Field with 53 bits of precision

It only had 53 bits of precision.

> sage: log(2-a-2)
> -infinity

For this particular computation, a is a positive number so 2-a-2
should be a negative number.  So, I would expect a result of -infinity
or NaN.

There are two options for working with more precision.  You can
RealField with a certain number of bits of precision like the
following:

sage: R = RealField(200); R
Real Field with 200 bits of precision
sage: a = R(10)^(-175); a
1.0000000000000000000000000000000000000000000000000000000000e-175

or you can use a RealIntervalField which gives an interval of real
numbers that your true answer is guaranteed to be in.

sage: R = RealIntervalField(100); R
Real Interval Field with 100 bits of precision
sage: a = R(10)^(-175); a
[9.9999999999999999999999999976770e-176 ..
1.0000000000000000000000000000747e-175]

Let me know if that helps,
--Mike

--~--~---------~--~----~------------~-------~--~----~
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