Is my closed solution to the following Heaviside integral correct?

81 Views Asked by At

I'm considering the following integral:

$$\int^a_b H(g(x))\:dx$$

Where $a$ and $b$ are constants, H is the Heaviside function, see

https://en.wikipedia.org/wiki/Heaviside_step_function#Discrete_form

And $g(x)$ some function. In order to evaluate this I've try integration by parts:

$$ \int^a_b {dv\over dx} u \: dx = \left.uv\right|^a_b -\int^a_b {du\over dx} v\: dx $$

Set $u = H(g(x))$ and ${dv\over dx} = 1$. Then:

$$ {du\over dx} = {d\over dx}H(g(x)) = g'(x)\delta(g(x)), \:\: v = \int dx = x $$

The former determined via Wolfram alpha. Substituting we find:

$$ \left. H(g(x)) x \right|^a_b -\int^a_b g'(x)\delta(g(x)) x\: dx $$ $$ H(g(a))a - H(g(b))b -\int^a_b g'(x)\delta(g(x)) x\: dx $$

Now we must evaluate:

$$\int^a_b g'(x)\delta(g(x)) x\: dx$$

I believe I am right in saying that

$$\int^{+\infty}_{-\infty} \delta(g(x)) f(x) dx = \sum_{x_0: \{g(x_0)=0 | -\infty < x_0 < +\infty \}} {f(x_0)\over|g^\prime(x_0)| } $$

Hence

$$\int^a_b g'(x)\delta(g(x)) x\: dx = \sum_{x_0} {g^\prime(x_0) x_0\over|g^\prime(x_0)| } = \sum_{x_0: \{g(x_0)=0 | b\leq x_0\leq a \} } sgn(g^\prime(x_0)) x_0$$

Where $sgn(x)$ is the sign of $x$. Hence

$$\int^a_b H(g(x))\:dx = H(g(a))a - H(g(b))b - \sum_{x_0: \{g(x_0)=0 | b\leq x_0\leq a \} } sgn(g^\prime(x_0)) x_0 $$

If I consider a trivial example:

$$\int^{2\pi}_0 H(\sin(x))\:dx = \pi$$

Wolfram suggest that the answer is $\pi$. The roots we seek are in the range $g(b)<x_i=g^{-1}(0)<g(a) => \sin(0)<x_i=g^{-1}(0)<\sin(2\pi) => 0 <x_i=\sin^{-1}(0)< 0$, which leaves only $x_1=0$. Substituting into my equation we get:

$$ 2\pi H(\sin(2\pi)) - [H(\sin(0))\times0] - (0) =2\pi$$

Clearly my derivation is wrong somewhere. Where have I made a mistake?

2

There are 2 best solutions below

0
On

$H$ is not differentiable and so you cannot use integration by parts (unless you evaluate the limits very carefully). In the present case, better writing simply $$ \int_0^{2\pi}H(\sin x)\,dx=\int_0^\pi 1\,dx=\pi, $$ since $H(\sin x)=0$ for $x\not\in[0,\pi]$.

0
On

The derivation is almost correct, but because you are integrating, the endpoints need to be excluded.

So the solution is

$$ \int_b^a H(g(x)) \,\mathrm{d}x = x H(g(x)) \big|_{b^+}^{a^-} - \sum_{x \in S} x \,\mathrm{sign}(g'(x)) $$

where $S = \{ x : b < x < a \wedge g(x) = 0 \}$ and the surface term is

$$ x H(g(x)) \big|_{b^+}^{a^-} = \lim_{x \to a^-} x H(g(x)) - \lim_{x \to b^+} x H(g(x)). $$

For the specific example,

$$ \begin{align} \int_0^{2\pi} H(\sin x) \,\mathrm{d}x &= x H(\sin x) \big|_{0^+}^{2\pi^-} - \sum_{x \in \{ \pi \}} x \,\mathrm{sign}(\cos x) \\ &= 2\pi \cdot 0 - 0 \cdot 1 - \pi \cdot (-1) \\ &= \pi \end{align} $$

as required.