Say you have three (distinct) points on the unit sphere in Euclidean space
$$p_1, p_2, p_3 \in S^n = \{ x \in \mathbb R^{n+1} : |x| = 1 \}$$
I'd like to find, as efficiently and robustly as possible, a description of the unique round circle in $S^n$ that contains the three points. By round circle I mean the intersection of an affine $2$-dimensional subspace of $\mathbb R^{n+1}$ with $S^n$.
I'm mostly interested in the $n=3$ case, although the $n>3$ cases are of some interest to me as well.
Off the top of my head the most sensible way to accomplish this would be:
Find the smallest-norm convex-combination of the $p_i$'s, i.e. solve $$\min \left\|\sum_i \alpha_i p_i\right\|, \hskip 1cm \sum_i \alpha_i = 1$$ which is a calculus problem.
Replace the $p_i$'s by $p_i - q$ where $q$ is the above norm-minimizer.
Compute the orthogonal complement of $span(p_1, p_2, p_3)$.
If $q_1, q_2, \cdots, q_{n-2}$ is a basis for the orthogonal complement then that would give a system of equations describing the circle.
$$q_i \cdot (x-p_j) = 0$$
for all $i,j$ (these equations would technically be independent of j).
The nice thing about this setup is it's just linear algebra. One problem with this solution is step (2) -- if the norm-minimizer results in a very small but non-zero norm there might be numerical instabilities. In the application I have in mind, there will be (potentially) billions of such computations and these kinds of instabilities will be difficult to avoid.
The $n=2$ case has a rather cute, stable and efficient solution which (off the top of my head) I don't see how to generalize
$$Det \pmatrix{ x & y & z & 1 \cr \cdot & \cdot & \cdot & 1 \cr \cdot & \cdot & \cdot & 1 \cr \cdot & \cdot & \cdot & 1} = 0$$
where you plug the three points $p_1, p_2, p_3$ into the dotted rows.
If there was a more general solution of this kind, that would be wonderful as it solves the stability issue. On top of that, it's a simple closed-form solution and my application could use a solution that is easily differentiated. I don't need that, but it would be useful.
edit: I need an answer that gives the "universal bundle" description of the circle, i.e. an equation of the plane the circle lives in. You could think of this as a point in the Grassmannian $G_{n+1,2}$ together with a vector in the orthogonal complement of the 2-dimensional subspace. This is because I need ready access to the Hausdorff distance function (minimum distance) from points in the sphere to the circle. i.e. a parametrization of the circle is not enough.
edit 2: in my comment below I refer to the matrix formulation of the Grassmannian. In this formulation, the space of 2-dimensional subspaces of $\mathbb R^n$ is the space of $n\times n$ matrices $A$ such that: $A^t = A, A^2=A, \text{ and } tr(A) = 2$. From this perspective the matrix $A$ represents the orthogonal projection map onto its image, which is a $2$-dimensional subspace.