How do I calculate, for an ellipsoid of the form How do I, numerically, inscribe a sphere inside an ellipsoid, $$ ax^{2}+by^{2}+cz^{2}+2fyz+2gzx+2hxy+2px+2qy+2rz+d=0 $$
such that it touches the ellipsoid at a point $(x_1,y_1,z_1)$ on its surface, and has the same curvature as the point? I was considering finding out the mean radius of curvature, and then using it to find a point on the major axis $(x_2,y_2,z_2)$ where the distance between the two points is the same as the radius of curvature.
Problem is, I cannot also find a proper formula to calculate the radius of curvature. The following has one,
Harris, W. F. "Curvature of ellipsoids and other surfaces." Ophthalmic and Physiological Optics 26.5 (2006): 497-501.

But I was looking for something simpler as a method to do it over and over again. Can you guys help?
 A: You're after the Gaussian curvature of your surface at a point. This is the product of the eigenvalues of the shape operator, and may be calculated as the determinant of the second fundamental form at that point as follows:


*

*Suppose you have a parameterization $r$ of your surface near your point in terms of variables $u,v$ so that $r(u,v)$ is an element in $\Bbb R^3$.

*The second fundamental form is $\begin{pmatrix} r_{uu}\cdot n & r_{uv}\cdot n \\ r_{vu}\cdot n & r_{vv}\cdot n \end{pmatrix}$ where subscripts denote partial derivatives and $n=\frac{r_u\times r_v}{|r_u\times r_v|}$ is a unit normal vector to the surface.

*Take the determinant of this to get the Gaussian curvature.


Since a sphere of radius $r$ has Gaussian curvature $\frac{1}{r^2}$, you can now find the sphere you need to use. If you take the square root of the inverse of the Gaussian curvature at a point, you'll get the radius of the sphere you need to use. Now you can center the sphere at the point plus the appropriate multiple of the unit normal vector, and you will be done.
