I'm programming an implementation of the Peirce quincuncial map projection. The projection involves a stereographic projection of a hemisphere of the globe onto a circle (I've got that part), then mapping points on that circle onto a square with a conformal mapping.
Wikipedia describes the relationship between a point $(p, \theta)$ on the circle and a point $(x, y)$ on the square as
$$\tan \left( \frac{p}{2} \right) e^{i \theta} = \mathrm{cn} \left( z, \frac{1}{2} \right), \text{ where } z = x + i y.$$
I don't understand the notation $\mathrm{cn} \left( z, \frac{1}{2} \right)$. Can it be written using algebraic and trigonometric functions?
That is, can you rewrite the above like this?
$\tan \left( \frac{p}{2} \right) \cos\theta = $ something in terms of $x$ and $y$
$\tan \left( \frac{p}{2} \right) \sin\theta = $ something in terms of $x$ and $y$
Thanks.
The $\mathrm{cn}$ function is a Jacobi elliptic function of $z=x+iy$; to get $z$, you require the corresponding inverse Jacobi elliptic function. By analogy with trig functions, these go by $\mathrm{arccn}$, $\mathrm{arcsn}$, etc. For your case, we have $$ z = \mathrm{arccn}\left(\tan\left(\frac{p}{2}\right)e^{i\theta},\frac{1}{2}\right) $$
The inverse Jacobi elliptic function $\mathrm{arccn}$ has an expression in terms of an elliptic integral. In general, it is given by
$$ \mathrm{arccn}\left(a,k\right) = \int_{a}^1 \frac{1}{\sqrt{(1-t^2)(k'^2+k^2t^2)}} dt, $$
where $k' = \sqrt{1-k^2}$ (see here). In your case, $k=1/2$ and so $k'=\sqrt{3}/2$, and $a=\tan\left(\frac{p}{2}\right)e^{i\theta}$. So,
$$ z = \int_{\tan\left(\frac{p}{2}\right)e^{i\theta}}^1 \frac{1}{\sqrt{(1-t^2)\left(\frac{3}{4}+\frac{1}{4}t^2\right)}} dt $$
So, for a given $p$ and $\theta$, you have to crunch that integral numerically. Or, you maybe be able to find a good elliptical integral package that does this for you, for complex arguments. The real part would be your $x$, and the imaginary part your $y$. As a final note, I'm not sure about the value $k=1/2$ from the Wikipedia article; this article seems to use the value of $k=k'=\frac{1}{\sqrt{2}}$.