Karim Belabas on Sat, 11 Apr 2015 11:10:43 +0200

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

 Re: cos: precision too low in mpsc1

```* Chris De Corte [2015-04-11 10:32]:
> I get the following error:
> cos: precision too low in mpsc1
>
> What can you recommend me please?

Assuming the error is something like

(10:53) gp > \p38
(10:53) gp > cos(1e100)
***   at top-level: cos(1e100)
***                 ^----------
*** cos: precision too low in mpcosm1.

then the error means that the input accuracy is simply to small to compute
anything at all about the result.

Most other systems (e.g. mpfr) consider that the input is exact, and can thus
be completed by any number of trailing zeroes. But PARI floats may represent
any real number in some range (see paragraph 2.3.2 in GP user's manual). In
this case [1e100 (1 - 1-e-38), 1e100 (1 + 1-e-38)], an nothing can be said
about the result except that it's between -1 and 1, which does not even
bound its exponent !

The simplest solution is to increase the default precision

(10:54) gp > \p200
realprecision = 211 significant digits (200 digits displayed)
(10:54) gp > cos(1e100)
%1 = -0.92808190507465534345619464377695592818318207643905039332511420954252122203079670126138117700511187183691887194853024728615605695907677892307983039507078619377572991288890406946861814031710664466671099

Note that this only increases the accuracy of *subsequent* inputs.

Cheers,

K.B.

P.S. to pari-dev : the global "t_REAL philosophy" recalled above is a
white lie when considered locally. In a number of functions, we do adopt
mpfr's point of view. It would be quite easy to automatically add trailing
zeroes (thereby artifically increasing the input accuracy) in all basic
functions relying on argument reduction, e.g. trigonometric functions.
Our current view is that this error usually indicates a catastrophic
cancellation in previous computations (thereby producing inputs of lower
accuracy than expected) and it's more useful to stop and notify the user
than to happily go on crunching meaningless numbers. Not as reliable as true
interval arithmetic, but still useful.

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

```