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)})$
 A: Where did I make a mistake?
First, you rather have 
$$
 \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
$$then observe that
$$
\left|\frac {\cos(x)-1}{\cos(x)+1}\right|=\frac {1-\cos(x)}{1+\cos(x)}
$$ since
$$
1 - \cos(x)\ge 0,\quad 1+ \cos(x)\ge0,
$$ giving that
$$
\ln\left|\frac {\cos(x)-1}{\cos(x)+1}\right|=\ln\left(\frac {1-\cos(x)}{1+\cos(x)}\right).
$$
A: 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$
A: If you are considering antiderivatives as functions on connected domains $D$ that are open in $\mathbb{C}$ -- suitably chosen so that we don't have to worry about multivaluedness of the logarithm -- then you should still be okay. It's still true that the functions $z \mapsto \frac1{2} \ln \left(\frac{1 - \cos(z)}{1 + \cos(z)}\right)$ and $z \mapsto \frac1{2} \ln \left(\frac{\cos(z) - 1}{\cos(z) + 1}\right)$ are antiderivatives of $z \mapsto 1/\sin(z)$. Their difference is the constant $C = \ln(-1)/2$ for whatever branch of the logarithm you are considering. So you still get the same family of functions, up to a complex constant. 
