How to find the integral of $\tan x - \sec x\tan x$? $$\int(\tan x - \sec x\tan x)dx$$
I rewrote the integral like this:
$$\int\left(\frac{\sin x}{\cos x}- \sec x\tan x\right)dx$$
and using $u$-substitution for the first term I got a final answer of:
$$-\ln|\cos x| - \sec x + c$$
Where was my mistake?
 A: You made no mistake.
Going to explain a bit to be clearer.
The first part is correct for
$$\int \tan(x)\ \text{d}x = -\ln|\cos(x)| + c_1$$
and this is easy (you just see the tangent as sine/cosine recognising it has the form $f'(x)/f(x)$ (with a minus sign) which is nothing but a logarithmic derivative.
About the second term:
$$\int \sec(x)\tan(x)\ \text{d}x = \sec(x) + c_2$$
Indeed by the definition: $\sec(x) = \dfrac{1}{\cos(x)}$
We have
$$\dfrac{\text{d}}{\text{d}x} \sec(x) = \dfrac{\sin(x)}{\cos^2(x)} \equiv \dfrac{1}{\cos(x)}\dfrac{\sin(x)}{\cos(x)} = \sec(x)\tan(x)$$
And of course the constant vanished in the derivative.
You made no mistake.
A: $$\tan x-\sec x\tan x=\frac{\sin x}{\cos x}-\frac1{\cos x}\frac{\sin}{\cos x}$$
If we first try and do the integral of $\tan x$:
$$I_1=\int\frac{\sin x}{\cos x}dx$$
$u=\cos x\Rightarrow dx=-\frac{du}{\sin x}$ and so:
$$I_1=-\int\frac1udu=-\ln|u|+C_1=-\ln|\cos x|+C_1=\ln|\sec x|+C_1$$
and now for $\sec x\tan x$:
$$I_2=\int\frac{\sin x}{\cos^2x}dx$$
$$=-\int\frac1{u^2}du=\frac1u+C_2=\frac1{\cos x}+C_2=\sec x+C_2$$
and so:
$$\int\tan x-\sec x\tan xdx=\ln|\sec x|-\sec x+C_3$$
A: $$
\log|\sec(x)|=-\log|\cos(x)|
$$
If we remove the absolute value signs, then this is obvious:
\begin{align}
\log\left(\cos(x)^{-1}\right)=-\log(\cos(x)) \, .
\end{align}
This still holds for $\log|\sec(x)|$ and $-\log|\cos(x)|$. This can be verified by noting that $\log|\sec(x)|$ is equal to $\log\left(\sec(x)\right)$ or $\log\left(-\sec(x)\right)$, and whenever $\sec$ is positive, so is $\cos$.
