What is wrong with my solution? $\int \cos^2 x \tan^3x dx$
Solution 1:
A very simple way to check if the answer to an indefinite integral is correct is to differentiate the answer. If you get the original function, your answer is correct, and is equal, up to a constant, with any other solutions.
We have $$\begin{align*} \frac{d}{dx}\left(\ln|\sec x| + \frac{\cos 2x}{4} + C\right) &= \frac{1}{\sec x}(\sec x)' + \frac{1}{4}(-\sin(2x))(2x)' + 0\\ &= \frac{\sec x\tan x}{\sec x} - \frac{1}{2}\sin(2x)\\ &= \tan x - \frac{1}{2}\left(2\sin x\cos x\right)\\ &= \frac{\sin x}{\cos x} - \sin x\cos x\\ &= \frac{ \sin x - \sin x\cos^2 x}{\cos x}\\ &= \frac{\sin x(1 - \cos^2 x)}{\cos x}\\ &= \frac{\sin^3 x}{\cos x}\\ &= \frac{\sin ^3 x \cos^2 x}{\cos^3x}\\ &= \frac{\sin^3 x}{\cos^3 x}\cos^2 x\\ &= \tan^3 x \cos^2 x. \end{align*}$$ So your answer is right.
This happens a lot with integrals of trigonometric identities, because there are a lot of very different-looking expressions that are equal "up to a constant". So the answer to $$\int\sin x\cos x\,dx$$ can be either $\sin^2 x + C$ or $-\cos^2x + C$; both correct, though they look different, because they differ by a constant: $-\cos^2x + C = 1-\cos^2x + (C-1) = \sin^2x + (C-1)$.
Solution 2:
Your integral is OK.
$${\ln |\sec x| + \frac{{\cos 2x}}{4} + C}$$
$${\ln \left|\frac 1 {\cos x}\right| + \frac{{1+\cos 2x}}{4} + C}-\frac 1 4$$
$${-\ln \left| {\cos x}\right| + \frac 1 2\frac{{1+\cos 2x}}{2} + K}$$
$${-\ln \left| {\cos x}\right| + \frac 1 2 \cos ^2 x + K}$$