Evaluate abs(z)^(2n) -> z^n * conjugate(z)^n.
authorVladimir V. Kisil <kisilv@maths.leeds.ac.uk>
Wed, 31 Dec 2014 18:07:26 +0000 (18:07 +0000)
committerRichard Kreckel <kreckel@ginac.de>
Wed, 31 Dec 2014 18:07:26 +0000 (18:07 +0000)
ginac/inifcns.cpp

index 02c909f..d4087e2 100644 (file)
@@ -302,10 +302,12 @@ static ex abs_imag_part(const ex& arg)
 
 static ex abs_power(const ex & arg, const ex & exp)
 {
-       if (arg.is_equal(arg.conjugate()) && ((is_a<numeric>(exp) && ex_to<numeric>(exp).is_even())
-                                               || exp.info(info_flags::even)))
-               return power(arg, exp);
-       else
+       if ((is_a<numeric>(exp) && ex_to<numeric>(exp).is_even()) || exp.info(info_flags::even)) {
+               if (arg.info(info_flags::real) || arg.is_equal(arg.conjugate()))
+                       return power(arg, exp);
+               else
+                       return power(arg, exp/2)*power(arg.conjugate(), exp/2);
+       } else
                return power(abs(arg), exp).hold();
 }