### A problem by Abhisek Regmi

Evaluate $\int \tan^2 x \sec 4x \; dx$

$\int \tan^2 x \sec 4x \; dx$

$= \int \frac{\sin^2 x}{\cos^2 x \cos 4x} \; dx$

$= \int \frac{1- \cos 2x}{(1+\cos 2x)(2\cos^2 2x - 1)} \; dx$

$= \int \left( \frac{2}{1 + \cos 2x} + \frac{3}{2\cos^2 2x -1} - \frac{4\cos 2x}{2\cos^2 2x -1} \right) \; dx$

$=\int \left( \sec^2 x + 3 \sec 4x - \frac{4\cos 2x}{1 - 2 \sin^2 2x} \right) \; dx$

For the third integral substitute $u = \sin 2x$ and $du = 2 \cos 2x \; dx$ and we have

$= \tan x +\frac{3}{4}\ln|\sec 4x + \tan 4x| - \int \frac{2\; du}{1 - 2u^2}$

$= \tan x + \frac{3}{4}\ln|\sec 4x + \tan 4x| + \int \frac{du}{u^2 - \frac{1}{2}}$

$= \tan x + \frac{3}{4}\ln|\sec 4x + \tan 4x| + \frac{1}{\sqrt{2}} \ln \left| \frac{\sqrt{2} - 2u}{\sqrt{2} + 2u} \right| + C$

$= \tan x + \frac{3}{4}\ln|\sec 4x + \tan 4x| + \frac{1}{\sqrt{2}} \ln \left| \frac{\sqrt{2} - 2\sin 2x}{\sqrt{2} + 2\sin 2x} \right| + C$