Is there a documentation for the function Simplify`PWToUnitStep? This is a function which can be used to express a Piecewise function as a sum of UnitStep functions. I used it in the following way (in the last line of the provided code):
hfun[h_, J1_, J2_] := Sign[h] (Abs[h] - (Abs[J2] - Abs[J1]))/2
Jfun[h_, J1_, J2_] := (Abs[J2] + Abs[J1] - Abs[h])/2
Field1Evolution[h_, J1_, J2_] :=
Piecewise[{{Sign[h] J1,
Abs[J2] >= Abs[J1] &&
Abs[h] >= Abs[J1] + Abs[J2]}, {Sign[J1] hfun[h, J1, J2],
Abs[J2] >= Abs[J1] && (Abs[J2] + Abs[J1]) >
Abs[h] && (Abs[J2] - Abs[J1]) < Abs[h]}, {0,
Abs[J2] >= Abs[J1] && (Abs[J2] - Abs[J1]) >= Abs[h]}, {Sign[h] J1,
Abs[J1] > Abs[J2] &&
Abs[h] >= Abs[J2] + Abs[J1]}, {Sign[J1] hfun[h, J1, J2],
Abs[J1] > Abs[J2] && (Abs[J2] + Abs[J1]) >
Abs[h] && (Abs[J1] - Abs[J2]) < Abs[h]}, {Sign[J1] h,
Abs[J1] > Abs[J2] && (Abs[J1] - Abs[J2]) >= Abs[h]}}]
Simplify`PWToUnitStep[Field1Evolution[h, J1, J2]]
but the output includes some terms like 1 - UnitStep[-Abs[J1] + Abs[J2]] instead of simply UnitStep[+Abs[J1] - Abs[J2]], I know that the two expressions are the same but I would like the second as output, for some reasons. Can someone help me in getting only terms with UnitStep instead of `1-Unitstep`?
UnitStep: It is equal to $0$ for $x<0$ and $1$ for $x\geq0$. Hence1 - UnitStep[x]is not equivalent toUnitStep[-x], because of the discontinuity at $x=0$:1 - UnitStep[0] == 0whileUnitStep[-0] == 1. You can also take a look at this image to see the transformations that the undocumented (!) functionSimplify`PWToUnitStepmakes. $\endgroup$Simplify`PWToUnitStepis undocumented, we have posts listing useful undocumented functions though: mathematica.stackexchange.com/a/133530/1871 $\endgroup$1 - UnitStep, beacuse sooner or later you need the negation of $\geq$ or $\leq$, which leads to $<$ and $>$. Take a look at this example:s = Simplify`PWToUnitStep[Piecewise[{{1, a >= b}, {2, b >= c}}]]. The first term in the output represents $a \geq b$, but the second term correctly represents $a<b \wedge b\geq c$. If you blindly replace1 - UnitStep[x]withUnitStep[-x], you will get wrong result for the edge cases:{s, s /. 1 - UnitStep[x_] :> UnitStep[-x]} /. {a -> 1, b -> 1, c -> 1}results in{1, 3}. $\endgroup$