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
Solve simplest algebraic equations with dummy parameter #22837
Comments
Simpler example:
Output:
But if we swap sides of the equation |
Not sure what happens, but if you do
You get the expected result. I guess that there should be something like
in Also
works, so looks like a bug. |
Thank you, Oscar! I obtained this quadratic equation (with much more parameters) after substitution in the solution of ordinary differential equation, so it's not very convenient for me to do these manual reorderings and simplifications, I just want to solve it as is. The problem is somewhere in the order of parts of the equation: |
>>> from sympy import *
>>> x, a = symbols("x a")
>>> eq = Eq(0, (4 - 4*x + x**2)/(4*a**2))
>>> print(solveset(eq, x))
>>> print(solveset(simplify(eq), x))
FiniteSet(2)
FiniteSet(2)
|
The In [2]: solve(eq, x)
Out[2]:
⎡ ________ ________⎤
⎢ ╱ 2 ╱ 2 ⎥
⎢ ╲╱ a - 1 ╲╱ a - 1 ⎥
⎢2 - ───────────, 2 + ───────────⎥
⎣ a a ⎦
In [3]: solve([eq], x)
Out[3]: [(2,)] The main branch is here: sympy/sympy/solvers/solvers.py Lines 1106 to 1109 in d822fcb
Try working backwards though and see if you can figure out when bare_f is true or false or what the point of it is.
|
It's a problem with |
Very strange behaviour of
solve
command in SymPy, when I try to solve quadratic equation with parametera
(which is dummy here, because solution doesn't depends on it):Output:
Just
solve
gives two (!) solutions, which depend ona
. After symplifying it gives only solutionx=2
, which is correct. What happens? Commandsolveset
works correctly, but I am interested in usingsolve
command. My SymPy version is 1.8.The text was updated successfully, but these errors were encountered: