Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expr: fixed limit/series incorrect simplification, added regression test #26544

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ Michael Mayorov <marchael@kb.csu.ru>
Michael Mueller <michaeldmueller7@gmail.com>
Michael S. Hansen <michael.hansen@nih.gov>
Michael Sparapany <msparapa@purdue.edu>
Michael Yang <yangmi@umich.edu>
Michael Zingale <michael.zingale@stonybrook.edu>
Michal Grňo <m93a.cz@gmail.com> Michal Grno <m93a.cz@gmail.com>
Michał Radwański <enedil.isildur@gmail.com>
Expand Down
3 changes: 2 additions & 1 deletion sympy/core/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3068,7 +3068,8 @@ def series(self, x=None, x0=0, n=6, dir="+", logx=None, cdir=0):

try:
from sympy.simplify.radsimp import collect
return collect(s1, x) + o
from sympy.simplify.ratsimp import ratsimp
return collect(ratsimp(s1), x) + o
Comment on lines -3071 to +3072
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about calling ratsimp here. If we want to canonicalise the form of the output then it should be done systematically and that really means using ringseries I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

except NotImplementedError:
return s1 + o

Expand Down
7 changes: 7 additions & 0 deletions sympy/core/tests/test_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2286,3 +2286,10 @@ def test_format():

def test_issue_24045():
assert powsimp(exp(a)/((c*a - c*b)*(Float(1.0)*c*a - Float(1.0)*c*b))) # doesn't raise

def test_issue_9173():
p_0, p_1, p_2, p_3, b_0, b_1, b_2 = symbols('p_0:4, b_0:3')
Q = (p_0 + (p_1 + (p_2 + p_3/y)/y)/y)/(1 + ((p_3/(b_0*y) +
(b_0*p_2 - b_1*p_3)/b_0**2)/y + (b_0**2*p_1 - b_0*b_1*p_2 -
p_3*(b_0*b_2 - b_1**2))/b_0**3)/y)
assert Q.series(y, n=3) == b_2*y**2 + b_1*y + b_0 + O(y**3)