The inverse function is

\[ f(z) = \frac{ 1 }{ 1 - z^n } \]With the parametrization \( z = r e^{ i \phi } \) the function can be written

\[ \begin{align} f(z) &= \frac{ 1 }{ 1 - r \cos n\phi + i r \sin n\phi } \\ &= \frac{ 1 - r \cos n\phi }{ ( 1 - r \cos n\phi )^2 + r^2 \sin^2 n\phi } - i \frac{ r \sin n\phi }{ ( 1 - r \cos n\phi )^2 + r^2 \sin^2 n\phi } \end{align} \]so that evaluations can be done with standard JavaScript functions. More complicated functions would require a library that can handle the arithmetic of complex numbers, such as Math.

Complete code for this example: