Contributing to GMP
Marc Glisse
marc.glisse at inria.fr
Wed Feb 26 12:54:21 UTC 2020
On Wed, 26 Feb 2020, Marco Bodrato wrote:
> Il Lun, 24 Febbraio 2020 2:51 pm, Marc Glisse ha scritto:
>> On Mon, 24 Feb 2020, Marco Bodrato wrote:
>
>>> Of course, if you don't care to obtain sqrt(9/49) = 3/7 or anything
>>> different...
>>
>> If you are going to approximate sqrt(2) with a rational, you probably
>> don't care that much about getting exactly 3/7 either.
>
> True, but 3/7 is more efficient for the following computations :-)
Indeed. It might not happen that often though.
>>> But of course, with mpq, we can decide how to approximate.
>>
>> By the way, maybe the function could return a bool (exact or not) or
>> {-1,0,+1} to say in which direction it approximated.
>
> That's the easy part. But one may also want to let the caller decide the
> desired direction of approximation. Efficiency is much more tricky.
Also, bounding the size of the denominator may not always be the best
suited to each application.
It is good for absolute errors, but does not bound the size of the output,
and can have bad relative error (sqrt(1/big,100) would be 0.
The only reply I got for now from CGAL is that they don't seem
particularly interested. The one function they would like for mpq_t is a
function that takes a mpq_t and returns a tight interval of double
containing it. Currently, this goes through MPFR, and is often the only
function from MPFR that is used.
So we have to look elsewhere for people interested in mpq_sqrt.
--
Marc Glisse
More information about the gmp-discuss
mailing list