# Why is it not true that $\int_0^{\pi} \sin(x)\; dx = 0$?

I know the following is not right, but what is the problem. So we want to calculate $$\int_0^{\pi} \sin(x) \; dx$$ If one does a substitution $u = \sin(x)$, then one gets $$\int_{\sin(0) = 0}^{\sin(\pi) = 0} \text{something}\; du = 0.$$ We know that $\int_a^a f(x) \; dx = 0$ for all functions $x$, so why doesn't this work for the above?

I get that the "something" "can't be found" because $du = \cos(x)dx$. But does it really matter what the $du$ is when one is integrating from $0$ to $0$?

Edit: I don't know what a "diffeomorphism" is. I am just in basic calculus.

• There is no inverse function to $\sin(x)$ on $(0,\pi)$. That is, yes, "something" cannot be found and it does matter. – Peter Franek Oct 20 '15 at 19:52
• Your substitution must be a bijective function. In your case, it's not. – 5xum Oct 20 '15 at 19:55
• @PeterFranek: Does integration by substitution only work when $u$ has an inverse function? – John Doe Oct 20 '15 at 19:55
• @JohnDoe You can always replace $\int f(\varphi(t)) \varphi'(t) dt$ by $\int f(x) dx$. But vice versa, starting with $\int f(x) dx$, you can only use $f(x)=u$ if $f$ has an inverse (the "something" in your question). – Peter Franek Oct 20 '15 at 19:57

This is a very good question and not one that many students ask. Let's see what happens when we do as you are suggesting. Letting $u = \sin x$, we get

$$du = \cos x\,dx = \pm\sqrt{1-\sin^2 x}\,dx = \pm\sqrt{1-u^2}\,dx.$$

Thus the integral becomes

$$\int \sin x\,dx = \int \frac{\pm u}{\sqrt{1-u^2}}\,du.$$

Notice I did not put any limits of integration in here. When $x\in[0,\frac{\pi}{2}]$, cosine is non-negative, so we can use the positive root. However when $x\in(\frac{\pi}{2},\pi]$, cosine is negative so we have to use the negative root. Meaning our one integral splits into two different integrals:

$$\int_0^{\pi} \sin x\,dx = \int_{u(0)}^{u(\pi/2)} \frac{u}{\sqrt{1-u^2}}\,du + \int_{u(\pi/2)}^{u(\pi)} \frac{-u}{\sqrt{1-u^2}}\,du.$$

Note that $u(0) = 0$, $u(\pi/2) = 1$ and $u(\pi) = 0$ so we get

$$\int_0^{\pi} \sin x\,dx = \int_0^1 \frac{u}{\sqrt{1-u^2}}\,du - \int_1^0 \frac{u}{\sqrt{1-u^2}},u = 2\int_0^1 \frac{u}{\sqrt{1-u^2}}\,du.$$

Note that this is a positive number. The reason for why it doesn't work out is exactly as Baloown is suggesting. What you suggest does not apply here and is partially reflected in the occurrence of the $\pm$ roots. What the actual case is that the forward direction for $u$-substitution always works (meaning substituting $x = \text{ something}$) - it is the backwards case is where the issues lie (substituting $\text{something } = f(x)$).

• It might be even more illustrative to write the substitution as $x\to \arcsin x$ and $dx\to \frac{1}{\sqrt{1-x^2}}\,dx$ for $x\in [0,\pi/2]$ and $x\to \pi - \arcsin (x)$ for $x\in [\pi/2,\pi]$, where the arcsine function is taken as the principal branch. – Mark Viola Oct 20 '15 at 22:42
• That's a good point but I think I will leave it as is. You can make an answer along those lines if you'd like :) – Cameron Williams Oct 20 '15 at 22:51

As suggested in the other answers, you cannot use that substitution on the whole interval $(0,\pi)$ because $\sin$ is not bijective there. However, you can do the change of variables after having split the interval into two pieces on which $\sin$ is bijective: $$\int_0^\pi\sin x\,\mathrm{d}x=\int_0^{\pi/2}\sin x\,\mathrm{d}x+\int_{\pi/2}^\pi\sin x\,\mathrm{d}x=\int_0^1\frac{u}{\sqrt{1-u^2}}\mathrm{d}u+\int_1^0\frac{-u}{\sqrt{1-u^2}}\mathrm{d}u\,,$$ having used the fact that $\cos x=\sqrt{1-u^2}$ on $(0,\pi/2)$ while $\cos x=-\sqrt{1-u^2}$ on $(\pi/2,\pi)$.

