# How to change limits of a definite integral during substitution

I am having this stupid doubt while solving atleast a dozen questions as of now.Let say we have $$\int_0^\pi xdx = \frac{\pi ^2}{2}$$Just to demonstrate lets say tanx=u and substitute for x, the integral then becomes $$\int_0^0 \frac{tan^{-1}{u}}{1+u^2}du$$What am I doing wrong with the limits ? Both $$tan0$$ and $$tan \pi$$ are 0 but clearly the new limit evaluates to 0.

• Sorry I was just testing whether I typed the correct mathjax,didn't expect a quick response as yours Feb 21, 2020 at 14:39
• Oh dude! so prompt to put a close vote. Feb 21, 2020 at 14:42
• There are lots of similar questions on this site already, see for example this one: math.stackexchange.com/questions/2380669/… Feb 21, 2020 at 15:49

The problem is that $$\tan x$$ isn't monotonic on $$[0,\,\pi]$$. If you split the integration range into regions on which it is monotonic, it would work:
$$\int_0^{\pi/2}xdx+\int_{\pi/2}^\pi xdx=\int_0^\infty\frac{\arctan udu}{1+u^2}+\int_{-\infty}^0\frac{(\pi+\arctan u)du}{1+u^2}.$$Note the one-sided approaches of the singularity at $$\pi/2$$ tend to $$\pm\infty$$, so the second integral on the right-hand sie isn't $$-1$$ times the first. Meanwhile, the last integrand's numerator has a complication: for obtuse $$x$$, $$u=\tan x\implies x=\pi+\arctan u$$. In fact, $$u\mapsto -u$$ in the last integral converts its range to $$0,\,\infty$$, allowing us to sum the two $$u$$ integrals as$$\int_0^\infty\frac{\arctan u+\pi-\arctan u}{1+u^2}du=\pi\int_0^\infty\frac{du}{1+u^2}=\frac{\pi^2}{2}.$$
In this case, your substitution is equivalent to $$x=\arctan u,$$ and as the range of the arctangent is $$(-π/2,π/2),$$ it follows that you cannot use this substitution for your integral in the range $$[π/2,π].$$ To do so, you may need to make a preliminary substitution in the second range, something like $$x=2y,$$ say.