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

linsolve now able to solve unsimplified equations having const variable. #10575

Closed
Closed
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
3 changes: 2 additions & 1 deletion sympy/solvers/solveset.py
Expand Up @@ -880,6 +880,7 @@ def linear_eq_to_matrix(equations, *symbols):
[f]])

"""
from sympy.simplify.radsimp import collect

if not symbols:
raise ValueError('Symbols must be given, for which coefficients \
Expand All @@ -894,7 +895,7 @@ def linear_eq_to_matrix(equations, *symbols):
row_no = 1

for equation in equations:
f = sympify(equation)
f = collect(equation.expand() ,symbols)
Copy link
Member Author

Choose a reason for hiding this comment

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

To collect coefficients of symbols.

if isinstance(f, Equality):
f = f.lhs - f.rhs

Expand Down
11 changes: 11 additions & 0 deletions sympy/solvers/tests/test_solveset.py
Expand Up @@ -1101,3 +1101,14 @@ def test_issue_8715():
(Interval.open(-2, oo) - FiniteSet(0))
assert solveset(eq.subs(x,log(x)), x, S.Reals) == \
Interval.open(exp(-2), oo) - FiniteSet(1)

def test_issue_10568():
e = [z-1 , m*(x+3*y)+8*z-3 , y-5]
soln = FiniteSet((-15 - 5/m, 5, 1))
assert linsolve(e, [x,y,z]) == soln

@XFAIL
def test_issue_10568_not_fixed():
e = [z-1 , m*(x+3*y)+8*z-3 , y-5]
soln = FiniteSet((-15 - 5/m, 5))
assert linsolve(e, [x,y]) == soln