I am trying to build a program to compare the partial sum of the Riemann Zeta function to the built-in Matlab function zeta(s). I want the function to output the minimum number of terms to achieve an accuracy of 0.1 percent. I thought a while loop would be the best approach, but my program is running so slow; I have yet to get a result from it.
function[n] = riemannzeta(s)
error = 1; n = 1; an = 1; S = an;
while error >= 0.1
an = 1/n^s;
S = S + an;
n = n + 1;
z = zeta(s);
error = ((S - z)/z)*100;
end
end
I call it with:
riemannzeta(3)