What is wrong with the following u-substitution?

We will calculate $\displaystyle\int^{2 \pi}_0 x \, dx$. Let $u=\sin (x)$, and observe that $\sin(2 \pi)=0$ and $\sin(0)=0$. We also have that $\frac{du}{dx}=\cos(x)=\sqrt{1-u^2}$. Hence, $$\int^{2 \pi}_0 x \, dx=\int^0_0 \frac{\sin^{-1}(u)}{\sqrt{1-u^2}} \, du = 0.$$ This is very obviously wrong, but I am not sure how to explain the error formally.

Edit: Thanks for the responses and in particular the link below to the related problem! The error is indeed caused by the substitution $x=\sin^{-1}(u)$. The integration is performed over $[0,2 \pi]$ which is outside the range of the $\sin^{-1}$ function.

Remark The error is slightly better disguised when calculating $\displaystyle\int^1_{-1}\frac{2x}{1+x^2} \, dx.$

Let $u(x)=1+x^2$, and observe that $u(1)=u(-1)=2$. Then since $dx=\frac{1}{2x} du$, we have that $$\int^1_{-1} \frac{2x}{1+x^2} \, dx = \int^2_2 \frac{1}{u} \, du=0.$$ This time, no trigonometric substitution is used, but it is still an incorrect proof for the same reason as above. A correct proof can be obtained by using the fact that $x \mapsto \displaystyle\frac{2x}{1+x^2}$ is odd.

This example is more disturbing because the procedures above are entirely intuitive and yield the correct result. It seems to me that students when taught integration by substitution of definite integrals should also be taught that great care be exercised in checking the range of integration, particularly when the (apparent) substituting function is not invertible in that range.

$1.$ Let $u=\sin x$

so that $\,du=\cos x \,dx$.

Now, for $x\in[0, \frac{\pi}{2}]$, \begin{align}\cos x &= \sqrt{1-u^2},\\x&=\arcsin u;\end{align} for $x\in[\frac{\pi}{2},\frac{3\pi}{2}]$, \begin{align}\cos x &= -\sqrt{1-u^2},\\x&=\pi -\arcsin u;\end{align} for $x\in[\frac{3\pi}{2}, 2\pi]$, \begin{align}\cos x &= \sqrt{1-u^2},\\x&=2\pi +\arcsin u.\end{align}

Therefore \begin{align}\int^{2\pi}_0 x \,dx&=\int^\frac{\pi}{2}_0 x \,dx + \int^\frac{3\pi}{2}_\frac{\pi}{2} x \,dx + \int^{2\pi}_\frac{3\pi}{2} x \,dx\\&=\int^1_0 \frac{\arcsin u}{\sqrt{1-u^2}}\,du + \int^{-1}_1 \frac{\pi-\arcsin u}{-\sqrt{1-u^2}} \,du + \int^0_{-1} \frac{2\pi + \arcsin u}{\sqrt{1-u^2}} \,du\\&=2\pi\int^0_{-1} \frac{\,du}{\sqrt{1-u^2}}-\pi\int^{-1}_1 \frac{\,du}{\sqrt{1-u^2}}\\&=2\pi \bigg[\arcsin u\bigg]_{-1}^0 -\pi\bigg[ \arcsin u\bigg]_1^{-1}\\&=2\pi^2.\end{align}

$2.$ Re: the Remark in the original question: the integration-by-substitution proof for $\displaystyle\int^1_{-1}\frac{2x}{1+x^2} \, dx$ supplied by the OP is actually perfectly valid (so the example isn't disturbing!), even though the substitution function $u=1+x^2$ is not injective (and certainly not invertible) on $[-1,1].$

Integration by substitution does not intrinsically require that the substitution function be invertible/bijective - or even injective or monotonic - on the interval of integration; but if the substitution function is not injective on the interval of integration, the integral may (or may not) need to be split up over subintervals before the substitution can be simply applied. (This applies to indefinite integrals too.)

The substituted formula must match the formula substituted on each interval. $\sin^{-1}(u)\in\left[-\frac\pi2,\frac\pi2\right]$ cannot cover all of $[0,2\pi]$. A safer way to substitute is to substitute on monotonic intervals of the substituted formula: \begin{align} \int_0^{2\pi}x\,\mathrm{d}x &=\overbrace{\int_0^1\color{#C00}{\sin^{-1}(u)}\,\mathrm{d}\sin^{-1}(u)}^{x=\sin^{-1}(u)\in\left[0,\frac\pi2\right]} +\overbrace{\int_{-1}^1\left(\color{#090}{\pi}+\color{#00F}{\sin^{-1}(u)}\right)\,\mathrm{d}\sin^{-1}(u)}^{x=\pi+\sin^{-1}(u)\in\left[\frac\pi2,\frac{3\pi}2\right]} +\overbrace{\int_{-1}^0\left(\color{#C90}{2\pi}+\color{#C9F}{\sin^{-1}(u)}\right)\,\mathrm{d}\sin^{-1}(u)}^{x=2\pi+\sin^{-1}(u)\in\left[\frac{3\pi}2,2\pi\right]}\\ &=\color{#C00}{\frac{\pi^2}8}\color{#090}{+\pi^2}\color{#00F}{+0}\color{#C90}{+\pi^2}\color{#C9F}{-\frac{\pi^2}8}\\[9pt] &=2\pi^2 \end{align}

I think that qwerty314 might have a better more direct answer to your bottom line question of why your particular method does not produce the desired result. That being said, it should be noted that you can actually get the desired result using trigonometric substitution by not changing the limits of integration, and instead back substituting the result then evaluating that at the original $x$ limits. To wit, given the indefinite integral

$$\int x\, dx,$$

let $$x=\sin u \Rightarrow dx=\cos u \, du.$$

Then

\begin{align*} \int x\, dx &= \int \sin u \cos u \, du \\ &= -\frac{\cos^2 u}{2}. \end{align*}

As we let $\frac{x}{1}=\sin u$ in our original substitution, we now form a right triangle with angle $u$, opposite side $x$, and hypotenuse $1$. Thus the adjacent side is $\sqrt{1-x^2}$. Reading from this triangle we have that

$$-\frac{\cos^2 u}{2}=-\frac{1-x^2}{2}.$$

Now if we evaluate this result at our limits we get

\begin{align*} -\frac{1-x^2}{2}\bigg|_0^{2\pi} &= -\frac{1-4\pi^2}{2}-\left( -\frac{1-0^2}{2} \right)\\ &=-\frac{1}{2}+\frac{4\pi^2}{2}+\frac{1}{2}\\ &=2\pi^2. \end{align*}

This is of course the result we would expect had we computed the definite integral in the standard manner.

substituting u=sin(x) will restrict the range of x to [-pi,pi], while x has range [-inf,inf].

• i dont see how the range is an issue here. Range of $x$ here is $[0, 2\pi]$. – Paramanand Singh Sep 13 '14 at 8:28

It shoud be obvious that the integral must be evaluated in the progressive direction, otherwise some parts of the summation are deducted rather than added. To achieve this, the transformation must be monotonous.

• Stupid downvotes. – Yves Daoust Jan 4 at 16:04