integrate $\int_0^{\frac{\pi}{4}}\frac{dx}{2+\tan x}$ 
$$\int^{\frac{\pi}{4}}_{0}\frac{dx}{2+\tan x}$$

$v=\tan(\frac{x}{2})$
$\tan x=\frac{2v}{1-v^2}$
$dx=\frac{2\,dv}{1+v^2}$
$$\int^{\frac{\pi}{4}}_0 \frac{dx}{2+\tan x}=\int^{\frac{\pi}{8}}_0 \frac{\frac{2\,dv}{1+v^2}}{2+\frac{2v}{1-v^2}}=\int^{\frac{\pi}{8}}_0 \frac{1-v^2}{(1+v^2)(-v^2+v+1)} \, dv$$
Using partial fractions 
$$-\frac{1}{5}\int^{\frac{\pi}{8}}_0 \frac{-2v+4}{v^2+1}+\frac{1}{5}\int^{\frac{\pi}{8}}_0 \frac{-2v+1}{-v^2+v+1}=\frac{1}{5}\int^{\frac{\pi}{8}}_0 \frac{2v}{v^2+1}-\frac{1}{5}\int^{\frac{\pi}{8}}_0 \frac{4}{v^2+1}+\frac{1}{5}\int^{\frac{\pi}{8}}_0 \frac{-2v+1}{-v^2+v+1}$$
$$=\frac{1}{5}ln|v^2+1|-\frac{4}{5}\arctan(v)+\frac{1}{5}ln|-v^2+v+1|$$ from $\frac{\pi}{8}$ to $0$
$0.02-0+0.299-0+0.04-0=0.359$
But it should come out 0.32

Before doing any substitutions are algebra, you can see that the value of this integral will be a finite positive number because you're integrating a positive function over a bounded interval.
Multiplying the numerator and denominator by $(1-v^2)(1+v^2)$, we get:
$$
\frac{\frac 2 {1+v^2}}{2+\frac{2v}{1-v^2}} = \frac{2(1-v^2)}{2(1+v^2)(1-v^2)+2v(1+v^2)} = \frac{1-v^2}{(1 - v^4) + v+v^3}.
$$
Since the denominator is not $0$ when $v$ is $1$ or $-1$, nothing cancels.  You may need numerical methods to factor this; I'm not sure.
Notice that as $x$ goes from $0$ to $\pi/4$, then $v$ goes from $0$ to $\tan\dfrac\pi8$, so your bounds of integration need to take that into account.
