> Mike's solution is ok for the precision but doesn't work for our > little example log(2+a-2), because it still says - infty and in my > application it doesn't fit either.
Doing log(2+a-2) instead of log(2-a-2) should work assuming that you have enough precision to avoid the cancellation problem of floating point arithmetic. sage: R = RealField(1000) sage: a = R(10)^(-175) sage: log(2+a-2) -402.95239127395799470314... Note that if you do log(2-2+a), you get the answer you think you'd get since you aren't taking the difference of two approximately equal floating point numbers. > Harald's solution using RationalField works for this example (log), > but when I come to sqrts or pi in my expression, it fails. > Also in my application I don't know when my variable gets Symbolic, > Real or Complex so it is not always possible to convert to Rational. > So I'd have to use .n() all the time. But isn't that slowing down the > whole computation a lot. If you post your code, it'd be easier to work out any issues. --Mike --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
