Skip to main content

Why won't Mathematica Solve a set of two equations for one variable?


For example, if I try to Solve this set of equations


Solve[y == 3 x + 5 && y == -x + 7, {x, y}]

Mathematica gives the right values for x and y. But if I try



Solve[y == 3 x + 5 && y == -x + 7, {x}]

it returns nothing. Why is that? There doesn't seem to be a mathematical reason for it.



Answer



That syntax makes Mathematica assume that y can be anything, and if y is different from 13/2, then there's no x, so it can't solve it for the general case.


In other words, Solve must return results that satisfy the equalities. Replacing x by 1/2, the solution you're looking for, doesn't make the equalities be true. For them to be true, you need to solve for y also


EDIT


It seems Solve's third argument also serves as a list of variables to eliminate. So, you should do


Solve[y == 3 x + 5 && y == -x + 7, {x}, {y}]



{{x -> 1/2}}



Comments