This question derives from this one, about mathematics and Maple.

Consider the following discontinuous function:

f[x_] := 1 + HeavisideTheta[x - 2] + (Sin[π x] + 1) (HeavisideTheta[x - 2] - HeavisideTheta[x - 1])

enter image description here

Recall that the total variation of a function is: $\int\limits_{-\infty}^\infty \left| {\partial f(x) \over \partial x} \right | dx$. Clearly this is non-negative and for the function just listed must be positive. Nevertheless, when we compute this integral we find:

Integrate[Abs[D[f[x], x]], {x, -\[Infinity], \[Infinity]}]

(* 0 *)

Why? Incidentally, the derivative itself is given as:

DiracDelta[-2 + x] + π Cos[π x] 
        (HeavisideTheta[-2 + x] -HeavisideTheta[-1 + x]) + 
        (DiracDelta[-2 + x] - DiracDelta[-1 + x]) (1 + Sin[π x])

If we use Piecewise,

f[x_] := Piecewise[
           {{1, x < 0}, 
            {Sin[π x], 0 <= x <= 1}, 
            {2, x > 1}}];

the total variation is given as

(* 2 *)

which is also not correct (as the cited question explains). Presumably this is because Mathematica does a Riemann integral (effectively ignoring the indeterminate discontinuities).

  • $\begingroup$ If you look at D[f[x], x] for your piecewise function, you can see that the derivative has definition Indeterminate at the two discontinuities. $\endgroup$ – bill s Mar 1 '17 at 18:44
  • $\begingroup$ There are two problems here: (i) Taking the absolute of DiracDelta does not seem to work as expected and (ii) integrating HeavisideTheta gives zero. I don't know what to do about (i), unless you are willing to change signs manually. About (ii), you can replace HeavisideTheta by UnitStep, which has a numerical value at x=0, like this: df[x_] := Evaluate[D[f[x], x]] /. HeavisideTheta -> UnitStep $\endgroup$ – Felix Mar 1 '17 at 20:27
  • $\begingroup$ So I think the problem reduces effectively to "How take Abs of DiracDelta" or "How to solve Integrate[Abs[DiracDelta[x]], {x, -\[Infinity], \[Infinity]}] $\endgroup$ – Felix Mar 1 '17 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.