]> www.ginac.de Git - ginac.git/blobdiff - check/exam_powerlaws.cpp
Make power::expand() (x*p)^c -> x^c * p^c, if p>0.
[ginac.git] / check / exam_powerlaws.cpp
index 0903c4e18a392a50721de524eb005a3c64db8d22..b81760357852be8c8a0abe288228d5df85fcb3a7 100644 (file)
@@ -288,6 +288,37 @@ static unsigned exam_powerlaws5()
        return 0;
 }
 
+static unsigned exam_powerlaws6()
+{
+       // check expansion rules for positive symbols
+
+       symbol a("a");
+       symbol b("b");
+       symbol c("c");
+       realsymbol x("x");
+       realsymbol y("y");
+       possymbol p("p");
+       possymbol q("q");
+       numeric half=numeric(1,2);
+
+       ex e1 = pow(5*pow(3*a*b*x*y*p*q,2),7*half*c).expand();
+       ex e2 = pow(p,7*c)*pow(q,7*c)*pow(pow(a*b*x*y,2),numeric(7,2)*c)*pow(45,numeric(7,2)*c);
+       if (!e1.is_equal(e2)) {
+               clog << "Could not expand exponents with positive bases in " << e1 << endl;
+               return 1;
+       }
+
+       ex e3 = pow(-pow(-a*x*p,3)*pow(b*y*p,3),half*c).expand().normal();
+       ex e4 = pow(p,3*c)*pow(pow(a*b*x*y,3),half*c);
+
+       if (!e3.is_equal(e4)) {
+               clog << "Could not expand exponents with positive bases in " << e3 << endl;
+               return 1;
+       }
+
+       return 0;
+}
+
 unsigned exam_powerlaws()
 {
        unsigned result = 0;
@@ -299,6 +330,7 @@ unsigned exam_powerlaws()
        result += exam_powerlaws3();  cout << '.' << flush;
        result += exam_powerlaws4();  cout << '.' << flush;
        result += exam_powerlaws5();  cout << '.' << flush;
+       result += exam_powerlaws6();  cout << '.' << flush;
        
        return result;
 }