From: Vladimir V. Kisil Date: Mon, 11 Sep 2017 21:12:36 +0000 (+0200) Subject: [PATCH] Fix bug in evaluation of real and imaginary parts of powers. X-Git-Tag: release_1-7-3~18 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=commitdiff_plain;h=ac58816ee70e2f9e8d863f3869ce512a4009ddc9;p=ginac.git [PATCH] Fix bug in evaluation of real and imaginary parts of powers. Be more careful when simplifying Re(a^c) -> a^c and Im(a^c) -> 0. Thanks to Jan Rheinländer for reporting this. --- 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; }