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

Below is a problem I attempted. However, I failed to find the right approach.

Problem: Perform the following integration: $$\int \dfrac{ 1 } { \sin x - \cos x - 1} dx$$

Let $$I$$ be the integral we are trying to evaluate. My first approach is to try to simplify the denominator by using the idenity $$\sin^2 x + \cos^2 x = 1$$. \begin{align*} I &= \int \dfrac{1 } { \sin x - (\cos x + 1)}dx \\ I &= \int \dfrac{ ( \sin x + (\cos x + 1)) } { ( \sin x + (\cos x + 1))( \sin x - (\cos x + 1))}dx \\ % I &= \int \dfrac{ ( \sin x + (\cos x + 1)) } {\sin^2x - \sin x(\cos x + 1) + \sin x (\cos x + 1) - (\cos^2 x + 1)^2} dx\\ % I &= \int \dfrac{ ( \sin x + \cos x + 1) } {\sin^2x - \cos^2x - 2\cos x - 1} dx\\ \end{align*} At this point, I do not see how to make progress. I was hoping for a $$\sin^2x + \cos^2x$$ in the denominator.

My second approach. \begin{align*} I &= \int \dfrac{ (\cos x) \,\, dx } { \sin x \cos x - \cos^2x - \cos x } \\ I &= \int \dfrac{ (\cos x) \,\, dx } { \sin x \cos x - \cos^2x - (1 - \sin^2 x) - \sqrt{1-\sin^2 x} } \\ \end{align*} Now I can apply the subsutution $$u = \sin x$$ and get rid of the trig functions. \begin{align*} I &= \int \dfrac{ du } { u^{\frac{3}{2}} - (1-u^2) - u^{ \frac{1}{2}} } \\ I &= \int \dfrac{ du } { u^2 + u^{\frac{3}{2}} - u^{ \frac{1}{2}} - 1 } \end{align*} Again, I do not see how to make progress.

My third approach is to dividend numerator and denominator by $$\cos^2 x$$ hoping to setup a substitution like $$u = \tan x$$. \begin{align*} I &= \int \dfrac{ (\sec^2 x) \,\, dx } { \dfrac{ \tan x}{\cos x} - \sec x - \sec^2 x } \\ \end{align*} What is the right way to solve this problem?

Note: I was planning on adding the homework tag to this post (despite the fact I am not in school) because I am not looking for the answer. I am looking for guidance to get there. When I attempted to use that tag, I got a message saying please do not use it. So I did not.

• Looks like Weierstrass substitution would work
– Zima
Commented May 20, 2023 at 21:32
• You may be interested in en.wikipedia.org/wiki/Bioche%27s_rules Commented May 20, 2023 at 21:36

Another approach

$$I=\int \dfrac{ 1 } { \sin x - \cos x - 1}dx = \int \dfrac{ \sin x - \cos x + 1 } { (\sin x - \cos x)^2 - 1} dx=\int \dfrac{ \sin x - \cos x + 1 } { -2\sin x \cos x} dx$$

we get

$$I=-\frac{1}2\int \sec x~ dx+\frac{1}2\int \csc x~ dx-\int \csc (2x)~ dx$$

So we convert it into the sum of three basic integrals. Can you proceed from here?

• Very clever technique +1. Commented May 20, 2023 at 22:00
• thank you.. :-) Commented May 20, 2023 at 22:01
• @MathFail I can take it from there.
– Bob
Commented May 20, 2023 at 22:54
• great, glad it helps @Bob Commented May 21, 2023 at 2:00

Using the famous Weierstrass substitution, let $$t=\tan\left(\frac{x}{2}\right)$$, the we have: $$\sin x=\frac{2t}{1+t^2} \hspace{1cm} \cos x=\frac{1-t^2}{1+t^2} \hspace{1cm} \text{d}x=\frac{2}{1+t^2}\text{d}t$$ now the integral reduces to $$\int\frac{\frac{2}{1+t^2}} {\frac{2t}{1+t^2}-\frac{1-t^2}{1+t^2}-1}dt=$$ $$=\int\frac{1}{t-1}dt$$ and this can is just $$\log |t - 1| + C$$

• I do not understand how you find $\sin x$ in terms of $t$ I do not understand how you find $\cos x$ in terms of $t$. Could you provide some more detail in your answer?
– Bob
Commented May 20, 2023 at 21:46
• I see more detail on the web. You do not have to bother.
– Bob
Commented May 20, 2023 at 21:48
• Your experssion for $dx$ is wrong. Please edit your answer. Commented May 20, 2023 at 21:48
• @TravisWillse fixed, thank you
– Zima
Commented May 20, 2023 at 21:55
• The tangent half-angle substitution was used by Euler in 1768 while Weierstrass was born in 1815 !! Commented May 21, 2023 at 1:50

Here is a compact solution via the substitution $$t=x-\frac\pi4$$ \begin{align} & \int \frac{ 1 } { \sin x - \cos x - 1} dx\\ =& \int \frac{ 1 } { \sqrt2 \sin t - 1} dt = \int \frac{ \sec^2 t \ (\sqrt2 \sin t - 1)} { \sec^2 t\ (\sqrt2 \sin t - 1)^2} dt\\ =& \int \frac{d (\sqrt2 \sec t - \tan t)} { (\sqrt2 \sec t - \tan t)^2-1}=-\coth^{-1}(\sqrt2 \sec t - \tan t)+C \end{align}

• Wonderful and elegant solution!
– Lai
Commented May 22, 2023 at 11:20

Expanding on your second approach, substitute $$v=\sqrt u$$ :

\begin{align*} &\int \dfrac{ du } { u^2 + u^{\frac{3}{2}} - u^{ \frac{1}{2}} - 1 } \\ &= \int \frac{2v\,dv}{v^4 + v^3 - v - 1} \\ &= \int \frac{2v\,dv}{(v-1)(v+1)(v^2+v+1)} \\ &= \frac13 \int \left(\frac3{v+1} + \frac1{v-1}-\frac{2(2v+1)}{v^2+v+1}\right) \, dv \end{align*}

Alternatively, substitute $$u=\tan x$$ :

\begin{align*} & \int \frac{dx}{\sin x - \cos x - 1} \\ &= \int \frac{\sec^2x\,dx}{\sec x(\tan x - 1 - \sec x)} \\ &= \int \frac{du}{\sqrt{u^2+1}(u - 1 - \sqrt{u^2+1})} \\ &= \frac12 \int \left(\frac1{u\sqrt{1+u^2}} - \frac1{\sqrt{1+u^2}} - \frac1u\right) \, du \\ &= -\frac12 \tanh^{-1}\left(\sqrt{1+u^2}\right) - \frac12 \sinh^{-1}u - \frac12\ln|u| + C \\ &= -\frac12 \tanh^{-1}\left|\sec x\right| - \frac12 \sinh^{-1}(\tan x) - \frac12\ln\left|\tan x\right| + C \end{align*}

\begin{align} \int_{ }^{ }\frac{1}{\sin\left(x\right)-\cos\left(x\right)-1}dx &= \int_{ }^{ }\frac{\sin\left(x\right)}{\sin^{2}\left(x\right)-\sin\left(x\right)\cos\left(x\right)-\sin\left(x\right)}dx \\ &= \int_{ }^{ }\frac{\sin\left(x\right)}{\left(1+\cos\left(x\right)\right)\left(1-\cos\left(x\right)-\sin\left(x\right)\right)}dx \\ &= \int_{ }^{ }\frac{\left(\frac{2}{1+\cos\left(x\right)}\right)\sin\left(x\right)}{2\left(1-\cos\left(x\right)-\sin\left(x\right)\right)}dx \\ &= \int_{ }^{ }\frac{\sec^{2}\left(\frac{x}{2}\right)\sin\left(x\right)}{2-2\cos\left(x\right)-2\sin\left(x\right)}dx \\ &= \int_{ }^{ }\frac{\sec^{2}\left(\frac{x}{2}\right)}{2\left(\frac{1-\cos\left(x\right)}{\sin\left(x\right)}-1\right)}dx \\ &= \int_{ }^{ }\frac{\sec^{2}\left(\frac{x}{2}\right)}{2\left(\tan\left(\frac{x}{2}\right)-1\right)}dx \\ &= \int_{ }^{ }\frac{1}{\tan\left(\frac{x}{2}\right)-1}d\left(\tan\left(\frac{x}{2}\right)-1\right) \\ &= \ln\left|\tan\left(\frac{x}{2}\right)-1\right|+C \end{align}

\begin{aligned} I & =\int \frac{1}{\sin x-(\cos x+1)} d x \\ & =\int \frac{1}{2 \sin \frac{x}{2} \cos \frac{x}{2}-2 \cos ^2 \frac{x}{2}} d x \\ & =\int \frac{\sec ^2 t}{\tan t-1} d t, \quad \textrm{ where }t=\frac x2 \\ & =\ln |\tan t-1|+C\\ & =\ln \left|\tan \frac{x}{2}-1\right|+C \end{aligned}