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

Universal trigonometric substitution is done in order to get the tangents instead of sines and cosines. In this case it is no longer necessary, so: $$t= \tan x,\quad x = \arctan t,\quad dx = \dfrac1{t^2+1},$$ $$J =\int\limits_0^{\pi/4}\frac{dx}{2+\tan x} = \int_0^1\dfrac{dt}{(t+2)(t^2+1)}.$$ Let $$R(t) = \dfrac1{(t+2)(t^2+1)} = \dfrac A{t+2}+\dfrac{Bt+C}{t^2+1},$$ then $$A = \lim_{t\to-2}(t+2)R(t) = \lim_{t\to-2}\dfrac1{t^2+1} = \dfrac15,$$ $$A+B = \lim_{t\to\infty}tR(t) = 0,\quad B=-\dfrac15,$$ $$\dfrac A2+C = R(0) = \dfrac12,\quad C = \dfrac25.$$ Thus, $$J=\dfrac15\int_0^1\dfrac{dt}{t+2} - \dfrac15\int_0^1\dfrac{t\,dt}{t^2+1} + \dfrac25\int_0^1\dfrac{dt}{t^2+1},$$ $$J = \dfrac15\log(t+2)\biggr|_0^1 - \dfrac1{10}\log(t^2+1)\biggr|_0^1 +\dfrac25\arctan t\biggr|_0^1,$$ $$J = \dfrac15\log\dfrac32 - \dfrac1{10}\log2 +\dfrac25\dfrac\pi4,$$ $$\boxed{J = \dfrac1{10}\left(\pi +\log\dfrac98\right)}$$

Another way (hinted by Wolfram Alpha): $$J = \int\limits_0^{\pi/4}\frac{dx}{2+\tan x} = \int\limits_0^{\pi/4}\frac{\cos x\,dx}{\sin x + 2\cos x},$$ $$\cos x = A(\sin x + 2\cos x) + B(\cos x - 2\sin x),$$ $$ \begin{cases} 2A + B = 1\\ A - 2B = 0, \end{cases}\quad A = \dfrac25,\quad B = \dfrac15, $$ $$J = \dfrac25\int\limits_0^{\pi/4}\,dx + \dfrac15\int\limits_0^{\pi/4}\frac{d(\sin x + 2\cos x)}{\sin x + 2\cos x}\,dx,$$ $$J = \dfrac{2x}5\biggr|_0^{\pi/4} + \dfrac15\log(\sin x + 2\cos x)\biggr|_0^{\pi/4},$$ $$J = \dfrac{2}5\dfrac\pi4 + \dfrac15\log\dfrac3{\sqrt2} - \dfrac15\log2,$$ $$\boxed{J = \dfrac1{10}\left(\pi +\log\dfrac98\right)}$$


The integrand is

$$f(x):=\frac{\cos(x)}{2\cos(x)+\sin(x)}.$$

We can form a linear combination to let the derivative of the denominator appear at the numerator:

$$af(x)+b=\frac{a\cos(x)+b(2\cos(x)+\sin(x))}{2\cos(x)+\sin(x)}=\frac{-2\sin(x)+\cos(x)}{2\cos(x)+\sin(x)},$$ is obtained with

$$b=-2,a=5.$$

Then by integrating, $$5F(x)-2x=\ln(|2\cos(x)+\sin(x)|),$$ from $0$ to $\dfrac\pi4$, $$5I-\frac\pi2=\ln\left(\frac{\frac3{\sqrt2}}{2}\right),$$

we get

$$I=\frac{\ln(9)-\ln(8)+\pi}{10}\approx0.3259375689\cdots$$ as claimed.


You have made a mistake in simplifying the integrand. You should have

$$\int \frac{\frac{2dv}{1+v^2}}{2+\frac{2v}{1-v^2}} = \int \frac{1-v^2}{(1+v^2)(1+v-v^2)}dv.$$

Now do partial practions. You get

$$ \frac{1-v^2}{(1+v^2)(1+v-v^2)} = \frac{2v-1}{5(v^2-v-1)} -\frac{2v-2}{5(v^2+1)} .$$

The first integral is a U-substitution. For the second, split the numerator up, then U-substitution and arctan respectively.