# Evaluate $\int \frac{1}{\sin x\cos x} dx$

Question: How to evaluate $\displaystyle \int \frac{1}{\sin x\cos x} dx$

I know that the correct answer can be obtained by doing:
$\displaystyle\frac{1}{\sin x\cos x} = \frac{\sin^2(x)}{\sin x\cos x}+\frac{\cos^2(x)}{\sin x\cos x} = \tan(x) + \cot(x)$ and integrating.

However, doing the following gets a completely different answer: \begin{eqnarray*} \int \frac{1}{\sin x\cos x} dx
&=&\int \frac{\sin x}{\sin^2(x)\cos x} dx\\ &=&\int \frac{\sin x}{(1-\cos^2(x))\cos x} dx. \end{eqnarray*} let $u=\cos x, du=-\sin x dx$; then \begin{eqnarray*} \int \frac{1}{\sin x\cos x} dx
&=&\int \frac{-1}{(1-u^2)u} du\\
&=&\int \frac{-1}{(1+u)(1-u)u}du\\ &=&\int \left(\frac{-1}{u} - \frac{1}{2(1-u)} + \frac{1}{2(1+u)}\right) du\\ &=&-\ln|\cos x|+\frac{1}{2}\ln|1-\cos x|+\frac{1}{2}\ln|1+\cos x|+C \end{eqnarray*}

I tested both results in Mathematica, and the first method gets the correct answer, but the second method doesn't. Is there any reason why this second method doesn't work?

• The second method looks right too. Did you try to simplify the answer you got with the second method? Nov 5, 2010 at 17:05
• The second method is correct. Try Simplify[D[-Log[Cos[x]]+1/2*Log[1-Cos[x]]+1/2*Log[1+Cos[x]],x]]; it gives Csc[x] Sec[x]. Nov 5, 2010 at 17:14
• I was hoping for the arbitrariness of "+C" to be key (I like when that happens!), but it turns out that all you need to do is combine the logs appropriately.
– Blue
Nov 5, 2010 at 17:21
• In the second integral $\int -\frac{1}{2(1-u)}=+\frac{1}{2}\ln|1-u|$? Nov 5, 2010 at 19:00

If I take the derivative of your second answer (call it $g(x)$), I get: \begin{eqnarray*} \frac{dg}{dx} & = & -\frac{-\sin x}{\cos x} + \frac{\sin x}{2(1-\cos x)} + \frac{-\sin x}{2(1+\cos x)}\\ & = & \frac{\sin x\left(1-\cos^2 x + \frac{1}{2}\cos x(1+\cos x) - \frac{1}{2}\cos x(1-\cos x)\right)}{\cos x(1-\cos x)(1+\cos x)}\\ & = & \frac{\sin x\left( 1- \cos^2 x + \frac{1}{2}\cos x + \frac{1}{2}\cos^2 x - \frac{1}{2}\cos x + \frac{1}{2}\cos^2 x\right)}{\cos x(1-\cos^2 x)}\\ & = & \frac{\sin x}{\cos x\>\sin^2 x} = \frac{1}{\cos x\sin x}. \end{eqnarray*} So I'm not sure why Mathematica says the second method is not "the right answer".

This may be an easier method $$\int\frac{1}{\sin{x} \cdot \cos{x}} \ dx = \int\frac{\sec^{2}{x}}{\tan{x}} \ dx$$ by multiplying the numerator and denominator by $\sec^{2}{x}$

• even easier, it could be $\int 2\csc(2x) dx$. Nov 6, 2010 at 3:42

Taking log of $\rm\ sin^2(x)\ =\ 1 - cos^2(x)\ = (1-cos(x))\ (1+cos(x))\$ shows both answers identical

The second method gives the same answer as the first. By the first method, the answer you get is $-\log(\cos x) + \log(\sin x)$. The first term is the same as what you get by the second method.

What you need to show is that $\log(\sin x) = \frac{1}{2}\log(1-\cos x) + \frac{1}{2}\log(1+\cos x)$.

\begin{equation} \begin{split} \frac{1}{2}\log(1-\cos x) + \frac{1}{2}\log(1+\cos x) &= \frac{1}{2}\left( \log(2 \sin^2 \frac{x}{2}) + \log(2 \cos^2 \frac{x}{2})\right)\\ & = \log(2 \sin \frac{x}{2} \cos \frac{x}{2}) \end{split} \end{equation}

Tangent half-angle substitution

$$\displaystyle \int \frac{1}{\sin x\cos x} dx=\displaystyle \int \frac{(1+t^2)}{t(1-t^2)} dt=\displaystyle \int \frac{1}{t} dt-\displaystyle \int \frac{1}{1-t} dt-\displaystyle \int \frac{1}{1+t} dt$$

• This is definitely the right way to go
– Vim
Jan 29, 2015 at 14:24

$\sin(x)\cos(x) = \frac{1}{2} \sin(2x)$.

$I = 2\int \csc(2x)$ let $u = 2x$ then:

$I = \int \csc(u) du = - \log(\cot(2x) + \csc(2x)) + C$

Another way to integrate would be to let $\displaystyle t = \frac{\sin{x}}{\cos{x}}$, then $\displaystyle \frac{dt}{dx} = \frac{1}{\cos^2{x}} \Rightarrow dx = \cos^2{x}\;{dt}$.

Thus $\displaystyle I = \int\frac{\cos^2{x}}{\sin{x}}\;{dt} = \int\frac{\cos{x}}{\sin{x}}\;{dt} = \int\frac{1}{t}\;{dt} = \ln{t}+k = \ln\frac{\sin{x}}{\cos{x}}+k$.

• You forgot a $\cos x$ in the denominator in the first step. By the way, this is essentially the same method as in Chandru1's answer, although perhaps done in a more systematic way ("apply the tan-half-angle substitution to $\int (2/\sin 2x)dx$"). Nov 5, 2010 at 18:33

Integrand $=\dfrac {1}{\sin(x)\cos(x)} = 2 \csc 2x$

Its integral is obtained by direct application of listed standard trigonometric function integration formulae. Using chain rule for constant double angle:

$$2 \log (\tan \dfrac{2 x}{2}) \cdot \frac12= \log (\tan x ) + c$$

agrees with OP's second result when it is further simplified.

Let $$\int \frac{1}{\sin x \cos x}dx=\int \frac{2}{2 \sin x \cos x}dx$$

=$$\int \frac{2}{\sin 2x}dx$$

Let $$\tan x=t$$

$$\sin 2x=\frac{2t}{1+t^2}$$

$$\tan^{-1} t=x$$

$$\frac{1}{1+t^2}dt=dx$$

$$2\int \frac{dx}{\sin 2x} =2\int \frac{1+t^2}{2t}\cdot\frac{dt}{1+t^2}$$

=$$\int\frac{dt}{t}$$

=$$\ln t+C$$

=$$\ln (\tan x)+C$$

$$\int \frac{1}{\sin x\cos x} dx = \int( \tan x+\cot x)\, dx= \int\frac{\sin x}{\cos x}\, dx+\int\frac{\cos x}{\sin x} \,dx$$ from where it should be fairly simple....(choose correctly the variables though)