1 /** @file inifcns_zeta.cpp
3 * Implementation of the Zeta-function and some related stuff. */
6 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #ifndef NO_GINAC_NAMESPACE
35 #endif // ndef NO_GINAC_NAMESPACE
38 // Riemann's Zeta-function
41 static ex zeta_eval(ex const & x)
43 if (x.info(info_flags::numeric)) {
44 numeric y = ex_to_numeric(x);
45 // trap integer arguments:
49 if (x.is_equal(exONE()))
50 throw(std::domain_error("zeta(1): infinity"));
51 if (x.info(info_flags::posint)) {
52 if (x.info(info_flags::odd))
53 return zeta(x).hold();
55 return abs(bernoulli(y))*pow(Pi,x)*numTWO().power(y-numONE())/factorial(y);
57 if (x.info(info_flags::odd))
58 return -bernoulli(numONE()-y)/(numONE()-y);
64 return zeta(x).hold();
67 static ex zeta_evalf(ex const & x)
71 END_TYPECHECK(zeta(x))
73 return zeta(ex_to_numeric(x));
76 static ex zeta_diff(ex const & x, unsigned diff_param)
78 GINAC_ASSERT(diff_param==0);
80 return exZERO(); // should return zeta(numONE(),x);
83 static ex zeta_series(ex const & x, symbol const & s, ex const & point, int order)
85 throw(std::logic_error("don't know the series expansion of the zeta function"));
88 REGISTER_FUNCTION(zeta, zeta_eval, zeta_evalf, zeta_diff, zeta_series);
90 #ifndef NO_GINAC_NAMESPACE
92 #endif // ndef NO_GINAC_NAMESPACE