Antiderivative of $|\sin(x)|$ Because $$\int_0^{\pi}\sin(x)\,\mathrm{d}x=2,$$ then $$\int_0^{16\pi}|\sin(x)|\,\mathrm{d}x=32.$$
And Wolfram Alpha agrees to this, but when I ask for the indefinite integral $$\int|\sin(x)|\,\mathrm{d}x,$$ Wolfram gives me $$-\cos(x)\,\mathrm{sgn}(\sin(x))+c.$$ However, $$[-\cos(x)\,\mathrm{sgn}(\sin(x))]_0^{16\pi}=0,$$ So what's going on here? What is the antiderivative of $|\sin(x)|$?
 A: The $c$ is important here! This is a subtle issue that comes up with formulas for antiderivatives: at any point where the antiderivative "without the $c$" is discontinuous, the value of $c$ can change. 
Suppose $I$ is an interval between two consecutive roots of $\sin(x)$.


*

*If $\sin(x)$ is positive on $I$, then $|\sin(x)| = \sin(x)$ and its antiderivative is $-\cos(x) + c$. 

*If $\sin(x)$ is negative on $I$, then $|\sin(x)|  = -\sin(x)$ and its antiderivative is $\cos(x) + c$. 
So one antiderivative of $\sin(x)$ really is 
$$-\cos(x)\operatorname{sgn}(\sin(x)) + c,$$ at least on every such interval $I$. And of course the only points left out are the roots of $\sin(x)$, which form a discrete set.  Here is a graph of that function, with $c = 0$, from Wolfram Alpha. As you can see. it has a jump discontinuity at each root of $\sin(x)$. 

The reason that the integrals in the original post don't work out is that if we want an antiderivative that is defined on a region that is more than the interval between two roots, the $c$ must change at every root of $\sin(x)$ to give a continuous antiderivative. This is why the naive integral calculation done in the post is flawed - because $c$ is only constant on each interval $I$. 
If you look at a graph of $-\cos(x)\operatorname{sgn}(\sin(x))$ above, you will see that it has a jump discontinuity of $2$ at each root (because $\int_0^\pi \sin(x) = 2$), and that it does "flatten out" at each root. So an antiderivative of $|\sin(x)|$ defined on all of $\mathbb{R}$ is $$-\cos(x)\operatorname{sgn}(\sin(x)) + j(x) + c,$$ where $j(x)$ is a particular step function that increases by $2$ at each root of $\sin(x)$.  But, in a table of integrals,the $j(x)$ may seem to be "hidden" inside the $c$. 

We can look at another example. which is a little easier because it does not have any periodic nature. Consider $\int |e^x - 1|\,dx$.  It is easy to work out an antiderivative $f(x)$ in $\mathbb{R} \setminus \{0\}$:
$$
f(x) = \begin{cases} e^x - x + c & ; x > 0, \\
-e^x + x + c & ; x < 0.
\end{cases}
$$
We may be tempted to write this as $f(x) = (e^x - x)\operatorname{sgn}(e^x - 1) + c$, and that is correct on $\mathbb{R} \setminus \{0\}$, although the '$c$' can be different on each side of $0$. 
Now, let's look at the graph of $f(x)$ (with $c = 0$ everywhere) from Wolfram Alpha. There is a jump discontinuity at $x = 0$.

You can see (and verify algebraically) that 
$$\lim_{x \to 0^-} f'(x) = 0 = \lim_{x \to 0^+} f'(x) = (e^x - 1)\big |_{x =0}.$$ 
So we can make $f$ continuous and differentiable on $\mathbb{R}$ by choosing $c$ appropriately on each side of $0$ to eliminate the jump discontinuity. The resulting function will be an antiderivative of $|e^x - 1|$ that is correct on all of $\mathbb{R}$.
A: For $x\in[n\pi,(n+1)\pi]$, we get
$$
\int_0^{n\pi}|\sin(t)|\,\mathrm{d}t=2n\tag{1}
$$
and
$$
\begin{align}
\int_{n\pi}^x|\sin(t)|\,\mathrm{d}t
&=\int_0^{x-n\pi}\sin(t)\,\mathrm{d}t\\
&=1-\cos(x-n\pi)\tag{2}
\end{align}
$$
Piecing $(1)$ and $(2)$ together yields
$$
\int_0^x|\sin(t)|\,\mathrm{d}t=1-\cos(x-\pi\overbrace{\lfloor x/\pi\rfloor}^n)+2\overbrace{\lfloor x/\pi\rfloor}^n\tag{3}
$$
A: let $$f(x) = \int_0^x |\sin x| \, dx = (1-\cos x), 0\le x \le \pi.$$  since the integrand is $\pi$-periodic, we can extend the formula for $$f(x) = f(\pi) + f(x-\pi), \pi \le x \le 2\pi$$ and so on. you can verify that $$f(n\pi) = 2n  \text{ for all integer } n.$$
 in particular $f(16\pi) = 32.$
A: Using symmetry :
$\int_0^\pi|\sin x|dx=2$ then $\int_0^{16\pi}|\sin x|dx=16.2=32$
A: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\dsc}[1]{\displaystyle{\color{red}{#1}}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\Li}[1]{\,{\rm Li}_{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
$\ds{}$
\begin{align}&\color{#66f}{\large\int\verts{\sin\pars{x}}\,\dd x}
=x\verts{\sin\pars{x}}-\int x\,{\rm sgn}\pars{\sin\pars{x}}\cos\pars{x}\,\dd x
\\[5mm]&=x\verts{\sin\pars{x}}
-\int\,{\rm sgn}\pars{\sin\pars{x}}\,\dd\bracks{\cos\pars{x} + x\sin\pars{x}}
\\[1cm]&=x\verts{\sin\pars{x}}
-\bracks{\cos\pars{x} + x\sin\pars{x}}\,{\rm sgn}\pars{\sin\pars{x}}
\\[5mm]&+\int\bracks{\cos\pars{x} + x\sin\pars{x}}2\delta\pars{\sin\pars{x}}
\cos\pars{x}\,\dd x
\\[1cm]&=-\cos\pars{x}\,{\rm sgn}\pars{\sin\pars{x}}
+2\int\delta\pars{\sin\pars{x}}\,\dd x
\\[5mm]&=\color{#66f}{\large -\cos\pars{x}\,{\rm sgn}\pars{\sin\pars{x}}
+2\sum_{n=-\infty}^{\infty}\ \int\delta\pars{x - n\pi}\,\dd x}
\end{align}

Then,
$$
\int_{0}^{16\pi}\verts{\sin\pars{x}}\,\dd x
=\overbrace{\left.\vphantom{\LARGE A}-\cos\pars{x}\,{\rm sgn}\pars{\sin\pars{x}}
\right\vert_{\ 0}^{\ 16\pi}}^{\ds{=\ \dsc{0}}}\ +\
2\ \overbrace{\sum_{n=-\infty}^{\infty}\
\int_{0^{-}}^{\pars{16\pi}^{\, +}}\delta\pars{x - n\pi}\,\dd x}^{\ds{=\ \dsc{16}}}
\ =\ 32
$$
A: According to http://en.wikipedia.org/wiki/Lists_of_integrals#Absolute-value_functions,
$\int|\sin x|~dx=2\left\lfloor\dfrac{x}{\pi}\right\rfloor-\cos{\left(x-\pi\left\lfloor\dfrac{x}{\pi}\right\rfloor\right)}+C$
