Integral of $$$\tan{\left(x \right)}$$$
Related calculator: Integral Calculator
Solution
Rewrite the tangent as $$$\tan\left(x\right)=\frac{\sin\left(x\right)}{\cos\left(x\right)}$$$:
$${\color{red}{\int{\tan{\left(x \right)} d x}}} = {\color{red}{\int{\frac{\sin{\left(x \right)}}{\cos{\left(x \right)}} d x}}}$$
Let $$$u=\cos{\left(x \right)}$$$.
Then $$$du=\left(\cos{\left(x \right)}\right)^{\prime }dx = - \sin{\left(x \right)} dx$$$ (steps can be seen »), and we have that $$$\sin{\left(x \right)} dx = - du$$$.
Therefore,
$${\color{red}{\int{\frac{\sin{\left(x \right)}}{\cos{\left(x \right)}} d x}}} = {\color{red}{\int{\left(- \frac{1}{u}\right)d u}}}$$
Apply the constant multiple rule $$$\int c f{\left(u \right)}\, du = c \int f{\left(u \right)}\, du$$$ with $$$c=-1$$$ and $$$f{\left(u \right)} = \frac{1}{u}$$$:
$${\color{red}{\int{\left(- \frac{1}{u}\right)d u}}} = {\color{red}{\left(- \int{\frac{1}{u} d u}\right)}}$$
The integral of $$$\frac{1}{u}$$$ is $$$\int{\frac{1}{u} d u} = \ln{\left(\left|{u}\right| \right)}$$$:
$$- {\color{red}{\int{\frac{1}{u} d u}}} = - {\color{red}{\ln{\left(\left|{u}\right| \right)}}}$$
Recall that $$$u=\cos{\left(x \right)}$$$:
$$- \ln{\left(\left|{{\color{red}{u}}}\right| \right)} = - \ln{\left(\left|{{\color{red}{\cos{\left(x \right)}}}}\right| \right)}$$
Therefore,
$$\int{\tan{\left(x \right)} d x} = - \ln{\left(\left|{\cos{\left(x \right)}}\right| \right)}$$
Add the constant of integration:
$$\int{\tan{\left(x \right)} d x} = - \ln{\left(\left|{\cos{\left(x \right)}}\right| \right)}+C$$
Answer: $$$\int{\tan{\left(x \right)} d x}=- \ln{\left(\left|{\cos{\left(x \right)}}\right| \right)}+C$$$