From a238800e34c1490e1581bbc923a5512dc61ffd11 Mon Sep 17 00:00:00 2001
From: "Vladimir V. Kisil" <kisilv@maths.leeds.ac.uk>
Date: Wed, 31 Jul 2013 16:44:18 +0100
Subject: [PATCH 6/9] Additional log evaluation rule. log(p^a) -> a*log(p) if p
 is positive and a is real.

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

diff --git a/check/exam_inifcns.cpp b/check/exam_inifcns.cpp
index 424aa26..2191172 100644
--- a/check/exam_inifcns.cpp
+++ b/check/exam_inifcns.cpp
@@ -295,6 +295,17 @@ static unsigned inifcns_consist_log()
 	if (!e1.is_equal(e2))
 		++result;
 
+	if (!ex(log(pow(p,a))).is_equal(a*log(p)))
+		++result;
+
+	// shall not do for non-real powers 
+	if (ex(log(pow(p,z))).is_equal(z*log(p)))
+		++result;
+
+	// shall not do for non-positive basis
+	if (ex(log(pow(a,b))).is_equal(b*log(a)))
+		++result;
+
 	return result;
 }
 
diff --git a/ginac/inifcns_trans.cpp b/ginac/inifcns_trans.cpp
index 0d4904a..4b5a1cd 100644
--- a/ginac/inifcns_trans.cpp
+++ b/ginac/inifcns_trans.cpp
@@ -173,6 +173,10 @@ static ex log_eval(const ex & x)
 		if (t.info(info_flags::real))
 			return t;
 	}
+
+	// log(pow(a,b)) -> b*log(a) (if a>0 and b is real)
+	if (is_exactly_a<power>(x) && x.op(0).info(info_flags::positive) && x.op(1).info(info_flags::real))
+		return x.op(1)*log(x.op(0));
 	
 	return log(x).hold();
 }
-- 
1.8.4.rc3

