<s>[INST] Noob question about $\int \frac{1}{\sin(x)}dx$ I manually integrate $\int \frac{1}{\sin(x)}dx$ as $$\int \frac{\sin(x)}{\sin^{2}(x)}dx = -\int \frac{1}{\sin^{2}(x)}d\cos(x) = \int \frac{1}{\cos^{2}(x) - 1}d\cos(x).$$ 
After replacing $u = \cos(x)$, 
$$\int \frac{1}{u^{2} - 1}du = \int \frac{1}{u^{2} - 1}du = \frac {1} {2} \int \left(\frac {1} {u - 1} - \frac {1} {u+1}\right) du = \frac {1} {2} \ln\left(\frac {u-1} {u+1}\right) + C.$$ 
Substitute back to obtain
$$\frac {1} {2} \ln\left(\frac {\cos(x)-1}{\cos(x)+1}\right) + C.$$
The problem is that this solution is incorrect (I guess) because for example http://www.integral-calculator.com/ gives another solution 
$$\frac {1} {2} \ln\left(\frac {1 - \cos(x)}{1 + \cos(x)}\right) + C.$$
And all other online solvers gives equivalent solution to 
$$\frac {1} {2} \ln\left(\frac {1 - \cos(x)}{1 + \cos(x)}\right) + C.$$
The question is there I made a mistake?
Update: some of you may say that in complex space my answer is right but not so fast:
Take wolfram solver: integrate 1/sinx
The we get: $-ln(cot(x) + csc(x)) + C$ It is easy to see that it is equvalent to $$\frac {1} {2} \ln\left(\frac {1 - \cos(x)}{1 + \cos(x)}\right) + C.$$
$-\ln(\cot(x) + \csc(x)) + C = -\ln(\frac {\cos(x)} {\sin(x)} + \frac {1} {\sin(x)})$ 
then 
$-\ln(\frac {\cos(x)} {\sin(x)} + \frac {1} {\sin(x)}) = -\frac {1}{2} \ln(\frac {(1+\cos(x))^{2}} {\sin^{2}x}) = -\frac {1}{2} \ln(\frac{1+\cos(x)+\cos(x)+\cos^{2}(x)} {1-\cos^{2}x}) = -\frac {1}{2} \ln(\frac {(1+\cos(x))(\cos(x)+\cos^{2})(x)} {1-\cos^{2}x}) = -\frac {1}{2} \ln(\frac {1+\cos(x)} {1-\cos(x)}) = \frac {1}{2} \ln(\frac {1-\cos(x)} {1+\cos(x)})$
 [/INST] The integral of $1/x$ is not $\ln(x)$, but $\ln|x|$. See What is the integral of 1/x?
Then, in your case $\frac{1}{2}\int du \left( \frac{1}{u-1} - \frac{1}{u+1} \right) = \frac{1}{2}\ln\left( \frac{|u-1|}{|u+1|} \right) + C$. When you put back $u=\cos(x)$, the expression $|u-1|$ becomes $|\cos(x)-1|=1-\cos(x)$ and $|u+1|$ becomes $|\cos(x)+1|=1+\cos(x)$. Notice, you can forget about taking the absolute value, because $1-\cos(x) \ge 0$ and $1+\cos(x)\ge 0$. Finally 
$\int dx \frac{1}{\sin(x)} = \frac{1}{2}\ln\left( \frac{1-\cos(x)}{1+\cos(x)} \right) + C$
</s>