In Mathematica 11.2, when I try
Solve[{x + y == 12, y == 2 x}, {x}]
I get
{{x -> 4}}
Looks good. But, if I do
Solve[{x + y == 25, y == 4 x}, {x}]
{{ }}
?
Thanks, Michael.
That works in mathematica online!
In[1]:=Solve[{x+y==25,y==4x},{x},{y}] Out[1]={{x->5}}
Curiously, when I do this in 11.2, I get:
Solve::ivar: 2 x is not a valid variable. Solve[{3 x == 25, 2 x == 4 x}, {x}, {2 x}]
Weird.
You can use the old syntax, specifying a list of variables to eliminate in the third argument:
Solve[{x + y == 25, y == 4 x}, {x}, {y}] (* {{x -> 5}} *)
Is there a reason you dont use Solve to solve your two equations with two unknowns (x and y)?
If you change {x} to {x,y} you will always get the complete answer for either set of equations.
Thanks Valeriu and Tanel. It's cool that the Reduce function works, sort of (I would expect given y==2, the result should be in terms of y==2). The biggest question I don't understand is why Solve for the first formula works, but not for the second, in all cases. I can repeat this in both online and the desktop version.
Only Reduce is giving values
In[7]:= Reduce[{x + y == 25, y == 4 x}, x] Out[7]= y == 20 && x == 5
and
In[8]:= Reduce[{x + y == 12, y == 2 x}, {x}] Out[8]= y == 8 && x == 4
I get for both of them:
In[1]:= Solve[{x + y == 12, y == 2 x}, {x}] Out[1]= {} In[2]:= Solve[{x + y == 25, y == 4 x}, {x}] Out[2]= {}
As you try to solve systems with respect to only one variable, the results are correct.