# Denoting large recurring parts of an equation by a variable

Suppose I have formula like the following:

(1 - x) (1 - y) + ((1 - x) (1 - y))/(z + 2)


Obviously, (1 - x) (1 - y) is found a couple of places in the formula.

How do I denote (1 - x) (1 - y) by z and thereby simplify my formula?

• PolynomialReduce is a good function for computations of this type. – Daniel Lichtblau Apr 16 '20 at 14:25

## 2 Answers

If you are looking for an automated process you may find ExperimentalOptimizeExpression useful:

\$Context = "Compile"; (* improve formatting for copy *)

ExperimentalOptimizeExpression[(1 - x) (1 - y) + ((1 - x) (1 - y))/(z + 2)]

ExperimentalOptimizedExpression[
Block[{$$1,$$2, $$3,$$4},
$$1 = -x;$$2 = 1 + $$1;$$3 = -y; $$4 = 1 +$$3; $$2$$4 + ($$2$$4)/(2 + z)
]
]


Or perhaps a simple replacement can suit your needs:

(1 - x) (1 - y) + ((1 - x) (1 - y))/(z + 2) /. ((1 - x) (1 - y)) :> zz

zz + zz/(2 + z)


I used zz instead of z for clarity.

Simplify[(1 - x) (1 - y) + ((1 - x) (1 - y))/(z + 2), z == (1 - x) (1 - y)]


$$\frac{z (z+3)}{z+2}$$