-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Substitution for powers should be like polynomial division #22249 #22656
base: master
Are you sure you want to change the base?
Conversation
Substitution for power is now like polynomial division cf issue sympy#22249 Commentaries update
Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. ❌ There was an issue with the release notes. Please do not close this pull request; instead edit the description after reading the guide on how to write release notes.
Click here to see the pull request description that was parsed.
|
Remove unnecessary lines
combines = b.is_positive and e.is_real or b.is_nonnegative and e.is_nonnegative | ||
|
||
return combines, pow, None | ||
pow = coeff1//coeff2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this now apply to symbolic powers too?
Ping @asmeurer @oscarbenjamin for suggestions/help.
I would also report the issues faced below
Thank You. |
I wonder if some of the ode related issues will stem from the assumption that this partial extraction is not going to work. So the code would have to be inspected and corrected where this assumption is made by checking the substitution result to verify that the target power was removed completely, e.g. |
I would use something like this... combines = b.is_positive and e.is_real or b.is_nonnegative and e.is_nonnegative
-
+ if not combines:
+ # check for partial extraction as in (x**3).subs(x**2, y) -> x*y
+ if coeff1.is_Integer and coeff2.is_Integer and coeff1 >= coeff2:
+ return True, *divmod(coeff1, coeff2)
return combines, pow, None |
References to other Issues or PRs
Fixes #22249
Brief description of what is fixed or changed
_eval_subs in power.py modified : simple division replaced by euclidean division in order to substitute even if pow is not integer
test_issue_22249() Added
Other comments
Release Notes