I have a problem where I need to find a point on a curve that is defined by two implicit surfaces. This point must be at the shortest distance from a reference point that is located somewhere in space.
These two surfaces are a cone-like and a sphere-like. The actual equations are quite complex therefore I will not present them here. However, it is important to mention that unlike in the example I provide below, the intersection curve of these surfaces does not fall in to one plane.
implicit formulation for a sphere: $x^2+y^2+z^2=1$
implicit formulation for a cone: $\frac{x^2+y^2}{0.5}=(z+1)^2$
Explanation how to derive an implicit equation of an intersection of any two 3d surfaces would help a lot as well.
EDIT: line -> curve
EDIT: Adding actual case:
The two surfaces are:
Ellipsoid -> $f_2(x,y,z)=\sqrt{\frac{Ex^2}{D}+Fxy+\frac{Dy^2}{E}+Gz^2}-\sqrt{DE}$
Stretched cone -> $f_1(x,y,z)=\frac{(x+y)-(A+B)}{2}+\sqrt{\left(\frac{(x-y)-(A-B)}{2}\right)^2+Cz^2}$
Where $A, B, C, D, E, F, G$ are the shape parameters. Let's assume that these parameters are:
$A=1$, $B=1$, $C=1$, $D=8$, $E=6$, $F=-1$, $G=1$
However they are not limited to those values, it could pretty much be anything (with some restrictions).
It results in two surfaces looking like this:
Note that the z=0 is a plane of symmetry


The standard method for such problems is to introduce Lagrange multipliers. Assume that the reference point is the origin, and that the two surfaces are given in the form $S_1:\ g_1(x,y,z)=0$ and $S_2:\ g_2(x,y,z)=0$. Then set up the auxiliary function $$\Phi(x,y,z,\lambda,\mu):=x^2+y^2+z^2-\lambda g_1(x,y,z)-\mu g_2(x,y,z)\ ,$$ and solve the system $$\Phi_x=0,\quad\Phi_y=0,\quad\Phi_z=0,\quad g_1=0,\quad g_2=0$$ for $x$, $y$, $z$ (the values of $\lambda$ and $\mu$ are not needed).
This brings all conditionally stationary points of the objective function $f(x,y,z):=x^2+y^2+z^2$ on the curve $\gamma:=S_1\cap S_2$ to the fore. When applying this method you should have the global situation under control, because there are instances when the method "fails", e.g. if $S_2$ passes through the tip of the cone $S_1$, or if $S_1$ and $S_2$ are tangent to each other at the point of minimum.
For the computations it helps if you present $S_1$ and $S_2$ avoiding square roots. It seems that both are quadrics not only in the toy example, but in your concrete case as well.