First, lets note that

. This leads us with the following problem:

Lets add sin on both sides, and we get:

Now if we divide with sin on both sides we get:

Now we can remember how cot is defined, it is (cos/sin). So we have:

Now take the inverse of cot and we get:

In general we have

, the reason we have to add pi times n, is because it is a function that has multiple answers, see the picture: