(kill (all), 0);
0;

closeto(e,tol):=block([numer:true,abse],abse:abs(e),if(abse<tol) then true else abse);
closeto(e,tol):=block([numer:true,abse],abse:abs(e),if(abse<tol) then true else abse);

(zeta%pi : true, 0);
0$

(chk(x) := zeta(1-x) - 2 * cos(x * %pi /2) * gamma(x) * zeta(x) / (2 * %pi)^x, 0);
0$

every(lambda([e], is(equal(e,0))), makelist(chk(k),k,2,21));
true$

every(lambda([e], is(equal(e,0))), makelist(zeta(-k) + bern(k+1)/(k+1),k,1,21));
true$

zeta(-1);
-1/12$

zeta(0);
-1/2$

zeta(0.0);
-0.5$

zeta(0.0b0);
-0.5b0$

errcatch(zeta(1)); /* zeta(1) is undefined */
[];

errcatch(zeta(1.0));
[];

errcatch(zeta(1.0b0));
[];

/* Check the limit */
limit(zeta(x),x,1,plus);
inf;

limit(zeta(x),x,1,minus);
minf;

limit(zeta(x),x,1);
infinity;

zeta(2);
%pi^2 /6$

zeta(4);
%pi^4 / 90$

zeta(6);
%pi^6 / 945$

zeta(8);
%pi^8/9450$

zeta(10);
%pi^10/93555$

/* bfloat(zeta(5)) should not return a rational! */
(fpprec:16, bfloat(zeta(5)));
1.03692775514337b0;

/* Fix bug #3672 */
closeto(abs(zeta(%i-2)-(0.02919559324346426-0.01778710697084208*%i)), 2e-17),numer;
true$

zeta(-2);
0$

zeta(-2),numer;
0.0$

/* Fix bug #3673 */
closeto(abs(zeta(%i)-(0.003300223685324066-0.4181554491413215*%i)), 1.69e-16),numer;
true$

fpprec: 32;
32$

/*
 * The expected value was obtained from functions.wolfram.com using 40 digits of
 * precision.
 */
closeto(abs(zeta(3b0 + %i) - (1.1072144084314091956251002057752233976776b0 - 0.1482908671781753484907641256686246807941b0*%i)), 3.11b-33);
true$

/*
 * Bug 3968: For s < 0, zeta(-s) can be expressed in terms of
 * zeta(1-s), a positive number.
 *
 * The expected answer is
 *
 * zeta(s) = 2^s*%pi^(s-1)*sin(%pi/2*s)*gamma(1-s)*zeta(1-s))
 */
zeta(-1/2);
-zeta(3/2)/(4*%pi);

zeta(-7/3);
(7*gamma(1/3)*zeta(10/3))/(27*2^(4/3)*%pi^(10/3));

makelist(
  block([
    /* Experimentally determined.  Should be around 1e-15 or so */
    threshold : 2.0e-15,
    exact : zeta(-(k+1/2)),
    fl : zeta(float(-(k+1/2))), err],
    /*
     *
     * Use relative error.  If the error is too large, return the arg,
     * the relative error, the exact value, and the corresponding
     * numerical value
     *
     */
    err : closeto(abs((float(exact)-fl)/fl), threshold),
    if (err = true)
    then true
    else [-(k + 1/2), err, exact, fl]),
  k, 1, 10);
[true, true, true, true, true, true, true, true, true, true];

(reset(fpprec), remfunction(chk),0);
0$
