Message Boards Message Boards


[✓]  One simple equation gets answer, similar one does not?

Posted 1 year ago
8 Replies
2 Total Likes

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}]

I get

{{ }}


8 Replies

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.

Only Reduce is giving values

In[7]:= Reduce[{x + y == 25, y == 4 x}, x]

Out[7]= y == 20 && x == 5


In[8]:= Reduce[{x + y == 12, y == 2 x}, {x}]

Out[8]= y == 8 && x == 4

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.

Is there a reason you don’t 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, Neil. I structured this exercise based on the problem in my algebra book, which specifically asks for it this way:

Solve for x if y=4x and x+y=25

So for the set of values for y of {4x}, provide x. I'm not all that interested in y, and I really don't want to get the value for it.

Oh, well. Solving for {x,y} does work. I'll keep an eye on it. Thanks, all!

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}}  *)

Thanks, Michael.

That works in mathematica online!


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}]


Looks like you accidentally wrote y = 2x instead of y == 2x at some point. Execute Clear[y] and try Solve again.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract