How can I simplify trivial expressions under the Power?

Here is one example:

(z2p-z2p z3)^-ϵ

The expected output:

z2p^-ϵ (1 - z3)^-ϵ        

Currently I am trying to look at the FullForm and decide the rule like below:

(z2p-z2p z3)^-ϵ /. Plus[x_,Times[-1,x_,y_]] -> x(1-y) //PowerExpand

However, how can I extend it to a general case where there could be multiple terms connected with +-? Or is there a better way to handle?


In a general scenario one would have factors multiplied with these kind of terms.


  expr= ((1 - z2p)^-e (1 - z3)^-e z3^-e (z2p - z2p z3)^-e)/
        ( z2p (-1 + z3)^2 (1 - z2p + z2p z3))

Basically how should one proceed to simplify/Factor out these terms?

  • $\begingroup$ (-z2p)^-ϵ (z3 - 1)^-ϵ is an equally valid output. What criterion should be used to decide between the two? $\endgroup$
    – bbgodfrey
    Sep 3, 2020 at 16:21
  • $\begingroup$ @bbgodfrey I understand this is indeed an ambiguity, but at least either of them is better that keeping the term in the original form (at least when I declare the variables as Reals). Even Mathematica loves to write 2 (1 - x) y // Simplify as -2 (-1 + x) y (probably it takes less strings/internal operations to write second one? ). I personally dont like this output but this hurts less than the examples in this question. It is really annoying that it can not do the simplification/Factor. I expected PowerExpand would have factor out everything using Assumptions but not. $\endgroup$
    – BabaYaga
    Sep 3, 2020 at 17:33
  • $\begingroup$ The case you just mentioned is an artifact of the canonical ordering that Mathematica inflexibly uses. $\endgroup$
    – bbgodfrey
    Sep 3, 2020 at 17:35

2 Answers 2


Let us first introduce a function I will use:

factorMinus[expr_] := Module[{}, (-1)*HoldForm[Evaluate[-expr]]]

Here is your expression (I write it down in a simplified notation to make it more visible):

expr = (z2 - z2*z3)^-e; 

Try this:

MapAt[factorMinus, MapAt[Factor, expr, {1}], {1, 3}] // 
  PowerExpand // ReleaseHold

 (*  z2^-e (1 - z3)^-e  *)

Have fun!

  • $\begingroup$ This works for this example and even for any combination of arbitrary number of such +-. However one would definitely like to apply this in cases where not only single Power but multiple number of Powers are present, in such case this is difficult to apply. $\endgroup$
    – BabaYaga
    Sep 3, 2020 at 7:49
  • 1
    $\begingroup$ I would not expect that one program could do such a work automatically for all possible expressions you meet. If you have a more complex expression, you will have to apply the analogous functions to all parts of your expression that you need to transform. It is not difficult, but requires some programming. By the way, application of the factorMinus is not always necessary, as you may have already noticed. If you have a very large expression I propose first to think do you really need to transform its terms and for what purpose. $\endgroup$ Sep 3, 2020 at 9:37
  • $\begingroup$ yes probably have to go case by case. $\endgroup$
    – BabaYaga
    Sep 3, 2020 at 9:50
  • $\begingroup$ @Boogeyman Please provide an example of the expressions you actually wish to transform. $\endgroup$
    – bbgodfrey
    Sep 3, 2020 at 16:08
  • $\begingroup$ @bbgodfrey, please see the part after EDIT in the question $\endgroup$
    – BabaYaga
    Sep 3, 2020 at 16:56

In light of the recent edit to the question, consider a slightly more difficult case of two Powers:

test2 = (z2p - z2p z3)^-ϵ + (z2p1^2 - z2p1^2 z31^3)^-ϵ1

Define the function,

m[z1_, z2_] := Module[{fac}, fac = List @@ Factor[z1]; 
    If[fac[[1]] < 0, fac[[1 ;; 2]] = -fac[[1 ;; 2]]]; Times @@ (fac^z2)]


test2 /. z1_^z2_ :> m[z1, z2]
(* (-z2p)^-ϵ (-1 + z3)^-ϵ + (-z2p1^2)^-ϵ1 (-1 + z31)^-ϵ1 (1 + z31 + z31^2)^-ϵ1 *)

Note that there is an inherent ambiguity in this process, and indeed in the question itself, namely what to do with an overall factor of -1. I chose to attach it to the second factor, but other options are possible.

  • $\begingroup$ The EDIT part is the kind of expression I am sure everybody encounters. It is unfortunate there is no simpler way to handle this kind of expression. Even if I assume all variables are Reals or Integers (which I tried) this is not possible at least in a simpler fashion. $\endgroup$
    – BabaYaga
    Sep 3, 2020 at 17:20
  • $\begingroup$ @Boogeyman Yes, I am aware of no simpler method. By the way, the example you added appears to be a different issue, how to simplify (1 - z3)^-e/(-1 + z3)^2. In fact, Simplify[(1 - z3)^-e/(-1 + z3)^2] yields (1 - z3)^(-2 - e), as I image you wish. However, Simplify[expr] goes in a different direction. Simplification can be difficult for a number of reasons. Often, if is necessary to force Simplify to emphasize certain simplifications over others. $\endgroup$
    – bbgodfrey
    Sep 3, 2020 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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