Integrating $\int \frac{8 dx}{3 \cos 2x + 1}$ to arctan rather than log [Edit: It is becoming increasingly likely that the expected answer containing arctan might be a typo from my book, which is transcribed correctly here, so an answer containing log might be correct after all. Sorry about that and thanks for the answers so far, I've learned a lot!]
I'm trying to integrate:
$$
\int \frac{8 dx}{3 \cos 2x + 1} \\
$$
So I tried substituting $x$ for $z$:
$$
z = \tan \frac{x}{2} \\
\cos x = \frac{1 - z^2}{1 + z^2} \\
dx = \frac{2 dz}{1 + z^2} \\
$$
Then I tried replacing $\cos 2x$ with $2 \cos^2 x - 1$ followed by some work:
$$
\int \frac{4(1 + z^2) dz}{z^4 - 4z^2 + 1} \\
$$
If I try substituting $z$ back to $x$, it seems my answer will contain log rather than the expected arctan:
$$
\frac{x}{3} - \frac{5}{6} \arctan (2 \tan \frac{x}{2}) + C \\
$$
Did I take a wrong turn somewhere?
 A: HINT:
$$\dfrac8{3\cos2x+1}=\dfrac{8\sec^2x}{3(1-\tan^2x)+1+\tan^2x}$$
Now set $\tan x=y$
A: Notice, the steps of substitution you showed are correct but your final answer is wrong. It shouldn't be in terms of $\arctan$
if you let $z=\tan \frac{x}{2}\implies dx=\frac{2\ dz}{1+z^2}$ then $$\int \frac{8\ dx}{3\cos 2x+1}$$
$$=\int \frac{8\ dx}{3(2\cos^2x-1)+1}=\int \frac{4\ dx}{3\cos^2x-1}$$
$$=\int \frac{4}{3\left(\frac{1-z^2}{1+z^2}\right)^2-1}\frac{2\ dz}{1+z^2}$$
$$=\int \frac{4}{3\left(\frac{1-z^2}{1+z^2}\right)^2-1}$$
$$=\int \frac{4(1+z^2)}{z^4-4z^2+1}\ dz$$
$$=4\int \frac{1+\frac{1}{z^2}}{\left(z-\frac 1z\right)^2-2}\ dz$$
$$=4\int \frac{d\left(z-\frac{1}{z}\right)}{\left(z-\frac 1z\right)^2-(\sqrt 2)^2}$$
$$=\frac{4}{2\sqrt 2}\ln\left|\frac{z-\frac{1}{z}-\sqrt 2}{z-\frac{1}{z}+\sqrt 2}\right|+C$$
substituting back $z=\tan \frac x2$, 
$$=\sqrt 2\ln \left|\frac{\tan\frac{x}{2}-\cot\frac{x}{2}-\sqrt 2}{\tan\frac{x}{2}-\cot\frac{x}{2}+\sqrt 2}\right|+C$$
A: If we are going to make a Weierstrass-style substitution, it seems more natural, because of the $\cos 2x$, to let $z=\tan x$. Then $\cos 2x=\frac{1-z^2}{1+z^2}$ and $dx=\frac{1}{1+z^2}\,dz$. Thus our integral becomes, after a little manipulation,
$$\int\frac{4}{2-z^2}\,dz.$$ 
