Q:

Solving $\int\frac{\csc^2(x)dx}{\sqrt{K-\cot^2(x)}}$ where $K$ is a constant

I'm solving a minimization problem, reeding some notes of my teacher, and as some point she wrote 

Then we have $$\tag{1}\int d\varphi = \int \frac{\csc^2(x)dx}{\sqrt{K-\cot^2(x)}}$$ from that we get $$\tag{2}\cot(x) = K\sin(C-\varphi)$$.

And I'm trying to get the relation $(2)$ from $(1)$.

These are my attempts if is of some help: If we make the substitution $\sin(\alpha) = -\cot(x)$ we get that
$$\int \frac{\csc^2(x)dx}{\sqrt{K-\cot^2(x)}} = \int\frac{\cos(\alpha)d\alpha}{\sqrt{K-\sin^2(\alpha)}} = \frac{1}{K}\int\frac{\cos(\beta)d\beta}{\sqrt{1-\sin^2(\beta)}} 
$$
and then I get something that it is very different from $(2)$

A:

Well, we have:
$$\mathscr{I}_{\space\text{n}}:=\int\frac{\csc^2\left(x\right)}{\sqrt{\text{n}-\cot^2\left(x\right)}}\space\text{d}x\tag1$$
Substitute:
$$\text{u}:=\frac{\cot\left(x\right)}{\sqrt{\text{n}}}\tag2$$
So, we get:
$$\mathscr{I}_{\space\text{n}}=-\int\frac{1}{\sqrt{1-\text{u}^2}}\space\text{d}\text{u}=\text{C}-\arcsin\left(\text{u}\right)=\text{C}-\arcsin\left(\frac{\cot\left(x\right)}{\sqrt{\text{n}}}\right)\tag3$$

