<s>[INST] Express $w=f(z)=\frac{1}{(1-z)^2}$ in the form $w=u(x,y)+iv(x,y)$ I start by writing $f(z)$ as $$\frac{1}{(1-(x+iy))^2}$$
and then I expand the bottom to get $$\frac{1}{(1-2x+x^2-y^2) + i(2y-2xy)}$$
The answer says $$w=\frac{(1+x^2-2x-y^2)-(i(2xy-2y)}{(1+x^2-2x-y^2)^2+(2xy-2y)^2}$$
How do I get to this stage?
 [/INST] Here is another way: $u(z) = \operatorname{re} f(z) = {1 \over 2} (f(z)+ \overline{f(z)})$, $v(z) = \operatorname{im} f(z) = {1 \over 2i} (f(z)- \overline{f(z)})$.
In this case, we have (also using $w \bar{w} = |w|^2$.)
\begin{eqnarray}
u(z) &=& {1 \over 2} ({1 \over (1-z)^2}+{1 \over (1-\bar{z})^2}) \\
&=& {1 \over 2} {(1-\bar{z})^2 + (1-z)^2 \over |1-z|^4 }\\
&=& {1 \over 2} {2 - 2 (z + \bar{z}) + z^2 + \bar{z}^2 \over |1-z|^4 } \\
&=& {1 \over 2} {2 - 2 \cdot 2 \operatorname{re}(z) + 2 \operatorname{re}(z^2)  \over |1-z|^4 } \\
&=& { 1 - 2x +x^2-y^2\over ((1-x)^2+y^2)^2}
\end{eqnarray}
Similarly:
\begin{eqnarray}
v(z) &=& {1 \over 2i} ({1 \over (1-z)^2}-{1 \over (1-\bar{z})^2}) \\
&=& {1 \over 2i} {(1-\bar{z})^2 - (1-z)^2 \over |1-z|^4 }\\
&=& {1 \over 2i} {2 (z - \bar{z}) + \bar{z}^2 - z^2  \over |1-z|^4 } \\
&=& {1 \over 2i} {2 \cdot 2i \operatorname{im}(z) - 2 i \operatorname{im}(z^2)  \over |1-z|^4 } \\
&=& { 2y - 2xy\over ((1-x)^2+y^2)^2}
\end{eqnarray}
</s>