Doubt in a Definite integral Concept $$ I = \int_0^{4\pi} \frac{\sec^2x\ dx}{2+\tan^2x} $$
Now it is simple and I can just write it as,
$I=\left[\frac{1}{√2}\tan^{-1}(\tan x/√2)\right]_0^{4\pi}$. Now if I simply place limits I will get $0-0=0$.
But if I take $8$ common as $f(2a-x)=f(x)$ property the limits change to $0$ to $π/2$ so the answer also changes to $2√2π$. Which is the correct answer given. I don't understand why we need to apply the property when it isn't needed in the first place and let alone why it gives a different answer?
 A: Handling Primitive Limitations
The problem lies in the fact that the primitive for $\int\frac{\sec^2(x)\,\mathrm{d}x}{2+\tan^2(x)}=\frac1{\sqrt2}\tan^{-1}\left(\frac{\tan(x)}{\sqrt2}\right)+C$ is only good for one period of $\tan(x)$. The constant changes for the next period because of the discontinuity in $\tan(x)$. So we can compute the integral in pieces:
$$
\begin{align}
\int_0^{4\pi}\frac{\sec^2(x)\,\mathrm{d}x}{2+\tan^2(x)}
&=\int_0^{\pi/2}\frac{\sec^2(x)\,\mathrm{d}x}{2+\tan^2(x)}
+\int_{\pi/2}^{3\pi/2}\frac{\sec^2(x)\,\mathrm{d}x}{2+\tan^2(x)}
+\int_{3\pi/2}^{5\pi/2}\frac{\sec^2(x)\,\mathrm{d}x}{2+\tan^2(x)}\\
&+\int_{5\pi/2}^{7\pi/2}\frac{\sec^2(x)\,\mathrm{d}x}{2+\tan^2(x)}
+\int_{7\pi/2}^{4\pi}\frac{\sec^2(x)\,\mathrm{d}x}{2+\tan^2(x)}\\
&=\int_0^\infty\frac{\mathrm{d}u}{2+u^2}+3\int_{-\infty}^\infty\frac{\mathrm{d}u}{2+u^2}+\int_{-\infty}^0\frac{\mathrm{d}u}{2+u^2}\\[9pt]
&=2\sqrt2\,\pi
\end{align}
$$

Smarter Primitive
As noted above, the function $u(x)=\frac1{\sqrt2}\tan^{-1}\left(\frac{\tan(x)}{\sqrt2}\right)+C$ suffers because of the discontinuity of $\tan(x)$. However, there is a trick that allows us to overcome this problem. Let us assume, for the time being, that $C=0$. We can simply add that to $u$ later. With this assumption, we get
$$
\frac{\tan(x)}{\sqrt2}=\tan(\sqrt2 u)\tag1
$$
Using the formula for the tangent of a difference, we get
$$
\begin{align}
\tan\left(\sqrt2 u-x\right)
&=\frac{\tan\left(\sqrt2u\right)-\tan(x)}{1+\tan\left(\sqrt2u\right)\tan(x)}\tag{2a}\\
&=\frac{\frac{1-\sqrt2}{\sqrt2}\tan(x)}{1+\frac1{\sqrt2}\tan^2(x)}\tag{2b}
\end{align}
$$
The nice thing about $\text{(2b)}$ is that it is bounded and continuous as a function of $x$.

Composing $\tan^{-1}$ with $\text{(2b)}$ encounters no discontinuity, and we can solve for $u$:
$$
u=\frac1{\sqrt2}\left(x+\tan^{-1}\left(\frac{\frac{1-\sqrt2}{\sqrt2}\tan(x)}{1+\frac1{\sqrt2}\tan^2(x)}\right)\right)\tag3
$$
Adding $C$ will give us a general primitive, but this primitive, albeit quite a bit more complicated looking, does not suffer from the discontinuities of $\tan(x)$.

Applying $(3)$ to the problem gives
$$
u(4\pi)-u(0)=2\sqrt2\pi\tag4
$$
