# Equation of the sphere that passes through 4 points

Write he equation of the sphere that passes through points $$a(-5,4,1),b(3,4,-5),c(0,0,4),d(0,0,0)$$ I tried to use four points to draw a geometric shape and then calculate the center of this shape on the basis of the circle that passing on four points. But I did not succeed

Here is the book answer $$x^2+y^2+z^2+54x−58y+4z=0$$

• I don't advise you to see the site : (2000clicks.com/mathhelp/…) that has one of the silliest use of Computer Algebra I have ever seen... Commented Dec 30, 2017 at 12:41
• You say that you have considered the tetrahedron (="the shape") formed by the 4 points. But the center (of gravity) of this "shape" isn't in general the center of the sphere : think for example to the limit case when 3 of the 4 points are grouped (or very nearby if you prefer) and the 4th one is at the opposite on the sphere ; the center of the sphere is visibly not the center of gravity of the points. Commented Dec 30, 2017 at 12:50
• thanks :D but 2000clicks example hhhhh more complex Commented Dec 30, 2017 at 12:52

$$\left | \begin{matrix} x^2 + y^2 + z^2 & x & y & z & 1 \\ x_1^2 + y_1^2 + z_1^2 & x_1 & y_1 & z_1 & 1 \\ x^2_2 + y_2^2 + z_2^2 & x_2 & y_2 & z_2 & 1 \\ x_3^2 + y_3^2 + z_3^2 & x_3 & y_3 & z_3 & 1 \\ x_4^2 + y_4^2 + z_4^2 & x_4 & y_4 & z_4 & 1 \end{matrix} \right | = 0$$

i.e. $-128(x^2+y^2+z^2-4x-\frac{29}{2}y-4z)=0$

