Karim Belabas on Mon, 29 Feb 2016 23:30:55 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Why is precision(sqrt(0)) < precision(sqrt(1)) ?? |
* 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. > and then why is is not also done for sqrt(1) ? Because there is no loss of accuracy there : (1+eps)^(1/2) ~ 1 + eps/2, we even gain 1 bit :-) 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] `