<s>[INST] Is there any better way of finding the required value If $$z=\cos\theta+i\sin\theta$$ find the value of $$\frac{1+z}{1-z}$$

The solution that I have is this
$$z=\cos\theta+i\sin\theta \implies$$
$$\frac{1+z}{1-z}=\frac{1+(\cos\theta+i\sin\theta)}{1-(\cos\theta+i\sin\theta)}=\frac{(1+\cos\theta)+i\sin\theta}{(1-\cos\theta)+i\sin\theta}$$
$$=\frac{2\cos^2\frac{\theta}{2}+i\:\:2\sin\frac{\theta}{2}\cos\frac{\theta}{2}}{2\cos^2\frac{\theta}{2}-i\:\:2\sin\frac{\theta}{2}\cos\frac{\theta}{2}}=\frac{\cos\frac{\theta}{2}}{\sin\frac{\theta}{2}}\cdot \frac{\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}}{\sin\frac{\theta}{2}-i\cos\frac{\theta}{2}}$$
$$=\cot\frac{\theta}{2}\cdot\frac{\color{red}{i}}{\color{red}{i}}×\frac{\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}}{\sin\frac{\theta}{2}-i\cos\frac{\theta}{2}}$$
$$=\color{red}{i}\cot\frac{\theta}{2}\cdot\frac{\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}}{\color{red}{i}\sin\frac{\theta}{2}-\color{red}{i}i\cos\frac{\theta}{2}}$$
$$=\color{red}{i}\cot\frac{\theta}{2}\cdot\frac{\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}}{\cos\frac{\theta}{2}+\color{red}{i}\sin\frac{\theta}{2}}$$
$$=\color{red}{i}\cot\frac{\theta}{2}$$
Now how on earth one will imagine the steps written in red. I am looking for an easy and a logical answer to this question. The solution that I have is impractical as you all can see. I tried it doing by $e^{i\theta}$ but no good happen.
Any help is greatly appreciated.
 [/INST] I don't think the question is really accurate in the first place, the value of $\frac{1+z}{1-z}$ can just be determined by plugging in the expression for $z$. To bring it in the final form is a matter of taste, I believe it mostly comes from the experience and knowing which result you want to get. Multiplying by $1$ and adding $0$ are among the most common tricks, but I don't think there exists any universal method.
</s>