3
$\begingroup$

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!
$\endgroup$
2
  • 1
    $\begingroup$ maybe g[x_, y_] := Simplify`PWToUnitStep[f[x, y]] /. UnitStep -> HeavisideTheta // FunctionExpand? $\endgroup$ – kglr Nov 11 '20 at 19:26
  • $\begingroup$ Thanks, it worked! $\endgroup$ – Adam Reis Nov 11 '20 at 19:35
5
$\begingroup$
ClearAll[g]

g[x_, y_] := FunctionExpand[Simplify`PWToUnitStep[f[x, y]] /. UnitStep -> HeavisideTheta]

g[x, y]
0.25 + 0.75 HeavisideTheta[1.5 - x, -0.5 + x, 1.5 - y, -0.5 + y]
$\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.