]> www.ginac.de Git - ginac.git/blobdiff - check/inifcns_consist.cpp
- introduced info_flags::cinteger, info_flags::crational,
[ginac.git] / check / inifcns_consist.cpp
index 024dad79917382849d191f334fca34c00b9f0ebb..f48db0abf9a35b8513399c08a346bb6e4dfd9215 100644 (file)
@@ -169,8 +169,8 @@ static unsigned inifcns_consist_trans(void)
     return result;
 }
 
-/* Simple tests on the Gamma combinatorial function.  We stuff in arguments
- * where the result exists in closed form and check if it's ok. */
+/* Simple tests on the Gamma function.  We stuff in arguments where the results
+ * exists in closed form and check if it's ok. */
 static unsigned inifcns_consist_gamma(void)
 {
     unsigned result = 0;
@@ -214,6 +214,27 @@ static unsigned inifcns_consist_gamma(void)
     return result;
 }
 
+/* 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;
+    
+    // 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;
+}
+
 /* Simple tests on the Riemann Zeta function.  We stuff in arguments where the
  * result exists in closed form and check if it's ok.  Of course, this checks
  * the Bernoulli numbers as a side effect. */
@@ -253,9 +274,10 @@ unsigned inifcns_consist(void)
     result += inifcns_consist_cos();
     result += inifcns_consist_trans();
     result += inifcns_consist_gamma();
+    result += inifcns_consist_psi();
     result += inifcns_consist_zeta();
 
-    if ( !result ) {
+    if (!result) {
         cout << " passed ";
         clog << "(no output)" << endl;
     } else {