So I came across a problem after answering the integral. The problem was:
$\int\tan^3(3x)dx$. This is to be integrated. This is how I did it:
$$\begin{align}\int\tan^2(3x)\tan(3x)dx&=\int(\sec^2-1)\tan(3x)dx\\ &=\int(\sec(3x)\sec(3x)\tan(3x))dx-\int\tan(3x)dx\\ &=\frac{\sec^2(3x)}{6}-\frac{1}{3}\ln|\cos3x|\end{align}$$
But the case is; my answer is incorrect after I checked online. The answer was:
$\frac{\sec^2(3x)}{6}-\frac{1}{3}\ln|\sec3x|$. How did it turn out to be sec inside of the natural log if the value to integrate is a $\tan(3x)$. Any suggestion. Thanks in advance.
Making use of $\sec^2x-1=\tan^2x$ and $(\tan x)'=\sec^2x$.
$$\begin{aligned}\int\tan^33x\mathrm dx&=\int\sec^23x\tan3x\mathrm dx-\int\tan3x\mathrm dx\\&=\dfrac{1}{6}\tan^23x-\dfrac{1}{3}\ln\left|\sec 3x\right|+C\\&=\dfrac{\sec^23x-1}{6}+\dfrac{1}{3}\ln\left|\cos 3x\right|+C\\&=\dfrac{1}{6}\sec^23x+\dfrac{1}{3}\ln\left|\cos3x\right|+\underbrace{\left(C-\dfrac{1}{6}\right)}_{C'}\end{aligned}$$
$$\int \tan x\mathrm dx=\int\dfrac{\sin x}{\cos x}\mathrm dx=\int\dfrac{-(\cos x)'}{\cos x}\mathrm dx=-\ln \mid \cos x\mid=\ln\mid \sec x\mid $$