# Simplify x+y=5 fails with assumption y = 2x, but works with x = 2y. Why? [duplicate]

I am trying to understand how assumptions and simplification works with this simple example:

x+y=5, assume x = 2y

So I write:

Assuming[x == 2y, Simplify[x+y==5]]


And the result makes sense to me:

3y == 5


But then if want to do

x+y=5, assume y = 2x

and I write:

Assuming[y == 2x, Simplify[x+y==5]]


I get:

x+y==5


when I should be getting:

3x==5


Why?

Update: I know this works: Simplify[x + y == 5] /. y -> 2 x what I want to understand is why Assuming does what it does: Am I using it wrong somehow?

I now tried: Assuming[q == 2 p, Simplify[p + q == 5]] vs Assuming[p == 2 q, Simplify[p + q == 5]] same issue, I am starting to wonder if it has something to do with alphabetical order of the name of the variables.

• Simplify measures "simplicity" via the measure SimplifySimplifyCount[expr]. None of the three expressions is simpler than the other by this measure. So any of the three answers would be acceptable to Simplify. (It is odd that in one case the original is chosen and in the other, the equivalent is.) Apr 15, 2018 at 22:31
• Interesting, thanks for commenting, to be clear, this is not the only case Assuming acts weirdly, this is just the simplest example I could come up with Apr 15, 2018 at 22:56
• I guess there is something else to it, otherwise there would be no difference between in the output of the 2 assumptions Apr 15, 2018 at 23:02
• I tried Reduce and the following happens. This command Assuming[y == 2 x, Reduce[x + y == 5]] // Simplify does not give anything, while this one again gives the correct result Reduce[x + y == 5] /. y -> 2 x // Simplify. Can it have to do with replacement rules by Mma?
– user49048
Apr 15, 2018 at 23:07

As @Michael E2 points out, your results have equal complexity according to Mathematica's default metric. When there's more than one answer, which one Mathematica chooses may depend on its canonical ordering of expressions. You can get it to prefer to eliminate symbols by defining your own ComplexityFunction.
cf[e_] := Count[e, _Symbol, All]

Assuming[y == 2 x, Simplify[x + y == 5, ComplexityFunction -> cf]]

It seems to implicitly prefer y to x, presumably because y` comes later in the alphabet.