<s>[INST] 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?
 [/INST] 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$$
</s>