\begin{align} u & = \sin x \\ du & = \cos x\,dx \\[8pt] dx & = \frac{du}{\cos x} = \frac{du}{\pm\sqrt{1-\sin^2 x}} = \frac{du}{\pm\sqrt{1-u^2}} = \begin{cases} \dfrac{du}{\sqrt{1-u^2}} & \text{for }0\le x \le \frac \pi 2 \\[10pt] \dfrac{du}{-\sqrt{1-u^2}} & \text{for } \frac \pi 2 \le x \le \pi \end{cases} \\[15pt] \int_0^\pi \sin x\,dx & = \int_0^{\pi/2} \sin x\,dx + \int_{\pi/2}^\pi \sin x\,dx = \int_0^1 \frac{u\,du}{\sqrt{1-u^2}} + \int_1^0 \frac{u\,du}{-\sqrt{1-u^2}} = \cdots \end{align}

As mentioned in the comments, a change of variables need not be a $C^1$-diffeomorphism. It also need not be a piecewise $C^1$-diffeomorphism. All you need is for the endpoints to match up and some weak smoothness. For example: Suppose $f$ is continuous on $[a,b]$ and $g:[c,d]\to [a,b].$ Assume $g(c) = a, g(d) = b,$ and that $g$ is differentiable on $[c,d]$ with $g'$ Riemann integrable on $[c,d].$ Then

$$\tag 1 \int_a^b f(x)\,dx = \int_c^d f(g(t))g'(t)\,dt.$$

Proof: Let $F(x) = \int_a^x f.$ Then $F'=f,$ so $(F\circ g)'(t) = (f\circ g)'(t)g'(t).$ The last function is Riemann integrable on $[c,d],$ so the integral on the right of $(1)$ equals $(F\circ g)(d)-(F\circ g)(c) = F(b)-F(a) = \int_a^b f.$

• As always, your answer is solid. So, +1. You might consider adding a couple of lines that maps this answer to the specific integral of interest (i.e., $f(x)=\sin x$ and $g(t)=\arcsin(t)$). Again, well done! – Mark Viola Oct 20 '15 at 21:09
• Thank you @Dr.MV. You always catch me providing an answer that is not directly related to the OP's question. In this case, I was addressing a different question that was raised in the answers and the comments. Can't help myself. – zhw. Oct 20 '15 at 21:21
• Whlist that might be true, your "bonus" answers are always (or should I write a.e.?) insightful! – Mark Viola Oct 20 '15 at 22:31
• I liked this answer by Christian Blatter to a similar question: math.stackexchange.com/a/470460/16490. He explains in similar detail why we really never need to assume that our "substitution" function need be injective. If it is not injective, for our bounds of integration we may choose any points in the preimage of the substituted integral bounds. But if non-invertible substitution functions are really allowed, how do we account for the erroneous proof that $\int^\pi_0\sin x dx =0$? Isn't it exactly the failure of $\sin x$ to be injective that caused this? – ziggurism Oct 21 '15 at 4:52

Although there have been several great answers, one user suggested that I expand on a comment I wrote. To that end, we make the simple substitution

$$x= \begin{cases} \arcsin (t)&,0\le x\le \pi/2\\\\ \pi-\arcsin(t)&,\pi/2\le x\le \pi \end{cases}$$

where the arcsine is taken to be the principal branch with domain $[-1,1]$ and range $[-\pi/2,\pi/2]$. Then, we have

$$dx= \begin{cases} \frac{1}{\sqrt{1-t^2}}\,dt&,0\le x\le \pi/2\\\\ -\frac{1}{\sqrt{1-t^2}}\,dt&,\pi/2\le x\le \pi \end{cases}$$

Finally, the integral of interest becomes

\begin{align} \int_0^\pi \sin x\,dx&=\int_0^{1} \frac{t}{\sqrt{1-t^2}}\,dt+\int_{1}^{0}\frac{-t}{\sqrt{1-t^2}}\,dt\\\\ &=2 \end{align}

and we are done!

• I like this answer more than other answers out there (+1 for the same). See a similar answer at math.stackexchange.com/a/669276/72031 – Paramanand Singh Oct 21 '15 at 4:10
• I think your answer would be improved if you 1. made it clear that you were adopting two different substitution variables in two different regimes, and did not adopt a nonstandard piecewise notation that makes it appear that you're doing a single substitution for x, and 2. if you motivated a little more how and why you decided to separate the two substitutions for x. – ziggurism Oct 21 '15 at 5:03

