Integrate $\sin(|x|)$

142 Views Asked by At

I would like to calculate the indefinite integral of $\sin(|x|)$. Could someone explain me how to integrate expressions involving absolute values in general?

3

There are 3 best solutions below

0
On

Here $-sign(x)\cos x$ does not quite work since it is not continuous at the origin, so you have to use something like $sign(x)(1-\cos x)$.

0
On

Remember that all indefinite integrals differ only by a constant. So it is ok to calculate only one particular form.

For instance $\displaystyle F_{x_0}(x)=\int_{x_0}^xf(t)dt$ is the one that annulates in $x=x_0$. Generally we fix $x_0$ to be either $0$ or a point of interest.

Here considering the absolute value, $x_0=0$ is a perfect candidate.

$\displaystyle \forall x\ge 0,\ F_0(x)=\int_0^x\sin(|t|)dt=\int_0^x\sin(t)dt=\bigg[-\cos(t)\bigg]_0^x=-\cos(x)+1$

$\displaystyle \forall x\le 0,\ F_0(x)=\int_0^x\sin(|t|)dt=\int_0^x\sin(-t)dt=\bigg[+\cos(t)\bigg]_0^x=\cos(x)-1$

So finally $F_0(x)=\operatorname{sgn}(x)\big(1-\cos(x)\big)$


But the technique for a random point would not be fundamentally different, just remember to split the integral along appropriate intervals.

$\begin{array}{ll} x_0\ge 0,x\ge 0 & \displaystyle F(x)=\int_{x_0}^x\sin(|t|)dt=\int_{x_0}^x\sin(t)dt=\cos(x_0)-\cos(x)\\ x_0\le 0,x\le 0 & \displaystyle F(x)=\int_{x_0}^x\sin(|t|)dt=\int_{x_0}^x\sin(-t)dt=\cos(x)-\cos(x_0)\\ x_0\le 0\le x & \displaystyle F(x)=\int_{x_0}^0\sin(-t)dt+\int_{0}^{x}\sin(t)dt=(1-\cos(x_0))+(-\cos(x)+1)\\ x\le 0\le x_0 & \displaystyle F(x)=\int_{x_0}^0\sin(t)dt+\int_{0}^{x}\sin(-t)dt=(-1+\cos(x_0))+(\cos(x)-1)\\ \end{array}$

The general expression is $F(x)=F_0(x)-F_0(x_0)=F_0(x)+C\quad$ as expected.

To conclude the technique for indefinite integrals with absolute values, is to calculate the particular one that annulates when what's inside the absolute value annulates or changes sign. In our case this was simply $x_0=0$.

0
On

I prefer to add another answer, because I'll discuss something different from my other answer here, and all is not completely rigourous.

It is quite easy to see that $|x|'=\operatorname{sgn}(x)$.

On the other hand a primitive of $|x|$ would be $\frac {x^2}2\operatorname{sgn}(x)+C$ or equivalently $\frac 12x|x|+C$ since $|x|=x\operatorname{sgn}(x)$.

If we extend a little our views we could also define the derivative of signum function with the Dirac delta distribution as $\operatorname{sgn}(x)'=2\delta(x)$.


Now let's consider $F(x)=\frac 12x^2\operatorname{sgn}(x)$

We have $F'(x)=x\operatorname{sgn}(x)+\frac 12x^2\operatorname{sgn}(x)'=|x|+x^2\delta(x)$

So the antiderivative of $|x|$ would be given by $\displaystyle \int |x|=F(x)-\int x^2\delta(x)$.

Why is it different from what we found previously ? In fact $x^2$ annulate in $0$ so there is no contribution coming from $\int x^2\delta(x)$ and we have $\int |x|=F(x)$.


Thus we could be tempted to use this technique as a general method to find any antiderivative containing an absolute value. But there is an issue as we will see.

In our case let's have $F(x)=-\operatorname{sgn}(x)\cos(x)$.

$F'(x)=+\operatorname{sgn}(x)\sin(x)-\operatorname{sgn}(x)'\cos(x)=\sin(|x|)-2\delta(x)\cos(x)$

Thus $\displaystyle \int \sin(|x|)=-\operatorname{sgn}(x)\cos(x)+\int 2\delta(x)\cos(x)$

But now cosinus doesn't annulate in $0$ and this is a problem.


If we take the easy path and say that $\int 2\delta(x)\cos(x)=2\cos(0)=2$, the problem is that $\phi(x)=2-\operatorname{sgn}(x)\cos(x)$ is not a proper antiderivative of $\sin(|x|)$.

Because $\int_0^1 \sin(|t|)dt=1-\cos(1)\neq\phi(1)-\phi(0)=(2-\cos(1))-(2-0)=-\cos(1)$

In fact the issue is that the antiderivative is always taken from a reference point, for instance $\displaystyle \int \sin(|x|)=\int_0^x\sin(|t|)dt$

But now we have to evaluate $\displaystyle \int_0^x 2\delta(t)\cos(t)dt$ which is not clearly defined on a non-symetric interval : have a look at this post integral-over-diracs-delta-distribution-with-variable-upper-limit.


Nevertheless, as suggested by the author of the answer, it is possible to consider the smooth $\delta_\varepsilon$ instead and take the limit.

In which case we would have to divide the result by $2$

if $x>0, \displaystyle \lim\limits_{\varepsilon\to 0}\int_0^x 2\delta_\varepsilon(t)\cos(t)dt=\frac 12 (2\cos(0))=1$

And similarly this would be $-1$ for $x<0$ making this integral $\operatorname{sgn}(x)$ for any $x\neq 0$.

Thus we are back to $\phi(x)=\operatorname{sgn}(x)-\operatorname{sgn}(x)\cos(x)$ which is the $F_0(x)=\operatorname{sgn}(x)\big(1-\cos(x)\big)$ given in my other answer (since we can extend $\phi$ in $x=0$ by continuity).


To conclude, we have seen in this little study that it is possible to give a meaning to antiderivatives of composition of functions with absolute value, but this leads to theoretic issues to justify the proper use of the Dirac delta on an interval that is not symetrical over $0$. So finally it is way much easier to directly calculate the original antiderivative on appropriate intervals and try to find a formulation a posteriori that embeds the signum function and/or the absolute value.

Yet we are now guided by the fact it should be something like $\displaystyle \int f(|x|)=\operatorname{sgn}(x)\big(F(|x|)-F(0)\big)$ where $F$ is an antiderivative of $f$.