# Integral of tan(x)

So I wanted to find a way to work out any trigonometric integral by simply knowing the integral of the two main trigonometric functions; $\sin(x)$ and $\cos(x)$. This is since any trigonometric function (that I know of so far) can be written with the basic $\sin(x)$ and $\cos(x)$, like all of the $\tan(x)$, $\cot(x)$, $\sec(x)$, $\mathrm{cosec}(x)$, etc. Even more complicated ones like $sec^3(x)$ or whatever.

So I know that :

• $\displaystyle\int \sin(x) = -\cos(x)$
• $\displaystyle\int \cos(x) = \sin(x)$

But to use these two functions to calculate the integral of any other function I'd need to understand how multiplications work in integrals.

I recall from derivation that the "product rule" goes as follows :

$$y = u\cdot v \implies \frac{\mathrm{d}y}{\mathrm{d}x} = v\cdot\frac{\mathrm{d}u}{\mathrm{d}x} + u\cdot\frac{\mathrm{d}v}{\mathrm{d}x}$$

And I found the formula for the equivalent "product rule" for integration, it goes as follows : $$\int \left(u\cdot\frac{\mathrm{d}v}{\mathrm{d}x}\right)\mathrm{d}x = u\cdot v - \int \left(v\cdot\frac{\mathrm{d}u}{\mathrm{d}x}\right)\mathrm{d}x + c$$

which is not quite as simple as in derivation, but I went along with it. So I decided to try it with the most simple trigonometric function I could think of (other than $\sin(x)$ and $\cos(x)$). I tried it with $\tan(x)$. I always liked using the product rule in differentiation with negative powers rather than the quotient rule because the product rule works just as well and it's just one less formula to remember. So I tried to use this rule for the negative power given to $\cos(x)$ when expanding the $\tan(x)$ to $\dfrac{\sin(x)}{\cos(x)}$.

I guess my question is simply where have I gone wrong in my working out. Here it is :

\begin{align*} \int \tan(x)\,\mathrm{d}x &= \int \frac{\sin(x)}{\cos(x)}\,\mathrm{d}x \\ &= \int \sin(x)\cdot\cos^{-1}(x)\,\mathrm{d}x \\ &= \int \left(u\cdot\frac{\mathrm{d}v}{\mathrm{d}x}\right)\mathrm{d}x \end{align*}

Then to write it in the form of $\displaystyle\int\left(u\cdot\dfrac{\mathrm{d}v}{\mathrm{d}v}\right)\,\mathrm{d}x$, I took $\sin(x)$ to be the $\dfrac{\mathrm{d}v}{\mathrm{d}x}$ term, and $\cos^{-1}(x)$ to be the $u$ term, i.e., :

• $\dfrac{\mathrm{d}v}{\mathrm{d}x} = \sin(x)$, and
• $u = \cos^{-1}(x)$

So what I need to find out the solution is $u$, $v$, $\dfrac{\mathrm{d}u}{\mathrm{d}x}$ as given in the form: $$u\cdot v - \int \left(v\cdot\frac{\mathrm{d}u}{\mathrm{d}x}\right)\mathrm{d}x + c$$

So...

• $u = \cos^{-1}(x)$, and
• $v = \displaystyle\int\sin(x)\,\mathrm{d}x = -\cos(x)$

To work out $\dfrac{\mathrm{d}u}{\mathrm{d}x}$, I used the derivative chain rule:

• $u = \cos^{-1}(x)$
• $a = \cos(x)$
• $\dfrac{\mathrm{d}u}{\mathrm{d}x} = \dfrac{\mathrm{d}u}{\mathrm{d}a}\cdot\dfrac{\mathrm{d}a}{\mathrm{d}x}$
• $\dfrac{\mathrm{d}u}{\mathrm{d}a} = -a^{-2} = -\cos^{-2}(x)$
• $\dfrac{\mathrm{d}a}{\mathrm{d}x} = -\sin(x)$

Therefore ... $$\dfrac{\mathrm{d}u}{\mathrm{d}x} = \dfrac{\mathrm{d}u}{\mathrm{d}a}\cdot\dfrac{\mathrm{d}a}{\mathrm{d}x} = (-\cos^{-2}(x))\cdot(-\sin(x)) = \cos^{-2}(x)\cdot\sin(x)$$

