Final Answer
Step-by-step Solution
Specify the solving method
Rewrite the trigonometric expression $\frac{1}{\cos\left(x\right)-1}$ inside the integral
Apply the trigonometric identity: $-1+\cos\left(\theta \right)^2$$=-\sin\left(\theta \right)^2$
Take the constant $\frac{1}{-1}$ out of the integral
Expand the fraction $\frac{\cos\left(x\right)+1}{\sin\left(x\right)^2}$ into $2$ simpler fractions with common denominator $\sin\left(x\right)^2$
Simplify the expression inside the integral
We can solve the integral $\int\frac{\cos\left(x\right)}{\sin\left(x\right)^2}dx$ by applying integration by substitution method (also called U-Substitution). First, we must identify a section within the integral with a new variable (let's call it $u$), which when substituted makes the integral easier. We see that $\sin\left(x\right)$ it's a good candidate for substitution. Let's define a variable $u$ and assign it to the choosen part
Now, in order to rewrite $dx$ in terms of $du$, we need to find the derivative of $u$. We need to calculate $du$, we can do that by deriving the equation above
Isolate $dx$ in the previous equation
Substituting $u$ and $dx$ in the integral and simplify
The integral $-\int\frac{1}{u^2}du$ results in: $\csc\left(x\right)$
The integral $-\int\csc\left(x\right)^2dx$ results in: $\cot\left(x\right)$
Gather the results of all integrals
As the integral that we are solving is an indefinite integral, when we finish integrating we must add the constant of integration $C$