6

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)|$?

  • This cannot be the correct antiderivative. An antiderivative of $|\sin(x)|$ would be unbounded, as we already know $$\int_0^{n\pi} |\sin(x)|dx = 2n.$$ However, $c-1 < c-\cos(x)sgn(\sin(x)) < c+1$ – Joel Feb 19 '15 at 21:13
  • 1
    @Mathi: not really. That anti-derivative is periodic. – robjohn Feb 19 '15 at 21:13
  • @Joel: this is where the $c$ comes in. Suppose $I$ is an interval between two consecutive roots of $\sin(x)$. Then if $\sin(x)$ is positive on $I$, then $|\sin(x)| = \sin(x)$ and its antiderivative is $-\cos(x) + c$. If $\sin(x)$ is negative there, then $|\sin(x)| = -\sin(x)$ and its antiderivative is $\cos(x) + c$. So the antiderivative really is $-\cos(x)\operatorname{sgn}(\sin(x)) + c$ but the $c$ changes at every root of $\sin(x)$, which is why the naive integral calculation done by the OP fails. – Carl Mummert Feb 20 '15 at 01:20
  • @CarlMummert The $c$ is misleading. The OP interpreted $c$ as a constant, where it is actually more like a linear function. I understand your distinction, but when $c$ is taken as a constant with respect to all $x$, the antiderivative is incorrect. – Joel Feb 20 '15 at 15:31
  • 1
    This is a common issue. For example, the antderivative of $1/x$ is usually stated as $\ln(|x|) + c$, but there the value of $c$ can change at the point $x = 0$; we do not obtain the general antiderivative by taking $c$ to be constant, only piecewise constant. @Joel – Carl Mummert Feb 20 '15 at 15:37
  • That is certainly true for the case of the antiderivative of $1/x$, in fact I think that is an exercise in Stewart's calculus. In this case though, $|\sin(x)|$ is a continuous function, so there is no ambiguity with the antiderivative. @CarlMummert – Joel Feb 20 '15 at 15:46
  • I added another example to my answer, for $|e^x - 1|$. Of course, everyone knows a continuous function like one that should have an antiderivative on $\mathbb{R}$, but the piecewise formula can make it look confusing. @Joel – Carl Mummert Feb 20 '15 at 16:16

6 Answers6

3

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)$.

enter image description here

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$.

Graph of f(x)

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}$.

Carl Mummert
  • 81,604
  • A similar confusion about $c$ can be used to give a well known fake "proof" that $0 = 1$, which you can read at https://www.math.hmc.edu/funfacts/ffiles/10002.3-8.shtml – Carl Mummert Feb 20 '15 at 01:53
  • I've spent some time to understand and investigate your answer. I think I understand the problem much more clearly now, and I have some comments. While a bit critical, I mean no disrespect, and if some of my criticism is based on my misunderstanding, I apologize. First, The fundamental theorem of calculus (FTC) says that as long as $f(x)$ is continuous, $\int f(x),\mathrm{d}x=F(x)+C$ will also be continuous, and $\int_a^b f(x),\mathrm{d}x=F(b)-F(a)$. So as long as we talk about continuous functions, it makes no sense to talk about discontinuous antiderivatives... – Jostein Trondal Feb 22 '15 at 18:28
  • ...Because $f(x)=|\sin(x)|$ is continuous, its antiderivatives also have to be continuous. Wolfram's $W(x)=-\cos(x)\mathrm{sgn}(\sin(x))$ is not continuous, so it cannot be an antiderivative of $|\sin(x)|$. It is true that $W$ works as an antiderivative within intervals between roots of $|\sin(x)|$, but then at least $W$ should be accompanied by a caveat. There is no such caveat in Wolfram Alpha, so my conclusion is that that result is simply wrong. And even with this caveat, $W$ is not user friendly if you want to use it to evaluate definite integrals that cross the roots of $|\sin(x)|$... – Jostein Trondal Feb 22 '15 at 18:29
  • ...The solution of @robjohn is nice. I modified it slightly to this: $\int|\sin(x)|,\mathrm{d}x=2n-(-1)^n\cos(x)+c\textrm{ where }n=\lfloor x/\pi\rfloor$. Second, When you say that, in a table of integrals, the step function $j(x)$ may seem to be "hidden" inside the $c$, that seems very odd to me. Isn't $c$ supposed to be constant? Surely it could not be constant if a function of $x$ is "hidden" inside it? Third, I like your example about $|e^x-1|$, but I don't understand your reasoning. What's the point of "choosing $c$ appropriately on each side of 0 to eliminate the jump discontinuity"?... – Jostein Trondal Feb 22 '15 at 18:29
  • ...The function would still be split, a separate calculation would still have to be made on each side of 0 for all definite integrals that cross 0, and the appropriately chosen $c$ would be useless. By the way, I found this: $\int |e^x-1|,\mathrm{d}x=x|e^x-1|+\mathrm{sgn}(e^x-1)((1-x)e^x-1)+c$. – Jostein Trondal Feb 22 '15 at 18:30
  • I agree: $W$ as specified by Wolfram Alpha only works between adjacent roots. The same thing goes in a normal table when you have $f(x) = 1/x$ and its antiderivative $\ln|x| + c$: that 'c' is also not really constant, it can have different value on either side of 0. So the issue is: what is the right way to read a table of integrals? That is what I was trying to explain: the relationship between a formula like '$\ln|x| + c$' and an actual antiderivative, which may require multiple values of the "constant" $c$. @Jostein Trondal – Carl Mummert Feb 22 '15 at 18:52
  • The final example of $|e^x -1|$ was meant to show how the formula in the table of integrals (in this case, $(e^x - x)\operatorname{sgn}(e^x-1)+c$) can be deceptive. For that formula, we have to pick different values of $c$ on either side of $x = 0$ to get an antiderivative that is correct at $x = 0$. (Note that many tables of integrals leave out the "$c$" entirely... but this does not eliminate the issue at all!) – Carl Mummert Feb 22 '15 at 18:54
  • I see. I am actually in the process of putting together a table of integrals myself for the second edition of my book of formulas. I consider using the notation $C_i$ for the constant of integration for all integrals that have singularities in the integrand. By the way, @Carl Mummert, did you actually see $(e^x-x)\mathrm{sgn}(e^x-1)+c$ in a table of integrals? – Jostein Trondal Feb 23 '15 at 16:36
2

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} $$

robjohn
  • 345,667
1

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.$

abel
  • 29,170
0

Using symmetry : $\int_0^\pi|\sin x|dx=2$ then $\int_0^{16\pi}|\sin x|dx=16.2=32$

BigM
  • 3,936
  • 1
  • 26
  • 36
0

$\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 $$
Felix Marin
  • 89,464
  • 1
    To manage to obfuscate what is going on at such a degree is definitely some kind of art. – Did Jul 09 '15 at 12:07
0

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$

Harry Peter
  • 7,819