# How can I integrate $\int \arctan(\sec x + \tan x) dx$

I got this problem in my homework exercise:

$$\int \arctan(\sec x + \tan x) dx$$

I simplified it to

$$\int \arctan\left(\dfrac{1+\sin x}{\cos x}\right) dx$$

$$=\int \arctan\left(\sqrt{\dfrac{1+\sin x}{1-\sin x}}\right) dx$$

now, I tried putting $\sqrt{\dfrac{1+\sin x}{1-\sin x}} = \tan t$

Then $x = \arcsin(\sin^2 t-\cos^2 t)$ but it becomes complete mess after that!

$${1+\sin(x)\over \cos(x)}={\sin(x/2)+\cos(x/2)\over \cos(x/2)-\sin(x/2)}={1+\tan(x/2)\over 1-\tan(x/2)}=\tan(\pi/4+x/2)$$

Also keep in mind: $$\tan^{-1}(\tan(z))=\begin{cases}z&-\pi/2\le z\le\pi/2\\ z-\pi&\ \ \ \pi/2\lt z\le \pi\\z+\pi&\ \ -\pi\le z\lt-\pi/2 \end{cases}$$

• That was fast. Did you do this before? – N.S.JOHN Aug 15 '16 at 7:15
• @N.S.JOHN Had a lot of practice in trigonometry and integration in 11th and 12th standard ;-) – Qwerty Aug 15 '16 at 7:16
• @N.S.JOHN Since $\arctan(\tan(x))$ is not always equal to $x$, the primitive you are looking for is not $\int (\pi/4+x/2)\,dx$. – Robert Z Aug 15 '16 at 7:36
• I think My edit will help @N.S.JOHN about the problem he was about to face. – Qwerty Aug 15 '16 at 7:51

An direct way to use the integration by parts:

Let $u = \arctan(\sec(x)+\tan(x))$ then $du = \frac{1}{2} dx$

$dv = dx$ then $v = x$.

Then the integral becomes $$x \arctan(\sec(x)+\tan(x)) - \int \frac{x}{2}dx$$

Using integration by parts, we get:

$$\int \arctan(\sec x + \tan x) dx=x\arctan(\sec x + \tan x)-\dfrac{x^2}{4}+C$$

By integration by parts we obtain $$\int \arctan(\sec x + \tan x) dx=x\arctan(\sec x + \tan x)-\dfrac{x^2}{4}+C.$$ Since we have the identity (see Qwerty's answer): $$\sec x + \tan x={1+\sin(x)\over \cos(x)}=\tan(\pi/4+x/2),$$ the primitive can be simplified (!?) to $$x\arctan(\sec x + \tan x)-\dfrac{x^2}{4}+C=x\arctan(\tan(\pi/4+x/2))-\dfrac{x^2}{4}+C\\=\frac{x^2+\pi x}{4}-\pi x \left\lfloor \frac{x}{2\pi}+\frac{3}{4}\right\rfloor+C.$$

P.S. Note that if we erroneously write that $\arctan(\sec x + \tan x)=\pi/4+x/2$, then we get a different answer $$\int \arctan(\sec x + \tan x) dx=\int (\pi/4+x/2) dx=\frac{x^2+\pi x}{4}+C.$$

sec x + tan x = tan t. then sec x - tan x = cot t. sec x = (cot t + tan t)/2. (sec t)^2 dt = sec x(sec x + tan x)dx = (tan t(tan t + cot t)/2)dx. Substitute dx and simplify.