(Edited + Example) Derive the formula for finding the center of the sphere and radius, if the coordinates of arbitrary the point are known The general sphere formula is
R^2 = (x -a)^2 + (y - b)^2 + (z - c)^2
[Above formula][1]
It can be transform into:
R = $ \sqrt{(x-a)^2 + (y - b)^2 + (z - c)^2} $
[Formula 2][2]
Please, can you help me derive a general formula for finding coordinates of a, b, c and radius R of the sphere through the known coordinates x, y and z?
(P.s: Can you, please, show me how to derive this equation by using partial differential equation and how to derive this equation without partial differential equation?)
 A: If I am not mistaken, according to the image, you have $n$ data points $(x_i,y_i,z_i)$ supposed to be on a sphere and you look for the coordinates $(a,b,c)$ of its center as well as it radius $R$.
This is a typical problem which would require optimization and this implies that you need estimates for the unknown variables $(a,b,c,R)$. This can be done quite easily in a preliminary step considering $n$ equations
$$f_i=(x_i-a)^2+(y_i-b)^2+(z_i-c)^2 -R^2 =0$$
Build the $\frac {n(n-1)}2$ equations $f_j-f_i$ ($i$ varying from $1$ to $(n-1)$ and $j$ varying from $(i+1)$ to $n$) to get
$$2(x_i-x_j)a+2(y_i-y_j)b+2(z_i-z_j)c=(x_i^2+y_i^2+z_i^2)-(x_j^2+y_j^2+z_j^2)$$ So, a multilinear regression gives parameters $(a,b,c)$.
When this is done, you can estimates $R^2$ using
$$R^2=\frac 1n \sum_{i=1}^n \Big[(x_i-a)^2+(y_i-b)^2+(z_i-c)^2\Big]$$
Havig these estimates, you can polish the solution minimizing with respect to $(a,b,c,R)$ either
$$\Phi=\sum_{i=1}^n \Big[(x_i-a)^2+(y_i-b)^2+(z_i-c)^2-R^2\Big]^2$$ or
$$\Psi=\sum_{i=1}^n \Big[\sqrt{(x_i-a)^2+(y_i-b)^2+(z_i-c)^2}-R\Big]^2$$ and this can easily be done using Newton-Raphson method (if you are lazy, just use numerical derivatives after having written explicitely
$$\frac {\partial \Phi}{\partial a}=\frac {\partial \Phi}{\partial b}=\frac {\partial \Phi}{\partial c}=\frac {\partial \Phi}{\partial R}=0$$ which is simple.
I used this method with your data points : it works like a charm.
