Looks to me like you have a bunch of 3-D points and you want to fit a sphere to them.
The equation of a sphere is
$r^2 = (x-a)^2 + (y-b)^2 + (z-c)^2$. This seems to be nonlinear in its parameters (r, a, b, c).
However if we write it as
$$r^2 = (x-a)^2 + (y-b)^2 + (z-c)^2 = x^2+y^2+z^2+2\ a\ x+2\ b\ y+2\ c\ z + a^2+b^2+c^2,$$
and let $v = a^2+b^2+c^2-r^2$, the equation becomes
$$0 = x^2+y^2+z^2+2\ a\ x+2\ b\ y+2\ c\ z +v$$
which is linear in its parameters (a, b, c, v).
Put this into a linear least squares solver, and then get $r$ from $a, b, c,$ and $v$.
This works for any number of dimensions. I used it about 25 years ago to fit circles to data points, and it worked quite well.
I know that this does not do a least squares fit of the sphere to points (which is nonlinear), but it works well and can generate good starting parameters for an exact nonlinear fitting process.
A suggestion I have found useful in practice: If you have many points and they are far from the origin, shift the origin so it is at the center of the points. Otherwise the computation of $r$ from $a$, $b$, $c$, and $v$ can be inaccurate.