# Simplify expressions by automated substitution of repeated terms

I would like to know whether there is a way in Mathematica to simplify an expression including the introduction of symbols for repeated terms, like so:

SimplifyWithSubstitution[(a+b)^7+(a+b)^3+(a+b)^2-a-b]

should yield

C^7+C^3+C^2-C, C=a+b

Note that I do want Mathematica to figure out that the expression can be shortened by substituting a+b.

• Shouldn't that be - a - b in the last part? Anyway: Eliminate[{res == (a + b)^7 + (a + b)^3 + (a + b)^2 - a - b, c == a + b}, {a, b}] – J. M. is in limbo Nov 14 '17 at 13:09
• Of course there was a sign error, thanks! Your proposal requires the user to recognize that a+b is repeated and may be replaced, I want MMA to do this. – Rainer Glüge Nov 14 '17 at 13:42
• ExperimentalOptimizeExpression[] gets pretty close: ExperimentalOptimizeExpression[(a + b)^7 + (a + b)^3 + (a + b)^2 - a - b] – J. M. is in limbo Nov 14 '17 at 13:44
• Well thanks, thats what I needed! – Rainer Glüge Nov 14 '17 at 14:19