| 1 | initial version |
Of course, the problem is really in the expression itself:
sage: f = 5*x*exp(-.1*x^2)
sage: f
5*x*e^(-0.100000000000000*x^2)
One way to avoid this sort of thing is to avoid using decimals at all.
sage: f = 5*x*exp(-1/10*x^2)
sage: diff(f,x)
-x^2*e^(-1/10*x^2) + 5*e^(-1/10*x^2)
(Notice the preferred syntax diff(f,x), since in principle one could be taking a partial derivative with respect to some other variable.)
We used to have a way to display a lot fewer digits, but that got nixed once we switched to Gi/Pynac for basic symbolics. I don't recall what the status of that is. All the ways I can think of to display fewer digits for now also would give you less precision, but I think there may still be a way to do it. In any case, I would not recommend using decimals unless you only have inexact data; you might as well get the benefit of exact symbolics!
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.