# How to convert a Piecewise function in a HeavisideTheta function?

I want to convert a Piecewise function in a HeavisideTheta function in order to correctly evaluate its derivatives at the point of abrupt change and then integrate the result along the axis. How can I do that? The function is given by:

xi=0.5;
yi=0.5;
f[x_,y_]:=Piecewise[{{1, 1-yi<=y<=1+yi&&1-xi<=x<=1+xi&&}}, 0.25]

Thanks!

• maybe g[x_, y_] := SimplifyPWToUnitStep[f[x, y]] /. UnitStep -> HeavisideTheta // FunctionExpand? – kglr Nov 11 '20 at 19:26
• Thanks, it worked! – Adam Reis Nov 11 '20 at 19:35

ClearAll[g]
g[x_, y_] := FunctionExpand[SimplifyPWToUnitStep[f[x, y]] /. UnitStep -> HeavisideTheta]

0.25 + 0.75 HeavisideTheta[1.5 - x, -0.5 + x, 1.5 - y, -0.5 + y]
`