Very precise answers have been given. I would like to answer the subject question only "Why is it not true that $\int_0^{\pi} \sin(x)\; dx = 0$?" This is first a matter of visual evidence and common sense.

In the interval $[0,\pi]$, your sine function is positive, and stricly inside $]0,\pi[$. With a little calculus, you obtain that $\sin$ is stricly positive (say, above $\sin(a)$) in some $[a,\pi-a]$ interval, $0<a<\pi-a<\pi$. Thus your integral, which can be interpreted as an area here, should be above $\sin(a)\times (\pi - 2a)>0$. Based on these observations, you should resign to the fact that your substitution is not valid for some reason (explained in the above precise answers). Your trick reminds me of the "proof" that $1=0$, which does unappropriate substitutions, leading to a wrong conclusion.

Logic and observations are good masters in maths.

A substitution has to be a bijection on the interval of integration. Draw a picture of the graph and you'll see that with your substitution, you need to split the interval of integration at $\pi/2$ to have a bijection. Otherwise, you miss parts of the interval of integration (in this case, the whole interval!). Note that the maximum of $\sin{x}$ on the interval of integration is $1$, so a substitution of the form $u=\sin{x}$ needs to have this as an endpoint, after splitting into intervals where $\sin{x}$ is monotonic.

• A substitution does not have to be a bijection. The substitution $u = x^2$ is perfectly fine, even over the interval $[-1,1]$ for instance. (What you are looking for in the strict sense is that a substitution has to be a piecewise $C^1$-diffeomorphism ; this is because the change of variables theorem works for $C^1$-diffeomorphisms and we can use the linearity of the integral to split the change of variables over the pieces.) – Patrick Da Silva Oct 20 '15 at 19:57
• Yes, but there's no point explaining it in those terms to people who have never done differential geometry. It's far simpler to tell them to split the interval of integration into sections on which the substitution they want to make is monotonic. There's no need to bring chains, pullbacks and partitions of unity into it. And last time I checked, a diffeomorphism had to be a bijection... – Chappers Oct 20 '15 at 20:10
• I didn't mention the advanced terms to confuse the OP, I added them for you. Since when is $u = x^2$ a bijection? I recall it is a correct change of variables though. That's all my comment is saying. But the point is that the only thing going wrong with the OP's idea is the bounds of integration, not the choice of change of variables. – Patrick Da Silva Oct 20 '15 at 20:14
• @PatrickDaSilva The substitution $u=x^2$ does not work for the integral of $x^3$ from -1 to 1. – Brian Rushton Nov 5 '15 at 16:46
• @BrianRushton : What? $$\int_{-1}^1 x^3 \, dx = \int_1^1 \frac u2 \, du = 0.$$ It works perfectly fine! – Patrick Da Silva Nov 5 '15 at 16:52

The integral will vanish only if the entire function is a constant, =0. Your logic is correct when you evaluate between limits $x = 0, 2 \pi$.

It matters a lot what the integrand is, because that is all the matter now is about.

Do not think about diffeomorphisms at this stage.

However the integral vanishes $x =-u, u$ where $u$ is any real number.

Since 0 to π in sin(x) covers area in upper part. so it cannot be zero. Please refer following link: https://en.wikipedia.org/wiki/Integral

• Did you read the post and not just the title? – pjs36 Oct 21 '15 at 5:29
• 0 to π is just limits. Why are you applying sin(x) there? – Johny Royan Oct 21 '15 at 5:40
• I didn't ask the question, so I'm not applying anything anywhere. I'm just pointing out that the actual question in the post is not addressed by this answer (while acknowledging that the title question, I suppose, is). – pjs36 Oct 21 '15 at 5:47

If you link integration to calculating area the answer is wrong but if if considered as a calculation of some number it is oke. The point $(\frac{\pi}{2},0)$ is a point of reflection and then you will count the number '$f(x)\, dx$' as welll as positive and negative so the outcome will be zero.

The reason that your idea doesn't work is that $u$-substitution only works if your function is one-to-one (also called monotone; it just means it has to be increasing everywhere or decreasing everywhere). They don't talk about this in calculus because it never really comes up. What you can do is split up your integral into two parts (from 0 to $/pi$/2 and then the other half) and do the u-substitution on both parts. That gives the right answer, because the substitution is one-to-one on both parts.