-
-
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
remove bug and make it more robust #17442
base: master
Are you sure you want to change the base?
Conversation
✅ Hi, I am the SymPy bot (v147). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
|
It would be nice to see the impact on simplify here. Is there a test one can add that works now and not earlier that illustrates the benefit? |
the newly added test case was not working, now they are working |
although we can separate the equation - |
If this is going to call something like simplify then there probably needs to be an option to prevent that. At the moment separatevars is a fairly simple low-level routine which is used in a few places (not many) and we should be careful that this doesn't slow those cases down. |
It's probably better to rewrite sin/cos as exp: In [28]: e = cos(x+y)+cos(x-y)
In [29]: factor(e.rewrite(exp)).rewrite(sin)
Out[29]: 2⋅cos(x)⋅cos(y) |
It may help but sometime it will make the equation very complex like- In [28]: e=sin(x+y)/cos(x+y)
In [29]: factor(e.rewrite(exp)).rewrite(sin)
Out[29]:
ⅈ⋅((-ⅈ⋅sin(x) + cos(x))⋅(-ⅈ⋅sin(y) + cos(y)) - (ⅈ⋅sin(x) + cos(x))⋅(ⅈ⋅sin(y) +
──────────────────────────────────────────────────────────────────────────────
(-ⅈ⋅sin(x) + cos(x))⋅(-ⅈ⋅sin(y) + cos(y)) + (ⅈ⋅sin(x) + cos(x))⋅(ⅈ⋅sin(y) +
cos(y)))
─────────
cos(y))
in this case, we have to deal with the more complex equation than given one so I think we can't do every time. |
Is this example separable? |
No |
Any news? Can it be taken over by somebody else? |
I would recommend against making separatevars be too smart. Some routines should just do a straigtforward task fast and well. It is the user's (or high-level routine's) job to try rewriting to make it work. |
References to other Issues or PRs
Brief description of what is fixed or changed
During separation,
separatesvars
cheks each multiplicative factors of the equation and find out that the factor is separable or not and it seems good. But if we will send an equation with expand(eq) so all the factor of equation will destroy and nowseparatevars
will may not able to separate the equation. So I have added factor(eq) so that we can make it a multiplicative equation if possible.And second, think is a bug- passing of force into
separatevars
in the function_separatevars.
And the third thing is after getting a multiplicative equation when we are passing each factor again in
separatevars
then maybe after doing simplification of each factor we can get a better result.I tried this and able to separate the more equations. (see added test case)
eg-
eq=exp(x**2+y**2)*(cos(x-y)+cos(x+y))
after passing this term we are getting one of the factors -
(cos(x-y)+cos(x+y))
and passing this only inseparatevars
we are not able to separate it so I think we can pass simplify(factor) every time inseparatevars
so that we can get a simplified equation and then we can easily separate the equation.Other comments
Release Notes