sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.34k stars 459 forks source link

[is invalid?] mpfr to RQDF coercion #1144

Closed zimmermann6 closed 15 years ago

zimmermann6 commented 16 years ago

I do not understand the following in RQDF??:

    The rings that canonically coerce to the real quad double field are:

On the contrary, RealField(p) should coerce to RQDF exactly for p <= 212 (in fact this should be 215 = 53 + 1 + 53 + 1 + 53 + 1 + 53 since if you round to nearest, then the remainder is smaller than 1/2 ulp of the most significant part).

Thus coercion from RealField() to RQDF should always work.

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/1144

ba94b9bb-195b-4422-a5e2-176920eaa163 commented 16 years ago
comment:2

This is the "canonical coercion", which is a somewhat different concept than coercion (the terminology is bad, and may change).

Canonical coercions are the coercions that Sage applies automatically, for instance when doing arithmetic. If you try to add (or multiply, etc.) an element of A and an element of B, sage will look for a canonical coercion from A to B and a canonical coercion from B to A. (Only one of these should exist.) It will apply this coercion, and then do the arithmetic.

In general, the Sage policy is to prefer to throw away information, rather than make up information; so the product of an RR and an RQDF is an RR.

Explicit coercions are more general; for instance, both RR(RQDF(1)) and RQDF(RR(1)) work.

So the fact that the canonical coercions seem "backward" is by design. However, the use of 212 instead of 215 does seem to be a bug.

robertwb commented 16 years ago
comment:3

Even if one can represent 215 bit numbers exactly with RDQF, the arithmetic it seems is only done to 212 bits of precision according to the documentation, so this would seem to be the correct bound.

http://www.cs.berkeley.edu/~yozo/

mwhansen commented 16 years ago
comment:4

Should this be marked as invalid then?

mwhansen commented 15 years ago
comment:7

Since we are removing RQDF, I'm going to mark this as invalid.