# Sphere Equation Given 4 Points - Calculator

## Equation of a Sphere Given 4 Points

An equation of a sphere calculator, given four points on the sphere, is presented.

The equation of a sphere whose center is at the point $$(h,k,l)$$ and has radius $$r$$ is given by $(x-h)^2 + (y - k)^2 + (z - l)^2 = r^2$ Expanding the above equation and grouping terms, we obtain $x^2 + y^2 + z^2 - 2xh - 2 y k - 2 z l + h^2 + k^2 + l^2 = r^2$ or $x^2 + y^2 + z^2 = 2 x h + 2 y k + 2 z l + r^2 - ( h^2 + k^2 + l^2)$ Let , $$A = 2 h$$ , $$B = 2 k$$ , $$C = 2 l$$ and $$D = r^2 - (h^2 + k^2 + l^2)$$ and rewrite the above as follows $A x + B y + C z + D = x^2 + y^2 + z^2$ For the 4 points with coordinates $$(x_1 , y_1 , z_1 )$$, $$(x_2 , y_2 , z_2 )$$, $$(x_3 , y_3 , z_3 )$$ and $$(x_4 , y_4 , z_4 )$$ to be on the same sphere, the following system of four equations with the unknowns $$A, B , C$$ and $$D$$ must have a solution:
\begin{align*} A x_1 + B y_1 + C z_1 + D & = x_1^2 + y_1^2 + z_1^2 \\ A x_2 + B y_2 + C z_2 + D & = x_2^2 + y_2^2 + z_2^2 \\ A x_3 + B y_3 + C z_3 + D & = x_3^2 + y_3^2 + z_3^2 \\ A x_4 + B y_4 + C z_4 + D & = x_4^2 + y_4^2 + z_4^2 \end{align*} Using Cramer's rule, we solve for $$A, B , C$$ and $$D$$ as follows: $M = \begin{vmatrix} &x_1&&y_1&&z_1&&1&\\ \\ &x_2&&y_2&&z_2&&1&\\ \\ &x_3&&y_3&&z_3&&1&\\ \\ &x_4&&y_4&&z_4&&1&\\ \end{vmatrix}$ and $A = \dfrac{\begin{vmatrix} &x_1^2 + y_1^2 + z_1^2&&y_1&&z_1&&1&\\ \\ &x_2^2 + y_2^2 + z_2^2 &&y_2&&z_2&&1&\\ \\ &x_3^2 + y_3^2 + z_3^2&&y_3&&z_3&&1&\\ \\ &x_4^2 + y_4^2 + z_4^2&&y_4&&z_4&&1&\\ \end{vmatrix}}{M}$
$B = \dfrac{\begin{vmatrix} &x_1&&x_1^2 + y_1^2 + z_1^2&&z_1&&1&\\ \\ &x_2&&x_2^2 + y_2^2 + z_2^2&&z_2&&1&\\ \\ &x_3&&x_3^2 + y_3^2 + z_3^2&&z_3&&1&\\ \\ &x_4&&x_4^2 + y_4^2 + z_4^2&&z_4&&1&\\ \end{vmatrix}}{M}$
$C = \dfrac{\begin{vmatrix} &x_1&&y_1&&x_1^2 + y_1^2 + z_1^2 &&1&\\ \\ &x_2&&y_2&&x_2^2 + y_2^2 + z_2^2&&1&\\ \\ &x_3&&y_3&&x_3^2 + y_3^2 + z_3^2&&1&\\ \\ &x_4&&y_4&&x_4^2 + y_4^2 + z_4^2&&1&\\ \end{vmatrix}}{M}$
$D = \dfrac{\begin{vmatrix} &x_1&&y_1&&z_1&&x_1^2 + y_1^2 + z_1^2&\\ \\ &x_2&&y_2&&z_2&&x_2^2 + y_2^2 + z_2^2&\\ \\ &x_3&&y_3&&z_3&&x_3^2 + y_3^2 + z_3^2&\\ \\ &x_4&&y_4&&z_4&&x_4^2 + y_4^2 + z_4^2&\\ \end{vmatrix}}{M}$

## Use of Calculator

Enter the coordinates of four 3D points:

Cramer's rule