Karim Belabas on Tue, 01 Mar 2016 00:18:09 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 Re: Why is precision(sqrt(0)) < precision(sqrt(1)) ??

• To: pari-dev@pari.math.u-bordeaux.fr
• Subject: Re: Why is precision(sqrt(0)) < precision(sqrt(1)) ??
• From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
• Date: Tue, 1 Mar 2016 00:17:58 +0100
• Delivery-date: Tue, 01 Mar 2016 00:18:09 +0100
• Mail-followup-to: pari-dev@pari.math.u-bordeaux.fr
• References: <CY1PR13MB012654C7BB9A95B7CF72E59ED2BA0@CY1PR13MB0126.namprd13.prod.outlook.com> <20160229223046.GA10195@math.u-bordeaux1.fr>
• User-agent: Mutt/1.5.23 (2014-03-12)

* Karim Belabas [2016-02-29 23:31]:
> * Jacques Gélinas [2016-02-29 22:12]:
> > Now, I can understand lowering the precision by half for sqrt(0.),
> > but not for sqrt(0)
>
> This is the unfortunate result of a generic convention that (most of the
> time) an exact input is converted to floating point before a
> "transcendental" function is applied, so sqrt(0) really calls sqrt(0.),
> which really means sqrt(eps) for some 0 <= eps < 2^-bitprecision.
> The result is then some eps' such that 0 <= eps' < 2^(-bitprecision/2)
>
> This is arguably a bug since *some* functions (e.g. cos / sin) avoid
> the  preliminary conversion that when it would lead to a loss of accuracy.
> Compare sin(10^38) and sin(1e38).
>
> I'll fix that.

Also note that

? sqrtn(0, 10)
%1 = 0.E-38

so sqrtn() is already doing "the right thing".

Cheers,

K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite de Bordeaux         Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~kbelabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]
`