# How to simplify an expression, using a known term substitution?

I have a complicated algebraic expression that involves a lot of similar terms. In particular, I have a complicated sub-expression involving sums and products that I would like to denote $\alpha$. I would like Mathematica to automatically recognize the occurrence of this sub-expression and replace it with $\alpha$.

For example, say I have the expression:

$$\frac{1 + xy(1+x) + zx^2 + (z + 1)y}{x^2y^2(z+2)(x+1)^2}$$

and I know $\alpha = xy(1+x)$. I would like to simplify this to:

$$\frac{1+\alpha+zx^2 + (z + 1)y}{\alpha^2(z+2)}$$

I know there are several ways of performing the simplification. I just want Mathematica to give me a reasonably simplified expression that exploits the equality $\alpha = xy(1+x)$, since using $\alpha$ is shorter than $xy(1+x)$.

Is there a way to do this?

• Copy & paste is so much more fun than typing & checking. I guess I'll look for another problem... :) – Michael E2 Mar 7 '17 at 15:47
• Try Simplify, e.g., Simplify[expr, a == x y (1 + x)] – Carl Woll Mar 7 '17 at 15:50
• @CarlWoll Thanks! For some reason I had assumed that wouldn't work. If you post an answer I'll accept it. – becko Mar 7 '17 at 15:56