From ac58816ee70e2f9e8d863f3869ce512a4009ddc9 Mon Sep 17 00:00:00 2001 From: "Vladimir V. Kisil" Date: Mon, 11 Sep 2017 23:12:36 +0200 Subject: [PATCH] [PATCH] Fix bug in evaluation of real and imaginary parts of powers. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Be more careful when simplifying Re(a^c) -> a^c and Im(a^c) -> 0. Thanks to Jan Rheinländer for reporting this. --- ginac/power.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ginac/power.cpp b/ginac/power.cpp index 26194928..a45e1fa3 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -669,7 +669,8 @@ ex power::real_part() const // basis == a+I*b, exponent == c+I*d const ex a = basis.real_part(); const ex c = exponent.real_part(); - if (basis.is_equal(a) && exponent.is_equal(c)) { + if (basis.is_equal(a) && exponent.is_equal(c) && + (a.info(info_flags::nonnegative) || c.info(info_flags::integer))) { // Re(a^c) return *this; } @@ -704,7 +705,8 @@ ex power::imag_part() const // basis == a+I*b, exponent == c+I*d const ex a = basis.real_part(); const ex c = exponent.real_part(); - if (basis.is_equal(a) && exponent.is_equal(c)) { + if (basis.is_equal(a) && exponent.is_equal(c) && + (a.info(info_flags::nonnegative) || c.info(info_flags::integer))) { // Im(a^c) return 0; } -- 2.44.0