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. – whuber Jan 17 '13 at 01:48Simplify[x^2+y^2,x^2+y^2==a], andSimplify[x+y,x+y==Cos[a]]returnsCos[a]– Cassini Jan 17 '13 at 02:03Simplify[x + y, x + y == Unevaluated[a]]givesa...? – kglr Jan 17 '13 at 02:09Simplify[x+y, x+y == boo[]]also givesboo[]. Strange. – Szabolcs Jan 17 '13 at 02:15Simplifyseems to have a preference for alphabetical order in sums. So you can get the expected result by replacingawith any symbol that lexically comes afterxandy. 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. – Jens Jan 17 '13 at 07:21