]> www.ginac.de Git - ginac.git/blobdiff - check/exam_pseries.cpp
power::series(): handle someg (trivial) singularities of the exponent...
[ginac.git] / check / exam_pseries.cpp
index 2e5d2d6ef9e8e5f2b146022813108eb4db660d86..a0f87eade96c06cadbda75a74ac5045d228c8434 100644 (file)
@@ -3,7 +3,7 @@
  *  Series expansion test (Laurent and Taylor series). */
 
 /*
- *  GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "exams.h"
+#include "ginac.h"
+using namespace GiNaC;
+
+#include <iostream>
+using namespace std;
 
 static symbol x("x");
 
@@ -169,6 +173,7 @@ static unsigned exam_series3()
 // Series exponentiation
 static unsigned exam_series4()
 {
+       using GiNaC::tgamma;
        unsigned result = 0;
        ex e, d;
        
@@ -207,6 +212,7 @@ static unsigned exam_series5()
 // Series expansion of tgamma(-1)
 static unsigned exam_series6()
 {
+       using GiNaC::tgamma;
        ex e = tgamma(2*x);
        ex d = pow(x+1,-1)*numeric(1,4) +
               pow(x+1,0)*(numeric(3,4) -
@@ -324,6 +330,7 @@ static unsigned exam_series11()
 static unsigned exam_series12()
 {
        using GiNaC::log;
+       using GiNaC::atanh;
 
        unsigned result = 0;
        ex e, d;
@@ -362,12 +369,28 @@ static unsigned exam_series13()
        return result;
 }
 
+// Test if (1+x)^(1/x) can be expanded.
+static unsigned exam_series14()
+{
+       unsigned result = 0;
+
+       ex e = pow(1+x, sin(x)/x);
+       ex d = 1 + x - pow(x,3)/6 + Order(pow(x,4));
+       try {
+               result += check_series(e,0,d,4);
+       } catch (const pole_error& err) {
+               clog << "series expansion of " << e << " at 0 raised an exception." << endl;
+               ++result;
+       }
+
+       return result;
+}
+
 unsigned exam_pseries()
 {
        unsigned result = 0;
        
        cout << "examining series expansion" << flush;
-       clog << "----------series expansion:" << endl;
        
        result += exam_series1();  cout << '.' << flush;
        result += exam_series2();  cout << '.' << flush;
@@ -382,12 +405,12 @@ unsigned exam_pseries()
        result += exam_series11();  cout << '.' << flush;
        result += exam_series12();  cout << '.' << flush;
        result += exam_series13();  cout << '.' << flush;
+       result += exam_series14();  cout << '.' << flush;
        
-       if (!result) {
-               cout << " passed " << endl;
-               clog << "(no output)" << endl;
-       } else {
-               cout << " failed " << endl;
-       }
        return result;
 }
+
+int main(int argc, char** argv)
+{
+       return exam_pseries();
+}