]> www.ginac.de Git - ginac.git/blobdiff - ginac/inifcns.cpp
More evaluation rules: abs(x^n) => abs(x)^n (x > 0, n is real).
[ginac.git] / ginac / inifcns.cpp
index 8103cd86bf3ec12ad02a2ebec48aff1b122b0c49..0cb2abbd744798bdc61b38348ad71e84e836bc8c 100644 (file)
@@ -197,6 +197,16 @@ static ex abs_eval(const ex & arg)
        if (is_ex_the_function(arg, abs))
                return arg;
 
        if (is_ex_the_function(arg, abs))
                return arg;
 
+       if (is_ex_the_function(arg, exp))
+               return exp(arg.op(0).real_part());
+
+       if (is_exactly_a<power>(arg)) {
+               const ex& base = arg.op(0);
+               const ex& exponent = arg.op(1);
+               if (base.info(info_flags::positive) || exponent.info(info_flags::real))
+                       return pow(abs(base), exponent.real_part());
+       }
+
        return abs(arg).hold();
 }
 
        return abs(arg).hold();
 }