Verify $\frac{d}{dx}\tan^2x+2\ln \cos x=2\tan^3x$ Verify $\frac{d}{dx} \tan^2x+2 \ln \cos x=2 \tan^3x$
Since this was in an integration chapter, I did integration:
$\int{2 \tan^3 x \space dx} = 2 \int{\tan^2x \cdot \tan x \space dx} = 2 \int{(\sec^2 x-1) \tan x} \space dx = 2 \int{\sec^2 x \cdot \tan x - \tan x} \space dx$
Then I did tried Integration by Parts:

$\int{\sec^2 x \cdot \tan x}$
Let $u = \tan x$
$\frac{du}{dx} = \sec^2 x$
$\int{\sec^2 x \cdot \tan x} = \int{\tan x} \space du = \frac{\tan^2{x}}{2} + c $

$\int{\tan x \space dx} = \int{\frac{\sin x}{\cos x} \space dx}$
Let $u = \cos x$
$\frac{du}{dx} = - \sin x$
$du = - \sin x \space dx$
$\int{\tan x} \space dx = \int{- \frac{- \sin x}{\cos x} \space dx} = - \int{\frac{1}{\cos x} \space du} = - \ln{\mid \cos x \mid} + c$

Then I get $\tan^2 x + 2 \ln \mid \cos x \mid + c$, not what's expected: $\frac{d}{dx} \tan^2x+2\ln \cos x$... Oh nearly correct except no absolute value? 
 A: Your result includes the one you were supposed to prove, since $\ln(\cos x)$, and therefore the expression you were asked to differentiate,  is not defined when $\cos x<0$.   What you did is to prove the more general result 
$\frac{d}{dx}(\tan^2 x +2\ln|\cos x|)=2\tan^3 x$.
However, you did much more work than you were expected to do. You were expected to check the correctness of a formula for $\int 2\tan^3x\,dx$ (by differentiating) and instead you did the harder work of producing the formula. 
The differentiation is (as usual) very easy. We get $2\sec^2 x \tan x -\tan x$. Then we use the trigonometric identity $\sec^2 x=1+\tan^2 x$ to conclude that the derivative is $2\tan^3 x$. The same calculation works if we use $\ln(|\cos x|)$ instead of $\ln(\cos x)$. 
There are some imperfections in what you wrote, but they do not affect correctness. As was pointed out by @Michael Hardy, you should have written $\frac{d}{dx}(\tan^2 x +2\ln\cos x)$. Leaving out parentheses can be hazardous.
You also wrote $\int \sec^2 x \tan x=\int \tan x\,dx =\frac{\tan^2 x}{2} +c$. It is certainly true that $\int \sec^2 x \tan x =\frac{\tan^2 x}{2}+c$. However, the middle term $\int \tan x\,dx$ is not correct. Undoubtedly, what you had in mind is that in $\int \sec^2 x \,dx$, if we make the substitution $u=\tan x$, we have 
$$\int \sec^2 x\tan x\,dx=\int u\,du=\frac{u^2}{2}+c=\frac{\tan^2 x}{2}+c.$$
However, that is not what you wrote.
A little earlier, you wrote that you tried integration by parts.  However, what you carried out successfully was two integrations by substitution. 
Comment: The integral $\int \sec^2 x\tan x$ could have been done by parts, though the substitution that you did works more quickly. But for fun we do it by parts.
We want $\int \sec^2 x \tan x\,dx$. Let $du=\sec^2 x\,dx$, and let $v=\tan x$. Then we can take $u=\tan x$. Also, $dv=\sec^2 x\, dx$. Thus by the integration by parts formula, we have 
$$\int \sec^2 x\tan x\,dx =uv-\int u\,dv=\tan^2 x-\int \tan x \;\sec^2 x\, dx.$$
Let $I=\int \sec^2 x\tan x\, dx$. Then the above equation can be rewritten as 
$$I=\tan^2 x -I,$$
from which we conclude that $I=\frac{\tan^2 x}{2}$. Not quite right, because during the calculation, as is traditional, we left out constants of integration. Just fix things by adding the constant of integration at the end. 
The technique that we used above, though overkill for this problem, can be quite useful for other integration problems.
