Here is my attempt:
$$\quad \ \sin x = \frac{2 \tan(x/2)}{1 + \tan^2 (x/2)} \\ \implies \int \frac{\text{d}x}{\sin x}=\int \frac{1+\tan^2(x/2)}{2 \tan(x/2)} \ \text{d}x$$
I do the following variable change: $u = \tan (x/2)$
$$\quad \ \frac{\text{d}u}{\text{d}x} = \frac{1}{2} \left(1 + \tan^2(x/2) \right) \\ \implies \text{d}u = \frac{1}{2} \left(1 + \tan^2 (x/2) \right) \text{d}x \\ \implies \int \frac{\text{d}x}{\sin x} = \int \frac{\text{d}u}{u} = \ln u = \ln ( \tan(x/2))$$
But if I try to compute the derivation of $\ln ( \tan(x/2))$ I will not find $1/\sin x$. Where is the mistake ?
The derivative is precisely $$\frac{d}{dx}\bigg(\ln\big(\tan(\frac{x}{2})\big)\bigg)=\frac{1}{2}\cdot \frac{\sec^{2}(\frac{x}{2})}{\tan(\frac{x}{2})}=\frac{1}{2\cdot\sin(\frac{x}{2})\cos(\frac{x}{2})}=\frac{1}{\sin(x)}$$