Here is the example:
Simplify[x + y, x + y == a]
Simplify[x + y, x + y == 5]
Mathematica 9 output:
x+y
5
I expect the complexity of a
to be lower than complexity of Plus[x,y]
, and the result of the first line should be a
.
Even if I specify ComplexityFunction
explicitly:
Simplify[x + y, x + y == a, ComplexityFunction -> LeafCount]
I still get x+y
as a result. It's however obvious that LeafCount[x+y]
is greater than LeafCount[a]
.
Why does Simplify ignore x+y==a
but uses x+y==5
? How can I define the former assumption in a right way?
Simplify[x y, x y == a]
returnsa
. $\endgroup$Simplify[x^2+y^2,x^2+y^2==a]
, andSimplify[x+y,x+y==Cos[a]]
returnsCos[a]
$\endgroup$Simplify[x + y, x + y == Unevaluated[a]]
givesa
...? $\endgroup$Simplify[x+y, x+y == boo[]]
also givesboo[]
. Strange. $\endgroup$Simplify
seems to have a preference for alphabetical order in sums. So you can get the expected result by replacinga
with any symbol that lexically comes afterx
andy
. For example, useSimplify[x + y, x + y == xPlusY]
or justSimplify[x + y,x + y==z]
. It probably tries substitutions not in all permutations but only in alphabetical order when sums are involved. $\endgroup$