Skip to content

Commit

Permalink
Merge pull request sympy#24401 from 1e9abhi1e10/ring
Browse files Browse the repository at this point in the history
fixes puiseux polynomials does not work with algebraic extensions
  • Loading branch information
oscarbenjamin authored Dec 20, 2022
2 parents c87cd36 + de3daa8 commit 9b9f5bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sympy/polys/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ def __pow__(self, n):
elif len(self) == 1:
monom, coeff = list(self.items())[0]
p = ring.zero
if coeff == 1:
if coeff == ring.domain.one:
p[ring.monomial_pow(monom, n)] = coeff
else:
p[ring.monomial_pow(monom, n)] = coeff**n
Expand Down
12 changes: 12 additions & 0 deletions sympy/polys/tests/test_ring_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,18 @@ def test_puiseux():
assert r == -x**QQ(9,5) - x**QQ(26,15) - x**QQ(22,15) - x**QQ(6,5)/3 + \
x + x**QQ(2,3) + x**QQ(2,5)

def test_puiseux_algebraic(): # https://github.com/sympy/sympy/issues/24395

K = QQ.algebraic_field(sqrt(2))
sqrt2 = K.from_sympy(sqrt(2))
x, y = symbols('x, y')
R, xr, yr = ring([x, y], K)
p = (1+sqrt2)*xr**QQ(1,2) + (1-sqrt2)*yr**QQ(2,3)

assert dict(p) == {(QQ(1,2),QQ(0)):1+sqrt2, (QQ(0),QQ(2,3)):1-sqrt2}
assert p.as_expr() == (1 + sqrt(2))*x**(S(1)/2) + (1 - sqrt(2))*y**(S(2)/3)


def test1():
R, x = ring('x', QQ)
r = rs_sin(x, x, 15)*x**(-5)
Expand Down

0 comments on commit 9b9f5bd

Please sign in to comment.