]> www.ginac.de Git - ginac.git/blobdiff - check/exam_pseries.cpp
- added registry for print_context classes (use print_context_class_info::dump_hierar...
[ginac.git] / check / exam_pseries.cpp
index cb65a53361de1ce5fa8edfda060edfab572c1412..8bd785a623ace37925cee58d1e8cda521d7ce9ae 100644 (file)
@@ -3,7 +3,7 @@
  *  Series expansion test (Laurent and Taylor series). */
 
 /*
  *  Series expansion test (Laurent and Taylor series). */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2003 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
  *
  *  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
@@ -27,20 +27,22 @@ static symbol x("x");
 static unsigned check_series(const ex &e, const ex &point, const ex &d, int order = 8)
 {
        ex es = e.series(x==point, order);
 static unsigned check_series(const ex &e, const ex &point, const ex &d, int order = 8)
 {
        ex es = e.series(x==point, order);
-       ex ep = ex_to_pseries(es).convert_to_poly();
+       ex ep = ex_to<pseries>(es).convert_to_poly();
        if (!(ep - d).is_zero()) {
                clog << "series expansion of " << e << " at " << point
                     << " erroneously returned " << ep << " (instead of " << d
                     << ")" << endl;
        if (!(ep - d).is_zero()) {
                clog << "series expansion of " << e << " at " << point
                     << " erroneously returned " << ep << " (instead of " << d
                     << ")" << endl;
-               (ep-d).printtree(clog);
+               clog << tree << (ep-d) << dflt;
                return 1;
        }
        return 0;
 }
 
 // Series expansion
                return 1;
        }
        return 0;
 }
 
 // Series expansion
-static unsigned exam_series1(void)
+static unsigned exam_series1()
 {
 {
+       using GiNaC::log;
+
        unsigned result = 0;
        ex e, d;
        
        unsigned result = 0;
        ex e, d;
        
@@ -98,11 +100,16 @@ static unsigned exam_series1(void)
        d = 1 + t + pow(t, 2) / 2 + pow(t, 3) / 6 + pow(t, 4) / 24 + pow(t, 5) / 120 + pow(t, 6) / 720 + pow(t, 7) / 5040 + Order(pow(x, 8));
        result += check_series(e, 0, d.expand());
        
        d = 1 + t + pow(t, 2) / 2 + pow(t, 3) / 6 + pow(t, 4) / 24 + pow(t, 5) / 120 + pow(t, 6) / 720 + pow(t, 7) / 5040 + Order(pow(x, 8));
        result += check_series(e, 0, d.expand());
        
+       e = log(x);
+       d = e;
+       result += check_series(e, 0, d, 1);
+       result += check_series(e, 0, d, 2);
+       
        return result;
 }
 
 // Series addition
        return result;
 }
 
 // Series addition
-static unsigned exam_series2(void)
+static unsigned exam_series2()
 {
        unsigned result = 0;
        ex e, d;
 {
        unsigned result = 0;
        ex e, d;
@@ -115,7 +122,7 @@ static unsigned exam_series2(void)
 }
 
 // Series multiplication
 }
 
 // Series multiplication
-static unsigned exam_series3(void)
+static unsigned exam_series3()
 {
        unsigned result = 0;
        ex e, d;
 {
        unsigned result = 0;
        ex e, d;
@@ -127,8 +134,25 @@ static unsigned exam_series3(void)
        return result;
 }
 
        return result;
 }
 
+// Series exponentiation
+static unsigned exam_series4()
+{
+       unsigned result = 0;
+       ex e, d;
+       
+       e = pow((2*cos(x)).series(x==0, 5), 2).series(x==0, 5);
+       d = 4 - 4*pow(x, 2) + 4*pow(x, 4)/3 + Order(pow(x, 5));
+       result += check_series(e, 0, d);
+       
+       e = pow(tgamma(x), 2).series(x==0, 3);
+       d = pow(x,-2) - 2*Euler/x + (pow(Pi,2)/6+2*pow(Euler,2)) + Order(x);
+       result += check_series(e, 0, d);
+       
+       return result;
+}
+
 // Order term handling
 // Order term handling
-static unsigned exam_series4(void)
+static unsigned exam_series5()
 {
        unsigned result = 0;
        ex e, d;
 {
        unsigned result = 0;
        ex e, d;
@@ -148,7 +172,7 @@ static unsigned exam_series4(void)
 }
 
 // Series expansion of tgamma(-1)
 }
 
 // Series expansion of tgamma(-1)
-static unsigned exam_series5(void)
+static unsigned exam_series6()
 {
        ex e = tgamma(2*x);
        ex d = pow(x+1,-1)*numeric(1,4) +
 {
        ex e = tgamma(2*x);
        ex d = pow(x+1,-1)*numeric(1,4) +
@@ -180,7 +204,7 @@ static unsigned exam_series5(void)
 }
        
 // Series expansion of tan(x==Pi/2)
 }
        
 // Series expansion of tan(x==Pi/2)
-static unsigned exam_series6(void)
+static unsigned exam_series7()
 {
        ex e = tan(x*Pi/2);
        ex d = pow(x-1,-1)/Pi*(-2) + pow(x-1,1)*Pi/6 + pow(x-1,3)*pow(Pi,3)/360
 {
        ex e = tan(x*Pi/2);
        ex d = pow(x-1,-1)/Pi*(-2) + pow(x-1,1)*Pi/6 + pow(x-1,3)*pow(Pi,3)/360
@@ -190,7 +214,7 @@ static unsigned exam_series6(void)
 }
 
 // Series expansion of log(sin(x==0))
 }
 
 // Series expansion of log(sin(x==0))
-static unsigned exam_series7(void)
+static unsigned exam_series8()
 {
        ex e = log(sin(x));
        ex d = log(x) - pow(x,2)/6 - pow(x,4)/180 - pow(x,6)/2835
 {
        ex e = log(sin(x));
        ex d = log(x) - pow(x,2)/6 - pow(x,4)/180 - pow(x,6)/2835
@@ -199,7 +223,7 @@ static unsigned exam_series7(void)
 }
 
 // Series expansion of Li2(sin(x==0))
 }
 
 // Series expansion of Li2(sin(x==0))
-static unsigned exam_series8(void)
+static unsigned exam_series9()
 {
        ex e = Li2(sin(x));
        ex d = x + pow(x,2)/4 - pow(x,3)/18 - pow(x,4)/48
 {
        ex e = Li2(sin(x));
        ex d = x + pow(x,2)/4 - pow(x,3)/18 - pow(x,4)/48
@@ -209,8 +233,10 @@ static unsigned exam_series8(void)
 }
 
 // Series expansion of Li2((x==2)^2), caring about branch-cut
 }
 
 // Series expansion of Li2((x==2)^2), caring about branch-cut
-static unsigned exam_series9(void)
+static unsigned exam_series10()
 {
 {
+       using GiNaC::log;
+
        ex e = Li2(pow(x,2));
        ex d = Li2(4) + (-log(3) + I*Pi*csgn(I-I*pow(x,2))) * (x-2)
               + (numeric(-2,3) + log(3)/4 - I*Pi/4*csgn(I-I*pow(x,2))) * pow(x-2,2)
        ex e = Li2(pow(x,2));
        ex d = Li2(4) + (-log(3) + I*Pi*csgn(I-I*pow(x,2))) * (x-2)
               + (numeric(-2,3) + log(3)/4 - I*Pi/4*csgn(I-I*pow(x,2))) * pow(x-2,2)
@@ -221,8 +247,10 @@ static unsigned exam_series9(void)
 }
 
 // Series expansion of logarithms around branch points
 }
 
 // Series expansion of logarithms around branch points
-static unsigned exam_series10(void)
+static unsigned exam_series11()
 {
 {
+       using GiNaC::log;
+
        unsigned result = 0;
        ex e, d;
        symbol a("a");
        unsigned result = 0;
        ex e, d;
        symbol a("a");
@@ -261,8 +289,10 @@ static unsigned exam_series10(void)
 }
 
 // Series expansion of other functions around branch points
 }
 
 // Series expansion of other functions around branch points
-static unsigned exam_series11(void)
+static unsigned exam_series12()
 {
 {
+       using GiNaC::log;
+
        unsigned result = 0;
        ex e, d;
        
        unsigned result = 0;
        ex e, d;
        
@@ -287,7 +317,7 @@ static unsigned exam_series11(void)
 }
 
 
 }
 
 
-unsigned exam_pseries(void)
+unsigned exam_pseries()
 {
        unsigned result = 0;
        
 {
        unsigned result = 0;
        
@@ -305,6 +335,7 @@ unsigned exam_pseries(void)
        result += exam_series9();  cout << '.' << flush;
        result += exam_series10();  cout << '.' << flush;
        result += exam_series11();  cout << '.' << flush;
        result += exam_series9();  cout << '.' << flush;
        result += exam_series10();  cout << '.' << flush;
        result += exam_series11();  cout << '.' << flush;
+       result += exam_series12();  cout << '.' << flush;
        
        if (!result) {
                cout << " passed " << endl;
        
        if (!result) {
                cout << " passed " << endl;