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)) ??


* 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]
`