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

• Please: Write $\tan x$, $\arctan x$, $\ln x$, not $tan x$, $arctan x$, $ln x$. See my edits. – Michael Hardy Feb 19 '16 at 0:24

First of all, since $v=\tan\frac{x}{2}$ with $\tan\frac{\frac{\pi}{4}}{2}=\tan\frac{\pi}{8}=\sqrt 2-1$, you should have $$\int_{0}^{\frac{\pi}{4}}\frac{dx}{2+\tan x}=\int_{0}^{\color{red}{\sqrt 2-1}}\frac{\frac{2dv}{1+v^2}}{2+\frac{2v}{1-v^2}}$$

Also, you should have \begin{align}&\frac{1-v^2}{(1+v^2)(-v^2+v+1)}\\&=\color{red}{+}\frac 15\cdot\frac{-2v+4}{v^2+1}+\frac{1}{5}\cdot\frac{-2v+1}{-v^2+v+1}\\&=-\frac 15\cdot\frac{2v}{v^2+1}+\frac 45\cdot\frac{1}{v^2+1}+\frac{1}{5}\cdot\frac{-2v+1}{-v^2+v+1}\end{align}

Now these give \begin{align}&\int_{0}^{\frac{\pi}{4}}\frac{dx}{2+\tan x}\\&=\left[-\frac 15\ln(v^2+1)+\frac 45\arctan v+\frac 15\ln(-v^2+v+1)\right]_{0}^{\sqrt 2-1}\\&=-\frac 15\ln(4-2\sqrt 2)+\frac 45\arctan (\sqrt 2-1)+\frac 15\ln(3\sqrt 2-3)\\&=\frac 15\ln\left(\frac{3\sqrt 2-3}{4-2\sqrt 2}\right)+\frac 45\cdot\frac{\pi}{8}\\&=\frac 15\ln\left(\frac{3\sqrt 2}{4}\right)+\frac{\pi}{10}\approx 0.32594\end{align}

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)}$$

• nice...........+1 – Bhaskara-III Feb 23 '16 at 12:53

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.

• how dis you get to $(1+v^2)(1+v-v^2)$? – gbox Feb 19 '16 at 0:47
• @gbox This is just fraction manipulation really (common denominator, factoring, etc...) – GaussTheBauss Feb 19 '16 at 0:49
• The second term should be wrong. – mathlove Feb 23 '16 at 6:09

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.

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.

• I think you mean something like "a positive, bounded function over a bounded interval" in your first sentence, right? – mickep Feb 23 '16 at 6:57

I have done the sum u just look at it.

Here after step 2 I have used the method where u have to do like this

Af(x) +Bf'(x) =numerator. and here A and B are constant.

Here f(x)=denominator =2cosx +sinx Hence f'(x) =-2sinx +cosx So we get A = 2/5 B= 1/5 Thanks for asking such a nice question.