Karim Belabas on Mon, 09 Jul 2018 19:06:20 +0200


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

Re: Truncation Precision in PARI


* Karim Belabas [2018-07-09 18:32]:
> * Peter Pein [2018-07-09 14:17]:
> > that is not very accurate :(
> > 
> > I get:
> > 
> > precision(-1 - Euler + 3/2*log(2*Pi) + 6*zetahurwitz(-1, 1, der = 1), 100)
> > %1 =
> > 0.1870730725097797894509591576777666319578148029622159376465535484192711630046534855901322306210633101
> 
> Please check ??precision :
> [...] If n is smaller than the precision of a t_REAL component of x,  it is
> truncated, otherwise it is extended with zeros.
> [...]
> 
> What you wrote first evaluates the expression to the default accuracy
> (38 decimal digits) then pads the result with trailing zeros.

I misread your message, sorry : I had somehow entirely forgotten the
original thread / question and the answer I made. Indeed,

  sumnum(k = 1, (1 - 3*k - 6*k^2) / (2*k+2) + 3*k^2 * log(1 + 1/k))

is very inaccurate. I only intended to show how intnum's expression
could be transformed algbraically, it wasn't meant to be numerically
stable or efficient and I didn't bother to check the numerical answer.
As you pointed out, it's actually completely wrong. I'll investigate... 

Other summation functions fare better with the same expression:

? sumnummonien(k = 1, (1 - 3*k - 6*k^2) / (2*k+2) + 3*k^2 * log(1 + 1/k))
%1 = 0.1870730725097797894509591576777666319578148029622159376465535484192711630046534855901322306210633101

? sumnumlagrange(k = 1, (1 - 3*k - 6*k^2) / (2*k+2) + 3*k^2 * log(1 + 1/k))
%2 = 0.1870730725097797894509591576777666319578148029622159376465535484192711630046534855901322306210633101

For some reason, the only summation routine that is unable to handle that
expression is the default one...

Thanks for pointing this out ! :-)

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 21 23
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~kbelabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]
`