Solution (source code)

= Solution

Use the <Riemann sphere> convention for evaluating a <Möbius transformation> at a pole and at infinity. When the three prescribed points are finite, take
$$
f(z)=\frac{(w_3-w_1)(z-w_2)}{(w_3-w_2)(z-w_1)}.
$$
Its zero is $w_2$, its pole is $w_1$, and substitution at $w_3$ gives one. The remaining three cases are
$$
\boxed{
\begin{array}{c|c}
\text{point at infinity}&f(z)\\ \hline
w_1=\infty&(z-w_2)/(w_3-w_2)\\
w_2=\infty&(w_3-w_1)/(z-w_1)\\
w_3=\infty&(z-w_2)/(z-w_1).
\end{array}}
$$
All coefficient <determinants> are nonzero because the points are distinct. There is only one such <Möbius transformation>: the composite of any two candidate maps, one inverted, fixes $\infty,0,1$; fixing infinity makes it affine, and fixing zero and one makes it the identity.

For this question use the <cross-ratio> normalization
$$
\boxed{[w_1,w_2,w_3,w_4]=f(w_4).}
$$
In the finite case this is $(w_3-w_1)(w_4-w_2)/[(w_3-w_2)(w_4-w_1)]$, with the corresponding limits if a point is infinite. It is finite and distinct from zero and one, since $w_4$ is distinct from the other three points and $f$ is a <bijection>. Ordering conventions for the <cross-ratio> differ; the definition here is fixed by the specified images, rather than by importing another ordering formula.

A <generalized circle> means either a <circle> or a <straight line> completed by infinity. Let $K$ be the unique <generalized circle> through the first three points. Its image under $f$ is the unique <generalized circle> through $\infty,0,1$, namely $\mathbb R\cup\{\infty\}$. Therefore $w_4\in K$ exactly when $f(w_4)$ is real. Conversely a real $f(w_4)$ lies on that extended real line, whose inverse image is $K$. This proves the <real cross-ratio criterion for a generalized circle> in both directions.