On 3/2/11 12:04 PM, sm123123 wrote:
Is there any way to handle scientific precision in base 10 in a simple
way, using sage ?


Yes. You could just use normal floating point numbers and then give the output format. This would use 53-bit precision for the calculations, but then the printing would follow your spec:

sage: a=23.192-49.39291
sage: "%12.3e"%a
'  -2.620e+01'


If you wanted to carry out the calculations with a different precision, you could try using RealField (this wraps the C MPFR library):

sage: R=RealField(10) # 10 bits of precision
sage: R('0.4')-R('2e3')
-2000.
sage: R('10')-R('2e3')
-2000.
sage: a=R('100')-R('2e3')
sage: a
-1900.
sage: "%12.3e"%a
'  -1.900e+03'

For more information about the printf-like syntax, see:

* printf-like syntax: http://docs.python.org/library/stdtypes.html#string-formatting-operations

* new, more powerful string formatting syntax: http://docs.python.org/library/string.html#format-string-syntax




The sense I have gotten so far is that numerical related work is an
afterthought in Sage and that it is really a professional
mathematician's workbench that could be coaxed or tweaked into being
useful for scientists who use math / numerics as a tool, and not an
end in itself.

I have nothing against mathematicians (btw).

Historically, the algebraic/combinatoric side of Sage has had a lot more attention than the numerical side. However, Sage also includes some very good standard numerical tools and packages that have been developed outside of the Sage community. The number of developers working on Sage numerical aspects is also increasing.

Keep your comments and questions coming. I would like to see Sage numerical capabilities get easier to use.

Thanks,

Jason

--
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
URL: http://www.sagemath.org

Reply via email to