Stereographic projection (source code)

= Stereographic projection
{title2=$\sigma_N(X,Y,Z)=(X+iY)/(1-Z)$}
{wiki}

Stereographic projection identifies a sphere minus one pole with the plane and supplies the standard charts of the Riemann sphere.

In the equatorial-plane convention of the <Riemann sphere>, draw the straight line through $N=(0,0,1)$ and a point $P=(X,Y,Z)\ne N$ on the <unit sphere>. Its intersection with the plane $Z=0$ has <complex coordinate>
$$
z=\sigma_N(P)=\frac{X+iY}{1-Z}.
$$
The <inverse function>, for $z=x+iy$ and $r^2=x^2+y^2$, is
$$
P(z)=\left(\frac{2x}{1+r^2},\frac{2y}{1+r^2},\frac{r^2-1}{1+r^2}\right).
$$
Here positive $x$ gives positive $X$, and positive $y$ gives positive $Y$. Thus $1$ and $i$ lie on the positive $X$ and $Y$ ends of the equator. The omitted north pole is assigned $z=\infty$.<Complex Variables with Applications, MIT 18.04, Spring 2018/Topic 2 Notes>[Complex Variables with Applications, MIT 18.04, Spring 2018; Topic 2 Notes, section 2.5.2, printed p. 7, projection formula and north pole]{ref}

\Image[/stereographic-projection-rays-and-axes.png]
{title=North-pole projection onto the equatorial plane: two real points and the positive complex-axis convention}

For original worked points, the real numbers $1/2$ and $2$ lift to points with the same $X$ coordinate but opposite $Z$ coordinates:
$$
P(1/2)=(4/5,0,-3/5),\qquad P(2)=(4/5,0,3/5).
$$
Projecting back gives $(4/5)/(1+3/5)=1/2$ and $(4/5)/(1-3/5)=2$. A point off the real axis checks the other sign:
$$
P(2+i)=(2/3,1/3,2/3),\qquad \sigma_N(2/3,1/3,2/3)=2+i.
$$
The coordinates satisfy $4/9+1/9+4/9=1$, as a point on the <unit sphere> must. Also $P(0)=S$, $P(-1)=(-1,0,0)$ and $P(i)=(0,1,0)$.

A short derivation starts with the line $N+t(P-N)=(tX,tY,1+t(Z-1))$. Setting its last coordinate to zero gives $t=1/(1-Z)$, hence the projection formula. Conversely the line from $N$ to $(x,y,0)$ is $(tx,ty,1-t)$. Substitution in the <unit sphere> equation gives
$$
t^2r^2+(1-t)^2=1,\qquad t\bigl(t(1+r^2)-2\bigr)=0.
$$
The root $t=0$ is $N$; the other root $t=2/(1+r^2)$ gives $P(z)$. These line intersections establish both the formula and its <bijection> property without guessing the inverse.

The same algebra explains how large planar distances become small spherical ones:
$$
1-Z=\frac{2}{1+|z|^2},\qquad \|P(z)-N\|=\frac{2}{\sqrt{1+|z|^2}}.
$$
Consequently $|z|\to\infty$ brings $P(z)$ to $N$ independently of direction. The last expression is twice the <chordal metric> distance $\chi(z,\infty)$. A whole unbounded exterior in the <complex plane> therefore becomes a small cap on the <unit sphere>.