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
See the answer to this question.
In the long term, I think Sage should make this easier by implementing the IPython
%precision
magic, but currently it is not yet implemented. There is an open ticket (#30755) which would be a first step for this.Thank you! Worked like a charm!