+/* Simple tests on the Psi-function (aka polygamma-function). We stuff in
+ arguments where the result exists in closed form and check if it's ok. */
+static unsigned inifcns_consist_psi(void)
+{
+ unsigned result = 0;
+ symbol x;
+ ex e, f;
+
+ // We check psi(1) and psi(1/2) implicitly by calculating the curious
+ // little identity gamma(1)'/gamma(1) - gamma(1/2)'/gamma(1/2) == 2*log(2).
+ e += (gamma(x).diff(x)/gamma(x)).subs(x==numeric(1));
+ e -= (gamma(x).diff(x)/gamma(x)).subs(x==numeric(1,2));
+ if (e!=2*log(2)) {
+ clog << "gamma(1)'/gamma(1) - gamma(1/2)'/gamma(1/2) erroneously returned "
+ << e << " instead of 2*log(2)" << endl;
+ ++result;
+ }
+
+ return result;
+}
+