Change of limits in definite integration The definite integral $\displaystyle\int_0^1\frac{\mathrm dx}{1+x^2}$ is evaluated as such:
Letting $x=\tan\theta$, $\mathrm dx=\sec^2\theta\ \mathrm d\theta$, $\begin{cases}x=0\\\theta=0\end{cases}$, $\begin{cases}x=1\\\theta=\frac\pi4\end{cases}$:
$$=\int_0^\frac\pi4\frac{\sec^2\theta\ \mathrm d\theta}{\sec^2\theta}$$
$$=\int_0^\frac\pi4\mathrm d\theta$$
$$=\frac\pi4$$
The question is, in the first step, why can I not have $\begin{cases}x=1\\\theta=\frac{5\pi}4\end{cases}$ instead, and the result would become $\frac{5\pi}4$?
 A: I think we should go back to the method of substitution in indefinite integral first.
So the argument is like this: If you can't integrate $\int f(x)dx$ directly, try to find an $\textit{invertible function}$ $x=g(u)$ so that you can find easily a function $F(u)$ such that
$$\frac{dF}{du}=f(g(u))g'(u)$$
Then, by chain rule
$$\frac{d}{dx}F(g^{-1}(x))=\frac{d}{du}F(u)\frac{d}{dx}g^{-1}(x)=f(g(u))g'(u)\frac{1}{g'(u)}=f(x)$$
and hence
$$\int f(x)dx=F(g^{-1}(x))$$.
So from the above, $g(u)$ need to be a $\textit{function}$ which is $\textit{invertible}$ and the inverse function is $\textit{differentiable}$.
So your case, you are using $x=\tan \theta$ of which is invertible with differentiable inverse only if you restrict the domain of $x=\tan \theta$ inside a certain interval $(-\pi/2+n\pi,\pi/2+n\pi)$ so that $\arctan x$ is well defined and differentiable.
A: One way to argue is that $I \leq \displaystyle \int_{0}^1 1 dx = 1 < \dfrac{5\pi}{4}$
A: Because the principal value
of arctan is being used.
If you choose
$\theta = 1$
at $x=1$,
you would have to choose
$\theta = \pi$
at $x=0$
and the result would
again be $\pi/4$.
A: The multiple branches for the arctangent function have integral representation 
$$\arctan(x;n)=n\pi+\int_0^x \frac{1}{1+u^2}\,du \tag 1$$
for integer $n$.  On the principal branch for the arctangent, $n=0$. 
Using $(1)$, we can write the integral of interest as 
$$\int_{0}^1\frac{1}{1+u^2}\,du=\arctan(1;n)-\arctan(0;n) \tag 2$$
The choice of branch for the arctangent does not impact the value of the integral in $(2)$, provided one uses only one branch for both $\arctan(1;n)$ and $\arctan(0;n)$. 

An as aside, we can evaluate the integral in $(2)$ without appealing to the arctangent function.  For $|x|\le 1$, the integral in $(1)$ can be transformed into the series
$$\int_0^x \frac{1}{1+u^2}\,du=\sum_{n=0}^\infty \frac{(-1)^n\,x^{2n+1}}{2n+1}$$ 
For $x= 1$, Leibniz used a purely geometric proof to show 
$$\sum_{n=0}^\infty \frac{(-1)^n}{2n+1}=\frac{\pi}{4} $$

Using Leibniz's result, we can also evaluate the integral $\int_0^\infty \frac{1}{1+u^2}\,du$ by writing
$$\begin{align}
\int_0^\infty \frac{1}{1+u^2}\,du&=\int_0^1\frac{1}{1+u^2}\,du+\int_1^\infty \frac{1}{1+u^2}\,du \tag 3\\\\
&=2\int_0^\infty \frac{1}{1+u^2}\,du \tag 4\\\\
&=\frac{\pi}{2}
\end{align}$$
where in going from $(3)$ to $(4)$ we enforced the substitution $u\to 1/u$ in the second integral.  Therefore, we find that 
$$\lim_{x\to \infty}\arctan(x;n)=n\pi+\pi/2$$
as expected!
