Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Set Precision or Decimal places in symbolic expression

Hello. I am currently working with some cumbersome symbolic expressions containing lots of variables. The issue I have is that I cannot view my symbolic expressions with as few decimal places as I would like. Here is a simplified example:

sage: var('x','y','z')
(x, y, z)
sage: expr = 0.1*x+0.2*y+0.3333*z
sage: show(expr)
0.100000000000000*x + 0.200000000000000*y + 0.333300000000000*z

Ideally I would like sth like:

sage: show(expr(precision=1))
0.1*x + 0.2*y + 0.3*z

or

sage: show(expr(decimals=2))
0.10*x + 0.20*y + 0.33*z