Find $\int_a^b \sin |x| \, \mathrm{d}x $ How to find the integral   $$\int_a^b \sin |x| \, \mathrm{d}x \,?$$
I'm able to obtain definite integral of form $ \int_a^b \lvert\sin x \rvert \, \mathrm{d}x$ but not when the modulus operator is solely on $x$.
 A: Hint: Look at the graph of $\sin x$ and $\sin |x|$ and see how the areas under each relate to each other. 
Hint-er: Split the integral into two parts. $$\int_0^a \sin |x| \, \mathrm{d}x + \int_0^b \sin |x| \, \mathrm{d}x$$
What can you say about each of these integrals? 
For $x>0$, the red graph overlays the blue one where red is $\sin |x|$ and blue is $\sin x$.

MORE HINTS: $$\int_0^b \sin |x| \, \mathrm{d}x = \int_0^b \sin x \, \mathrm{d}x$$
A: All antiderivatives of $\sin|x|$ have the form
$$
c+\int_0^x\sin|t|\,dt
$$
If $x\ge0$, we have
$$
\int_0^x\sin|t|\,dt=\int_0^x\sin t\,dt=1-\cos x
$$
whereas, if $x\le0$,
$$
\int_0^x\sin|t|\,dt=\int_0^x\sin(-t)\,dt=-1+\cos(-x)
$$
so the general antiderivative is
$$
c+f(x)
$$
where
$$
f(x)=\begin{cases}
1-\cos x & \text{if $x\ge0$}\\
-1+\cos(-x) & \text{if $x<0$}
\end{cases}
$$

For a definite integral, there is no problem if $a<b\le0$ or $0\le a<b$. For the case $a\le 0\le b$, just split it as
$$
\int_a^0\sin(-x)\,dx+\int_0^b\sin t\,dt
$$
which is easier than using the antiderivative shown above.
A: Consider
$$
f(x)=\left\{\begin{array}{cl}
\dfrac{x}{|x|}(1-\cos(x))&\text{if }x\ne0\\
0&\text{if }x=0\end{array}\right.
$$
If $x\gt0$, then $f'(x)=\sin(x)$. If $x\lt0$, then $f'(x)=-\sin(x)$. The mean value theorem says that $f'(0)=0$. Therefore,
$$
f'(x)=\sin(|x|)
$$
A: $\because\int\sin|x|~dx$
$=\int\sin(x~\text{sgn}(x))~dx$
$=\text{sgn}(x)\int\sin x~dx$
$=\text{sgn}(x)\int_0^x\sin x~dx+C$
$=\text{sgn}(x)[-\cos x]_0^x+C$
$=\text{sgn}(x)(1-\cos x)+C$
$\therefore\int_a^b\sin|x|~dx$
$=[\text{sgn}(x)(1-\cos x)]_a^b$
$=\text{sgn}(b)(1-\cos b)-\text{sgn}(a)(1-\cos a)$
