3
$\begingroup$

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?

$\endgroup$
1
  • 2
    $\begingroup$ PolynomialReduce is a good function for computations of this type. $\endgroup$ Apr 16, 2020 at 14:25

2 Answers 2

9
$\begingroup$

If you are looking for an automated process you may find Experimental`OptimizeExpression useful:

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

Experimental`OptimizeExpression[(1 - x) (1 - y) + ((1 - x) (1 - y))/(z + 2)]
Experimental`OptimizedExpression[
 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.

$\endgroup$
7
$\begingroup$
Simplify[(1 - x) (1 - y) + ((1 - x) (1 - y))/(z + 2), z == (1 - x) (1 - y)]

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

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.