3
$\begingroup$

I'm having trouble understanding why it is that when I try to calculate $\int_{0}^{\pi}|\sin(x)|dx$ from it's indefinite integral I seem to get the wrong result of $0$.

Of course $|\sin(x)| = \sin(x) $ on $[0, \pi]$ so I know the result should be $2$. But considering the indefinite integral

$\int |\sin(x)| = -\cos(x)sgn(\sin(x))$

($sgn$ is the sign function) I use some fallacious reasoning to conclude that

$\int_{0}^{\pi}|\sin(x)|dx = [-\cos(x)sgn(\sin(x))]_{0}^{\pi} = -(-1)(0) -(-1)(0)) = 0$

I think the problem is how I use the sign function but as far as I know $sgn(\sin(0)) = sgn(\sin(\pi)) = 0$ and $|\sin(x)| $ is continuous on $[0, \pi]$. What am I doing wrong here?

$\endgroup$
3
  • $\begingroup$ You can't apply the "sgn" function only to the endpoints like that. Since you recognize that sin(x) is positive for [itex]0< x< \pi[/itex] I don't see why you do not simply say that [tex]\int_0^\pi |sin(x)|dx= \nt_0^\pi sin(x) dx[/itex]. $\endgroup$
    – user247327
    Jul 29, 2019 at 11:49
  • 1
    $\begingroup$ @user247327 The point of the question was to understand why my reasoning was wrong. As I wrote I know how I can calculate the integral correctly the way you suggest but that's beside the point. $\endgroup$
    – user578018
    Jul 29, 2019 at 11:52
  • $\begingroup$ Let $F(x) = -\cos x \operatorname{sgn} \sin x$. Then $\int_0^\pi |\sin x| dx = F(\pi - 0) - F(+0)$. The integral from $0$ to $2 \pi$ would be $F(2 \pi - 0) - F(\pi + 0) + F(\pi - 0) - F(+0)$. $\endgroup$
    – Maxim
    Jul 29, 2019 at 19:19

1 Answer 1

6
$\begingroup$

An indefinite integral, aka antiderivative, is necessarily a continuous function. If you graph the function $-\cos xsgn(\sin x)$, you'll see that it is discontinuous at the multiples of $\pi$. However, you can make it continuous by adding on the step function $s(x)=2\lfloor x/\pi\rfloor$. More precisely, we have

$$\int|\sin x|\,dx=C+ \begin{cases} -\cos xsgn{(\sin x)}+2\lfloor x/\pi\rfloor\quad\text{for }x\not\in\pi\mathbb{Z}\\ 2\lfloor x/\pi\rfloor-1\quad\text{for }x\in\pi\mathbb{Z} \end{cases}$$

where $C$ is an arbitrary constant.

Note, it's easy to see that the derivative of this piecewise-defined function is equal to $|\sin x|$ in each interval $k\pi\lt x\lt(k+1)\pi$ with $k\in\mathbb{Z}$, since $sgn(\sin x)$ and $2\lfloor x/\pi\rfloor$ are constant in each such interval. It's a good exercise to verify that the derivative exists, and is equal to $0$, at the multiples of $\pi$.

For the given definite integral, we have

$$\int_0^\pi|\sin x|\,dx=(C+2\lfloor\pi/\pi\rfloor-1)-(C+2\lfloor0/\pi\rfloor-1)=(C+2-1)-(C+0-1)=2$$

which agrees, of course, with the simpler calculation

$$\int_0^\pi|\sin x|\,dx=2\int_0^{\pi/2}\sin x\,dx=-2\cos x\big|_0^{\pi/2}=0-(-2)=2$$

Again, the fallacy lay in thinking that the formula $-\cos xsgn(\sin x)$, which defines a discontinuous function, could serve as "the" indefinite integral for $|\sin x|$.

$\endgroup$
0

You must log in to answer this question.