# How to transform the regions in which a piecewise function are defined?

I have a function f[x,y,z] that has a piecewise definition, i.e., its values depends on the ranges of the arguments. Now suppose I have a coordinate transformation {X[x,y,z],Y[x,y,z],Z[x,y,z]}. As a function of the new variables the ranges will be different. How can I use Mathematica to give me the ranges in the new variables?

For example, let

f[x_,y_,z_] := a HeavisideTheta[x] + b HeavisideTheta[-x].


Now consider

X[x_,y_,z_] = z(x-y)
Y[x_,y_,z_] = z(x+y)
Z[x_,y_,z_] = z


Clearly in the new variables the ranges will be different. Indeed the inverse is $$(x,y,z)=\left(\frac{X+Y}{2Z},\frac{Y-X}{2Z},Z\right)$$ and it is clear that $$x<0$$ and $$x>0$$ now depend on whether $$Y, $$Y>X$$ and $$Z<0$$ and $$Z>0$$.

I want a systematic way of obtaining these regions in the new coordinates using Mathematica.

You can use UnitSpet instead of HeavisideTheta and PiecewiseExpand which converts nested piecewise functions into a single piecewise function:

f[x_, y_, z_] := a UnitStep[x] + b UnitStep[-x] // PiecewiseExpand


Then you can use it like this:

f[x, y, z] /. {x -> (x + y)/(2 z), y -> (y - x)/(2 z), z -> z} // FullSimplify


or

f[(x + y)/(2 z), (y - x)/(2 z), z] // FullSimplify


You can see the new conditions in the definition: (x + y) z > 0...