static ex zeta_eval(ex const & x)
{
if (x.info(info_flags::numeric)) {
+ numeric y = ex_to_numeric(x);
// trap integer arguments:
- if ( x.info(info_flags::integer) ) {
- if ( x.info(info_flags::posint) ) {
- return numZERO(); // FIXME
+ if (y.is_integer()) {
+ if (y.is_zero())
+ return -exHALF();
+ if (!x.compare(exONE()))
+ throw(std::domain_error("zeta(1): infinity"));
+ if (x.info(info_flags::posint)) {
+ if (x.info(info_flags::odd))
+ return zeta(x).hold();
+ else
+ return abs(bernoulli(y))*pow(Pi,x)*numTWO().power(y-numONE())/factorial(y);
} else {
- return numZERO(); // FIXME
+ if (x.info(info_flags::odd))
+ return -bernoulli(numONE()-y)/(numONE()-y);
+ else
+ return numZERO();
}
}
}
return zeta(x).hold();
-}
-
+}
+
static ex zeta_evalf(ex const & x)
{
BEGIN_TYPECHECK
static ex zeta_diff(ex const & x, unsigned diff_param)
{
- ASSERT(diff_param==0);
+ GINAC_ASSERT(diff_param==0);
return exZERO(); // should return zeta(numONE(),x);
}