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!

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.$$
