From d6114460a50180c1f2b12542ef52eccca8f68af0 Mon Sep 17 00:00:00 2001
From: "Vladimir V. Kisil" <kisilv@maths.leeds.ac.uk>
Date: Tue, 30 Jul 2013 19:47:14 +0100
Subject: [PATCH 5/5] Some more evaluation rules for abs() They evaluate
 absolute values of powers and exponents. Simple checks
 are added as well.

Signed-off-by: Vladimir V. Kisil <kisilv@maths.leeds.ac.uk>
---
 check/exam_inifcns.cpp |   11 +++++++++--
 ginac/inifcns.cpp      |    6 ++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/check/exam_inifcns.cpp b/check/exam_inifcns.cpp
index ba1ba9a..7b77d38 100644
--- a/check/exam_inifcns.cpp
+++ b/check/exam_inifcns.cpp
@@ -223,13 +223,20 @@ static unsigned inifcns_consist_various()
 {
 	unsigned result = 0;
 	symbol n;
-	ex e;
 	
 	if ( binomial(n, 0) != 1 ) {
 		clog << "ERROR: binomial(n,0) != 1" << endl;		
 		++result;
 	}
-	
+
+	realsymbol a("a"), b("b"), x("x"), y("y");
+
+	if (!abs(exp(x+I*y)).eval().is_equal(exp(x)))
+		++result;
+
+	if (!abs(pow(x+I*y,a+I*b)).eval().is_equal(pow(abs(x+I*y),a).eval()))
+		++result;
+
 	return result;
 }
 
diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp
index 8103cd8..e49e297 100644
--- a/ginac/inifcns.cpp
+++ b/ginac/inifcns.cpp
@@ -197,6 +197,12 @@ static ex abs_eval(const ex & 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))
+		return pow(abs(arg.op(0)), arg.op(1).real_part());
+
 	return abs(arg).hold();
 }
 
-- 
1.7.10.4

