Simplify not maintaining precision?

Skip to first unread message


Aug 1, 2011, 3:17:41 PM8/1/11
to sage-devel
Is this a known bug?

sage: a = RealField(200)(8.987551787368175506591796875e9)
sage: a
sage: var('y')
sage: b = (a * x).mul(y, hold=True)
sage: b
sage: c = (b / (x * y)).simplify()
sage: c
sage: RealField(200)(c)


Aug 1, 2011, 4:03:38 PM8/1/11
to sage-devel

On Aug 1, 3:17 pm, Eviatar <> wrote:
> Is this a known bug?

Perhaps it is better to say that it is a confusing feature.

sage: x.simplify?
Note: Currently, this just sends the expression to Maxima and
it back to Sage.

In particular, the precision will not be carried over.

On the other hand, as a workaround for what you are doing, you could
just use a symbolic a and then substitute it in
(expression.subs(a=RealField...)) at the very end.

I am not sure if this is a good answer for you, but I don't think we
can do anything else about this at the current time.

- kcrisman


Aug 1, 2011, 4:42:41 PM8/1/11
to sage-devel
Oh, I just assumed the interface with Maxima would maintain precision.

Nils Bruin

Aug 1, 2011, 7:25:55 PM8/1/11
to sage-devel
On Aug 1, 1:42 pm, Eviatar <> wrote:
> Oh, I just assumed the interface with Maxima would maintain precision.

It could. Maxima does have a notion of multiprecision floats. They are
base 2, so interfacing with MPFR should be a cinch. Especially with
lib_maxima, translating MPFR to maxima multiprec and vv. should be a
matter of a couple of lines.

I don't know how many routines in Maxima work in a sensible way with
multiprec floats.


Aug 1, 2011, 9:52:48 PM8/1/11
to sage-devel

Nils Bruin

Aug 3, 2011, 5:53:31 PM8/3/11
to sage-devel
On Aug 1, 6:52 pm, Eviatar <> wrote:
> This is now #11643,

A little experimenting (see ticket) shows that Maxima itself does not
keep track of precision in its bigfloats. Any computation (including
just adding two numbers!) will just produce a bigfloat with precision
as set by "fpprec". This even happens when adding two bigfloats with
lower precision. In short, while maxima's bigfloats carry precision
information with them, this is not taken into account in computations.

If we want maxima's floats to act nicely with sage's precision model,
we'd have to scan the expression for mpfr objects, figure out from
that a reasonable precision, set fpprec to that and do the maxima
In your original example, you'd have to set "fpprec" to 200*ln(2)/
Reply all
Reply to author
0 new messages