Once I met the indefinite integral $$I=\int \frac{\tan (3 x)}{\tan x+\sec x} d x,$$ I thought of triple-angle formula of tangent

$$\tan 3 x =\frac{3 \tan x-\tan ^3 x}{1-3 \tan ^2 x} \tag*{} $$

For simplicity, I first rationalised the denominator of $I$ as $$\displaystyle I=\int \tan (3 x)(\sec x-\tan x) d x\tag*{} $$ and get $\displaystyle \begin{aligned}I & =\int \frac{\left(3-\tan ^2 x\right) \tan x}{1-3 \tan ^2 x}(\sec x-\tan x) d x \\& =\int \frac{3-\tan ^2 x}{1-3 \tan ^2 x}\left(\sec x \tan x-\sec ^2 x+1\right) d x \\& = \underbrace{\int \frac{4-s^2}{4-3 s^2} d s}_{J} - \underbrace{\int \frac{3-t^2}{1-3 t^2} d t}_{K} + \underbrace{\int \frac{3-\tan ^2 x}{1-3 \tan ^2 x} d x}_{L} \end{aligned}\tag*{} $ where $s=\sec x$ and $t=\tan x$.

To deal with these $3$ integrals, we used the result:

$$ \int \frac{1}{a^2-b^2 x^2} d x=\frac{1}{a b} \tanh ^{-1}\left(\frac{b x}{a}\right)+c $$

For $J$, $$\displaystyle \begin{aligned}\int \frac{4-s^2}{4-3 s^2} d s & =\frac{1}{3} \int \frac{8+\left(4-3 s^2\right)}{4-3 s^2} d s\\&=\frac{8}{3} \int \frac{d s}{2^2-(\sqrt{3} s)^2}+\frac{s}{3} \\& =\frac{4}{3 \sqrt{3}} \tanh ^{-1}\left(\frac{\sqrt{3} s}{2}\right)+\frac{s}{3}+c_1\end{aligned}\tag*{} $$

For $K$, $\displaystyle \begin{aligned}K & =\int \frac{3-t^2}{1-3 t^2} d t \\& =\frac{1}{3} \int \frac{8+\left(1-3 t^2\right)}{1-3 t^2} d t \\& =\frac{8}{3 \sqrt{3}} \tanh ^{-1}(\sqrt{3} t)+\frac{t}{3}+c_2\end{aligned}\tag*{} $

For $L$, $\displaystyle \begin{aligned}L & =\int \frac{3-\tan ^2 x}{1-3 \tan ^2 x} d x \\& =\int \frac{2 \sec ^2 x+\left(1-3 \tan ^2 x\right)}{1-3 \tan ^2 x} d x \\& =2 \int \frac{d t}{1-3 t^2}+x\\&=\frac{2}{\sqrt{3}} \tanh ^{-1}(\sqrt{3} t)+x+c_3\end{aligned}\tag*{} $

Now we can conclude that $ \boxed{\displaystyle I=\frac{4}{3\sqrt{3}} \tanh ^{-1}\left(\frac{\sqrt{3} \sec x}{2}\right)+\frac{\sec x}{3}-\frac{2}{3 \sqrt{3}} \tanh ^{-1}(\sqrt{3} \tan x)-\frac{\tan x}{3}+x+C }\tag*{} $

My solution is rather tedious and long. Is there any simpler method?

Your comments and alternative methods are highly appreciated.

  • 1
    $\begingroup$ Note that $ \int \frac{1}{a^2-b^2 x^2} d x=\frac{1}{a b} \tanh ^{-1}\frac{b x}{a} $ is only valid for $a^2> b^2x^2$, which is not always the case here $\endgroup$
    – Quanto
    Commented May 15, 2023 at 2:06
  • $\begingroup$ Yes, you are right. Maybe use log is safe. $\endgroup$
    – Lai
    Commented May 15, 2023 at 2:28

3 Answers 3


Let $$I_1=\int \frac{\tan(3x)}{\tan x+\sec x}dx, ~~I_2=\int \frac{\tan(3x)}{-\tan x+\sec x}dx$$

Use the property: $\sec^2x-\tan^2x=1$


