5
$\begingroup$

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?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.