Skip to content

Commit

Permalink
Merge pull request #26546 from lorenzwinkler1/improve-power-assumptions
Browse files Browse the repository at this point in the history
improve assumptions of roots of non-real expression
  • Loading branch information
oscarbenjamin committed Apr 26, 2024
2 parents fc7750f + e676709 commit 95085aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ Liwei Cai <cai.lw123@gmail.com>
Ljubiša Moćić <3rdslasher@gmail.com>
Lokesh Sharma <lokeshhsharma@gmail.com> <your_email@youremail.com>
Longqi Wang <iqgnol@gmail.com>
Lorenz Winkler <lorenz.winkler@tuwien.ac.at>
Lorenzo Contento <lorenzo.contento@gmail.com> Lorenzo Contento <lcontento@users.noreply.github.com>
Lorenzo Contento <lorenzo.contento@gmail.com> lcontento <lcontento@users.noreply.github.com>
Louis Abraham <louis.abraham@yahoo.fr> <louisabraham@users.noreply.github.com>
Expand Down
4 changes: 3 additions & 1 deletion sympy/core/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ def _eval_is_extended_real(self):
return ok

if real_b is False and real_e: # we already know it's not imag
if isinstance(self.exp, Rational) and self.exp.p == 1:
return False
from sympy.functions.elementary.complexes import arg
i = arg(self.base)*self.exp/S.Pi
if i.is_complex: # finite
Expand Down Expand Up @@ -1837,6 +1839,6 @@ def _eval_difference_delta(self, n, step):
power.add((object, object), Pow)

from .add import Add
from .numbers import Integer
from .numbers import Integer, Rational
from .mul import Mul, _keep_coeff
from .symbol import Symbol, Dummy, symbols
12 changes: 11 additions & 1 deletion sympy/core/tests/test_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def test_issue_14815():
assert sqrt(x).is_extended_negative is False
x = Symbol('x', extended_real=True)
assert sqrt(x).is_extended_negative is False
assert sqrt(zoo, evaluate=False).is_extended_negative is None
assert sqrt(zoo, evaluate=False).is_extended_negative is False
assert sqrt(nan, evaluate=False).is_extended_negative is None


Expand Down Expand Up @@ -651,3 +651,13 @@ def test_powers_of_I():
def test_issue_23918():
b = S(2)/3
assert (b**x).as_base_exp() == (1/b, -x)


def test_issue_26546():
x = Symbol('x', real=True)
assert x.is_extended_real is True
assert sqrt(x+I).is_extended_real is False
assert Pow(x+I, S.Half).is_extended_real is False
assert Pow(x+I, Rational(1,2)).is_extended_real is False
assert Pow(x+I, Rational(1,13)).is_extended_real is False
assert Pow(x+I, Rational(2,3)).is_extended_real is None

0 comments on commit 95085aa

Please sign in to comment.