$$I_1+I_2=2\int \tan(3x)\sec (x)~ dx$$


$$I_1-I_2=-2\int \tan(3x)\tan(x)~dx$$

  • $\begingroup$ Thank you very much for your alternative method, though the steps are similar to rationalisation. $\endgroup$
    – Lai
    Commented May 15, 2023 at 2:27
  • $\begingroup$ Yes, just get rid of the denominators. $\endgroup$
    – MathFail
    Commented May 15, 2023 at 2:28
  • $\begingroup$ agree with you! $\endgroup$
    – Lai
    Commented May 15, 2023 at 2:31

Using $x=\tan^{-1}(t)$ $$I=\int \frac{\tan (3 x)}{\tan( x)+\sec (x)}\, dx$$ $$I=\int\frac{t \left(t^2-3\right) \sqrt{t^2+1}}{3 t^2-1}\,dt-\int\frac{t^2 \left(t^2-3\right)}{3 t^2-1}\,dt$$

The second integral is simple since $$\frac{t^2 \left(t^2-3\right)}{3 t^2-1}=\frac{t^2}{3}-\frac{8}{9 \left(3 t^2-1\right)}-\frac{8}{9}$$ For the first integral $$\frac{t \left(t^2-3\right) \sqrt{t^2+1}}{3 t^2-1}=\frac{1}{3} t \sqrt{t^2+1}-\frac 83\,\frac{t \sqrt{t^2+1}}{3 t^2-1}$$ Using partial fraction decomposition $$\frac{t \sqrt{t^2+1}}{3 t^2-1}=\frac{\sqrt{t^2+1}}{2 \left(3 t-\sqrt{3}\right)}+\frac{\sqrt{t^2+1}}{2 \left(3 t+\sqrt{3}\right)}$$

So, the only "problematic" integral is $$\int \frac{\sqrt{t^2+1}}{t+a}\,dt$$ which is not so difficult.


Even simpler using the tangent half-angle substitution foloowed by partial fraction decomposition $$I=\int \Big(\frac{2}{3 \left(t^2-4 t+1\right)}-\frac{2}{t^2+4 t+1}+\frac{2}{t^2+1}-\frac{2}{3 (t+1)^2} \Big)\,dt$$ Just complete the squares. $$I=

  • $\begingroup$ Interesting partial fractions. $\endgroup$
    – Lai
    Commented May 15, 2023 at 4:19

$$\begin{align*} & \int\frac{\tan(3x)}{\tan x+\sec x} \, dx \\ &= \int \frac{\tan^3x-3\tan x}{3\tan^2 x-1} \cdot \frac{\cos x}{\sin x+1} \, dx \\ &= \int \frac{\frac y{\sqrt{1-y^2}} \left(\frac{y^2}{1-y^2}-3\right)}{\frac{3y^2}{1-y^2} - 1} \cdot \frac{dy}{y+1} \tag1 \\ &= \int \frac{y \left(4y^2-3\right)}{(y+1)\left(4y^2-1\right)} \cdot \frac{dy}{\sqrt{1-y^2}} \\ &= -2 \int \frac{-\frac{2z}{1+z^2} \left(\frac{16z^2}{(1+z^2)^2}-3\right)}{\left(1-\frac{2z}{1+z^2}\right) \left(\frac{16z^2}{(1+z^2)^2}-1\right)} \cdot \frac1{1-\frac{2z^2}{1+z^2}} \cdot \frac{1-z^2}{(1+z^2)^2} \, dz \tag2 \\ &= 4 \int \frac{z (3z^4-10z^2+3)}{(z-1)^2\left(z^2+1\right)\left(z^4-14z^2+1\right)} \, dz \\ &= \frac23 \left(\int \frac{dz}{(z-1)^2} - 3 \int \frac{dz}{z^2+1} + 3 \int \frac{dz}{z^2-4z+1} - \int \frac{dz}{z^2+4z+1}\right) \end{align*}$$

  • $(1)$ : substitute $y=\sin x$
  • $(2)$ : substitute $z=\dfrac{\sqrt{1-y^2}-1}y$
  • $\begingroup$ Interesting substitution and partial fractions. $\endgroup$
    – Lai
    Commented May 15, 2023 at 4:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .