[Scilab-users] Riemann Zeta update
Lester Anderson
arctica1963 at gmail.com
Sun May 22 08:31:30 CEST 2022
Hi all,
After a lot of trial and error, I have managed to get a set of functions to
compute the approximations of Riemann's Zeta for negative and positive real
values; values of n > 1e6 seem to give better results:
function zs=zeta_s(z, n)
// Summation loop
zs=1;
if z == 0
zs = -0.5
elseif z == 1
zs = %inf
else
for i = 2: n-1
zs = zs + i.^-z;
end
endendfunction
function zfn=zeta_functional_eqn(s)// Riemann's functional equation//
Analytic continuation for negative values
zfn = 2.^s .* %pi.^(s - 1) .* sin(%pi.*s./2) .* gamma(1 - s) .*
zeta_s((1 - s),n)endfunction
For even values of s < -20 the values of Zeta(s) increase in value and are
not as close to zero as expected e.g. zeta_functional_eqn(-40) gives
7.5221382. At small even values e.g. -10, the result is of the order of
~1e-18 (close enough to zero). Any ideas why the even zeta values increase
or how to reduce that response?
The solution over the critical strip (zero to one) is not so efficient
unless n is very large( > 1e8), and there seems to be a performance issue
when using a for-loop compared to vectorisation. Vectorised n speeds things
up quite a bit.
function zs2=zeta_0_1(s, n)zs2=0for i = 1: n
zs2 = zs2 + (-1).^(i + 1)./(i.^s );end
zs2 = 1./(1 - 2.^( 1-s )).*zs2; endfunction
function zs1=zeta_0_1(s, n)// Vectorised version zs1=0k=linspace(1,n,n);
zs1 = sum((-1).^(k+ 1)./(k.^s ));
zs1 = 1./(1 - 2.^( 1-s )).*zs1;endfunction
For example, calculating the approximation of Zeta(0.5) using a for-loop
takes ~150s to give a value of -1.4602337981325388 (quite close),
whereas the vectorised version does the computation in under 20s, both
tested using n=1e8. Can the functions be optimised to improve speed and
accuracy?
Using Scilab 6.1.1 on Windows 10 (16 Gb RAM).
Thanks
Lester
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20220522/5bc1ea7b/attachment.htm>
More information about the users
mailing list