• what do yo did :( Commented Dec 30, 2017 at 12:44
• @dannydavito I computed the determinant in maple, using $x_1=-5, y_1=4,z_1=1,$ and so on. Commented Dec 30, 2017 at 12:46
• i admit i'm donkey thank you Commented Dec 30, 2017 at 12:55

The technique here is straightforward.

First take the general equation of a sphere:

$$(x-a)^2+(y-b)^2+(z-c)^2=r^2$$

If this passes through the points $(x_1, y_1, z_1)$ and $(x_2, y_2, z_2)$ then you have two equations:

$$(x_1-a)^2+(y_1-b)^2+(z_1-c)^2=r^2$$$$(x_2-a)^2+(y_2-b)^2+(z_2-c)^2=r^2$$

Now subtract the second from the first $$x_1^2-x_2^2+2a(x_2-x_1)+y_1^2-y_2^2+2b(y_2-y_1)+z_1^2-z_2^2+2c(z_2-z_1)=0$$

You now have a linear equation in three unknowns, $a, b, c$ - the inconvenient square terms all cancel. You have enough data to obtain three independent equations, which you should be able to solve. Here you can do somewhat better by choosing the point $(0,0,0)$ as the second point in each case, which gives $$2ax_1+2by_1+2cz_1=x_1^2+y_1^2+z_1^2$$ and gives you some simpler arithmetic.

• If this passes through four point i will write four equation in three unknowns? Commented Dec 30, 2017 at 12:59
• @dannydavito To get three equations take the difference of the other three with the one for $(0,0,0)$. The other equations you can get are linearly dependent on these ones because $(a-b)+(b-c)=a-c$. You get $r$ at the end once you have determined $a, b, c$ by evaluating at a single point. The system of equations here is equivalent to those proposed by others. I wanted to pint out a method which seems to me computationally simpler if you are having to do this by hand. Commented Dec 30, 2017 at 13:17

Using the equation for points on spheres:

$\qquad(x-a)^2+(y-b)^2+(z-c)^2=r^2$

Using coordinates of the four points provided, we have four simultaneous equations to solve for $a, b, c, d$. \begin{cases} (-5-a)^2+(4-b)^2+(1-c)^2=r^2 \\ (3-a)^2+(4-b)^2+(-5-c)^2=r^2 \\ (0-a)^2+(0-b)^2+(4-c)^2=r^2 \\ (0-a)^2+(0-b)^2+(0-c)^2=r^2 \end{cases} (Substracting third and fourth equation yield $c$, and the first two yield $a$ then $b$, then you have $r$, easy to solve on paper)

and get a nonnegative solution: \begin{cases} a=2 \\ b=\frac{29}{4} \\ c=2 \\ r=\frac{\sqrt{969}}{4} \end{cases} (just solved it, maybe you can check the answers :D )

• :( here the answer but i don't understand $$x^2+y^2+z^2+54x-58y+4z=0$$ Commented Dec 30, 2017 at 12:49
• I see what you mean now... you can put my a,b,c,r back into the first equation and simplify to get this answer. Commented Dec 30, 2017 at 12:52
• And your provided answer doesn't seems right... if you try (0,0,4) the equality doesn't hold... Commented Dec 30, 2017 at 12:56
• this the book answer :( Commented Dec 30, 2017 at 12:58
• Then, could you recheck that if the four points you provided are the same as things on the book? Thanks! This is getting strange. :/ Commented Dec 30, 2017 at 12:59

The equation of the sphere with a centre in $(x_0,y_0,z_0)$ and radius $r$ is: $(x-x_0)^2+(y-y^0)^2+(z-z_0)^2=r^2$. For us, the unknowns are $x_0,y_0,z_0,r$.

Plug the given four points in:

\begin {align}(-5-x_0)^2+(4-y_0)^2+(1-z_0)^2=r^2 \\ (3-x_0)^2+(4-y_0)^2+(-5-z_0)^2=r^2 \\ (-x_0)^2+(-y_0)^2+(4-z_0)^2=r^2 \\ (-x_0)^2+(-y_0)^2+(-z_0)^2=r^2\end {align}

or (after a bit of transforming):

\begin {align}42+10x_0-8y_0-2z_0+x_0^2+y_0^2+z_0^2=r^2 \\ 50-6x_0-8y_0+10z_0+x_0^2+y_0^2+z_0^2=r^2 \\ 16-8z_0+x_0^2+y_0^2+z_0^2=r^2 \\ x_0^2+y_0^2+z_0^2=r^2\end {align}

Now, take away one of the equations from the rest (in this case, the last one is the easiest one):

\begin {align}42+10x_0-8y_0-2z_0=0 \\ 50-6x_0-8y_0+10z_0=0\\ 16-8z_0=0\\ x_0^2+y_0^2+z_0^2=r^2\end {align}

Solve the system of the first three (linear) equations, to obtain: $x_0=2, y_0=\frac {29}{4}, z_0=2$. Plug that into the fourth to obtain $r=\sqrt {2^2+\left (\frac {29}{4}\right)^2+2^2}=\frac {\sqrt {969}}{4}$.

Thus, the final equation is:

$$(x-2)^2+(y-\frac {29}{4})^2+(z-2)^2=\frac {969}{16}$$

or, after transforming:

$$x^2+y^2+z^2-4x-\frac {29}{2}y-4z=0$$

as all constant terms will happen to cancel each other.

the equation of a sphere is given by $$(x-x_M)^2+(y-y_M)^2+(z-z_M)^2=R^2$$ inserting the given coordinates you will get $$(-5-x_M)^2+(4-y_M)^2+(1-z_M)^2=R^2$$ (I) $$(3-x_M)^2+(4-y_M)^2+(-5-z_M)^2=R^2$$ (II) $$x_M^2+y_M^2+(4-z_M)^2=R^2$$ (III) $$x_M^2+y_M^2+z_M^2=R^2$$ (IV) solve this System for $x_M,y_M,z_M$ and $R$ and now subtract (I)-(II) for example

• what's M M M M ?? mean Commented Dec 30, 2017 at 12:45
• the midpoint of the sphere Commented Dec 30, 2017 at 12:55
• aha .. okay .. so what the easiest way to solve this system Commented Dec 30, 2017 at 13:07

Here is a general and closed solution. Call the four non-coplanar points $$A$$, $$B$$, $$C$$ and $$D$$. The center of the sphere is where the planes between $$B$$ and $$A$$, $$C$$ and $$A$$, and $$D$$ and $$A$$ intersect. For instance, the plane between $$B$$ and $$A$$ has the normal $$B-A$$, and goes through $$(A+B)/2$$, i.e. has the equation $$(B-A)\cdot I=(B-A)\cdot(B+A)/2\;.$$ It helps a bit to work in coordinates in which the origin is at $$A$$, so that $$B'=B-A$$, $$C'=C-A$$ and $$D'=D-A$$. In those coordinates, $$A'=0$$ and thus the plane equations are of the form $$B'\cdot I=|B'|^2/2\;,$$ and likewise for $$C'$$ and $$D'$$. We can either write this as a matrix equation, $$N\,I:=(B',C',D')^T\,I=\frac{1}{2}(|B'|^2,|C'|^2,|D'|^2)^T\;,$$ or just solve this a bit more "geometrically", the results are of course the same. What is meant by "geometrical" solution is that, since the points are not coplanar, we can make the ansatz $$I=\beta\,C'\times D'+\gamma\,D'\times B'+\delta\,B'\times C' \;.$$ Obviously, $$C'\cdot (C'\times D')=0$$ and so on, and the only nonvanishing combinations are $$B'\cdot(C'\times D')$$ and cyclic permutations thereof, which all equal to $$\det N$$. (If and only if the points were all on a common plane, $$\det N=0$$, and there was no unique sphere.) This determines $$\beta\,\det N=|B'|^2/2$$ etc. So in the shifted coordinate system the center of the sphere is at $$I'=\frac{1}{2B'\cdot(C'\times D')}\left(|B'|^2\,C'\times D' + |C'|^2\,D'\times B'+ |D'|^2\,B'\times C'\right)\;.$$ In the original, unshifted coordinates $$I=A+I'\;.$$ Given the center, the computation of the radius is trivial, $$r=\sqrt{|I'|^2}$$.