So the solution (according to the integral product rule formula) is : \begin{align*} u\cdot v - \int \left(v\cdot\frac{\mathrm{d}u}{\mathrm{d}x}\right)\mathrm{d}x + c &= \cos^{-1}(x)\cdot(-\cos(x)) - \int (-\cos(x))\cdot(\cos^{-2}(x)\cdot\sin(x))\mathrm{d}x + c \\ &= -1 - \int (-\sin(x))\cdot\cos^{-1}(x)\,\mathrm{d}x + c \\ &= \int\sin(x)\cdot\cos^{-1}(x)\,\mathrm{d}x + c \\ &= \int \frac{\sin(x)}{\cos(x)}\,\mathrm{d}x + c = \int\tan(x)\,\mathrm{d}x + c \end{align*}

So my final conclusion is that : $$\int\tan(x)\,\mathrm{d}x = \int\tan(x)\,\mathrm{d}x + c$$

Which isn't very useful for me. Where have I gone wrong and is there a better integral product rule?

Also, in the line : $$u\cdot v - \int\left(v\cdot\frac{\mathrm{d}u}{\mathrm{d}x}\right)\mathrm{d}x + c$$

If neither $v$ nor $\dfrac{\mathrm{d}u}{\mathrm{d}x}$ form a constant, then you're simply left with another two functions in an integration that need to be multiplied together, which brings us back to the first problem, how do you multiply two functions in an integration?

• Have you considered looking up a derivation? It’s plastered all over the internet. – gen-z ready to perish Mar 17 '18 at 17:42
• Hint : Use $\tan(x)=\frac{\sin(x)}{\cos(x)}$ and substitute $\cos(x)=z$ – Peter Mar 17 '18 at 17:42
• Also note the derivative of $\cos x$ – Karl Mar 17 '18 at 17:43
• Overall I'm not sure (others will tell you for sure ) that it is possible to compute all trig integrals as you describe. I suspect it isn't. – Karl Mar 17 '18 at 17:52
• A useful substitution is the half angle tangent. This cracks many nuts. – Karl Mar 17 '18 at 18:01

## 3 Answers

write $$\int\tan(x)dx=-\int\frac{-\sin(x)}{\cos(x)}dx$$ and note that $$(\cos(x))'=-\sin(x)$$ this integral is from the form $$\int\frac{f'(x)}{f(x)}dx$$

• Thanks, I have come across that formula too, I was simply wondering if I made an error in my working out since it was a multiplication but didn't come to any reasonable solution. I don't know if this is the case, but it seems that I won't always be able to get a function (like tan(x)) into the form you show above, so I would rather rely on the product rule if possible. Or am I completely wrong and this is the only way to integrate tan(x)? – Lucas Dyson-Diaz Mar 17 '18 at 17:51
• i would say this is not the only way to solve this integral, but a nice one – Dr. Sonnhard Graubner Mar 17 '18 at 17:55
• Integrate $\sin(x) , \sec(x)$ by parts as usual treating as a product. – Narasimham Mar 17 '18 at 17:56
• Can I do it my way? Or was my working out right, but I can't be done my way? – Lucas Dyson-Diaz Mar 17 '18 at 18:17

$$\int \tan(x)dx=\int \frac {\sin(x)}{\cos(x)}dx=-\int \frac {du}{u}$$

Where $u=\cos(x)$

Just notice that $\tan = \frac{\sin}{\cos}$ which is nothing but $-\frac{f'}{f}$

hence the integral is trivial and it's minus the logarithm of $f$:

$$-\int \frac{f'}{f}\ dx = -\ln(f)$$

In your case: $-\ln(\cos(x)) + C$

• Thanks, I have come across that, but this is simply an example to lead to harder ones (where I assume I cannot use the form du/d), I there no way to use the product rule here? Or is it that when one rule doesn't work (product rule) the other one always works (your rule) and vice versa? – Lucas Dyson-Diaz Mar 17 '18 at 17:55