6

Simplify may or may not simplify depending on the symbols you use for its assumptions are good. For example, here is a case where Simplify is uncooperative

Simplify[b + c, b + c == a]
(* b + c *)

Here is a case where Simplify is happy with using the assumptions because it likes x, y and z.

Simplify[x + y, x + y == z]
(* z *)

Obviously Simplify is guilty of symbol favoritism. How do I formulate the assumptions in Simplify so that it will consistently simplify?

QuantumDot
  • 19,601
  • 7
  • 45
  • 121

2 Answers2

4

There is an old mathgroup discussion on this. The issue is that Simplify uses a Groebner basis and this is dependent on lexical order. The suggestion for getting around this was to use this code from Adam Strzebonski.

VOISimplify[vars_, expr_, assum_: True] := Module[{perm, ee, best},
  perm = Permutations[vars];
  ee = (FullSimplify @@ ({expr, assum} /. Thread[vars -> #])) & /@ 
    perm;
  best = Sort[Transpose[{LeafCount /@ ee, ee, perm}]][[1]];
  best[[2]] /. Thread[best[[3]] -> vars]]

Then we have

VOISimplify[{a, b, c}, b + c, b + c == a]

a

However, checking all lexical orders could be expensive... I am no expert on this but just remember I had a similar problem in 2005. It is probably time to have further discussions on this issue.

Hugh
  • 16,387
  • 3
  • 31
  • 83
  • Nice find on the old mathgroup discussion. It's too bad you have to manually check for all permutations. – QuantumDot Jul 28 '18 at 16:54
  • @QuantumDot Thanks for accepting. It might be worth asking a new question to see if there are alternative approaches to the one I found from 2005. This seems to be a very basic need in computer algebra and there should be a better method rather than looking at all permutations. I was hoping for a good discussion on the problem but no one seems to have responded to your attractively written question. – Hugh Jul 30 '18 at 08:36
1

In this simple case, converting the equation to a Rule and using ReplaceAll works.

b + c /. Rule @@ (b + c == a)

(* a *)

or just

b + c /. b + c -> a

However, it would generally be better to restructure the Rule since replacement works better (more consistently) when the LHS of the Rule is as simple as possible.

b + c /. b -> a - c

Or

b + c /. c -> a - b
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • The simple case is the result of isolating the issue in a bigger problem. The point of using Simplify with assumptions is to use transformations to make things simpler. – QuantumDot Jul 26 '18 at 19:29