Re: Zeta Function [HP 50g] Message #8 Posted by Thomas Ritschel on 12 Nov 2012, 2:46 p.m., in response to message #3 by Gerson W. Barbosa
Hello Gerson,
the german wikipedia article on the zeta function provides an EulerMcLaurin sum formula, which can easiliy programmed into the HP50g:
\<< \> s N m
\<< 0 1 N 1 
FOR n n s NEG ^ +
NEXT N 1 s  ^ s
1  / + 1 2 / N s NEG
^ * + 1 m
FOR m 2 m * DUP
IBERNOULLI SWAP ! / 0
2 m * 2 
FOR n s n + *
NEXT N s NEG 2
m *  1 + ^ * +
NEXT
>NUM
\>>
\>>
Note that the above code requires 3 arguments on the stack: besides the argument of the zeta function (called "s" in the code above) also the two integers "N" and "m" which more or less control the number of terms in the sum and therefore the accuracy.
For example, for s=1/2, N=4, and m=2, one will get:
zeta(1/2) = 1.46035496134
Using N=6 and m=4 leads to:
zeta(1/2) = 1.46035450885
I did no precise timings so far, but the two examples took no longer than about 1 or 2 seconds, respectively.
The above code could be further optimized, e.g. by using the fact that the successive "Bernoulli" terms share common factors.
Kind regards,
Thomas
