Integral of Absolute Value of $\sin(x)$

2.3k Views Asked by At

For the Integral: $\int |\sin (ax)|$, it is fairly simple to take the Laplace transform of the absolute value of sine, treating it as a periodic function.

$$\mathcal L(|\sin (ax)|) = \frac{\int_0^\frac{\pi} {a} e^{-st} \sin (ax)} {1 - e^{-\frac{ \pi s} {a}}} = \frac{a (1 + e^{-\frac{ \pi s} {a}})} {(a^2 +s^2)(1 - e^{-\frac{ \pi s} {a}})} $$

Then the integral of the absolute value would simply be $ 1/s $ times the Laplace transform. Splitting into partial fractions we have:

$$\mathcal L(\int |\sin (ax)|) = \frac{a (1 + e^{-\frac{ \pi s} {a}})} {s(a^2 +s^2)(1 - e^{-\frac{ \pi s} {a}})} = \frac{(1 + e^{-\frac{ \pi s} {a}})} {as(1 - e^{-\frac{ \pi s} {a}})} - \frac{s (1 + e^{-\frac{ \pi s} {a}})} {a(a^2 +s^2)(1 - e^{-\frac{ \pi s} {a}})} $$

The first term is close to the floor function, when separated:

$$ \frac{(1 + e^{-\frac{ \pi s} {a}})} {as(1 - e^{-\frac{ \pi s} {a}})} = \frac{(1 - e^{-\frac{ \pi s} {a}}) + 2e^{-\frac{ \pi s} {a}}} {as(1 - e^{-\frac{ \pi s} {a}})} = \frac{1} {as} + \frac{2e^{-\frac{ \pi s} {a}}} {as(1 - e^{-\frac{ \pi s} {a}})}$$

This leads to $$ \frac{1} {a} + \frac {2\cdot\text{floor}(\frac{ax}{\pi})} {a}$$

Since the second term looks to be $ s/a^2 $ multiplied by the original function, this points to the derivative, or $$-1\cdot\text{sign}(\sin(ax))\cos (ax)/a$$, for a total integral is:

$$ \frac{1} {a} + \frac {2\cdot \text{floor}(\frac{ax}{\pi})} {a} -\text{sign}(\sin(ax))\cos(ax)/a$$

The Laplace transform method to evaluate an integral seems bulky - is there a better method than this? And what is the cosine version?

2

There are 2 best solutions below

0
On

Without loss of generality, let us assume $a=\pi$ and compute

$$\int_0^X|\sin(\pi x)|dx.$$

The function has period $1$ so that when integrating from $0$ to $X$, there are $\lfloor X\rfloor$ whole periods and a partial one from $X-\lfloor X\rfloor$ to $X$, i.e. by shifting, from $0$ to $X-\lfloor X\rfloor$.

Hence

$$\int_0^X|\sin(\pi x)|dx=\lfloor X\rfloor\int_0^1\sin(\pi x)dx+\int_0^{X-\lfloor X\rfloor}\sin(\pi x)dx=\frac1\pi\left(2\lfloor X\rfloor-\cos(\rfloor\pi x)\Big|_0^{X-\lfloor X\rfloor}\right)=\frac1\pi\left(2\lfloor X\rfloor+1-\cos(\pi(X-\lfloor X\rfloor)\right).$$

enter image description here

For the cosine version, shift the argument by $\dfrac\pi2$.

2
On

Suppose $F(x)$ is an antiderivative of $|\sin(x)|$. On the interval $[n\pi, (n+1)\pi]$, $|\sin(x)| = (-1)^n \sin(x)$, so we must have $F(x) = (-1)^{n+1}\cos(x) + c_n$ there, where $c_n$ is some constant. Comparing the values at $n\pi$ from both sides, since $\cos(n\pi) = (-1)^n$, we get $ 1 + c_{n-1} = -1 + c_n$, i.e. $c_n = c_{n-1} + 2$. Thus we could take $c_n = 2 n$, i.e. since $n = \lfloor x/\pi \rfloor$, $$F(x) = 2 \lfloor x/\pi \rfloor - (-1)^{\lfloor x/\pi \rfloor} \cos(x)$$