Find a point where two surfaces touch Given two n-dimensional surfaces, $S_1$ and $S_2$, how do we find a point where these surfaces touch? 
In particular, let one of the surfaces, say $S_1$, be an ellipsoid given by an affine transformation $\mathbf{x}=R\mathbf{Lu}$ of a sphere, where  $\mathbf{L}$ is a lower triangular matrix and $\mathbf{u}$  is a unit vector, i.e. $\mathbf{u}^T\mathbf{u}=\mathbf{1}$, with elements
$$ u_1=\cos(ϕ_1) $$
$$ u_2=\sin(ϕ_1)\cos(ϕ_2) $$
$$ u_3=\sin(ϕ_1)\sin(ϕ_2)\cos(ϕ_3) $$
$$\vdots$$
$$ u_k=u_{k-1}\tan(ϕ_{k-1})\cos(ϕ_k) $$ 
$$ u_n=u_{n-1}\tan(ϕ_{n-1}) $$ 
and the angles $ϕ_{1}, ϕ_{2}, \dots, ϕ_{n-2}$ range over $[0, π]$ and $ϕ_{n−1}$ ranges over $[0, 2π]$.
My thinking is to do the following:
1) Find the expression for gradient of the second surface $\frac{dS_2}{d\mathbf{x}}$, which is an $n \times 1$ column vector
2) Substitute the expression for the ellipsoid into the gradient from (1), i.e. $\frac{dS_2}{d\mathbf{x}} |_{\mathbf{x}=R\mathbf{Lu}}$ 
3) Find the expression for the tangent plane to the ellipsoid as $R\frac{d\mathbf{Lu}}{d\mathbf{\phi}}$, which is a $(n-1)\times n$ matrix (using the denominator layout for vector derivative)
4) Set the product of the gradient from (2) and the tangent plane from (3) eual to $\mathbf{0}$, i.e. $(R\frac{d\mathbf{Lu}}{d\mathbf{\phi}})(\frac{dS_2}{d\mathbf{x}} |_{\mathbf{x}=R\mathbf{Lu}})=\mathbf{0}$, which gives a system of $n-1$ equations for $ϕ_{1}, \dots, ϕ_{n-1}$.
This approach, however, (assuming it is correct) seems to be rather laborious and I was wondering if there is a better way of doing it.
 A: For two surfaces to touch at $X=(x_1,\dots, x_n)$ you need $S_1=S_2$ and $\nabla S_1=\lambda\nabla S_2$ at $X$. This is a system of $n+1$ equations in the $n+1$ unknowns $(x_1,\dots, x_n, \lambda)$.
A: Elaborating on my comment:
Let $s_1(u,v) = (x_1,y_1,z_1)$ parametrise the surface $S_1$.
Let $s_2(u,v) = (x_2,y_2,z_2)$ parametrise the surface $S_2$. 
Solve for $u_1,u_2,u_3,u_4$ in the three simultaneous equations
$$x_1(u_1,v_1) - x_2(u_2,v_2) = 0$$
$$y_1(u_1,v_1) - y_2(u_2,v_2) = 0$$
$$z_1(u_1,v_1) - z_2(u_2,v_2) = 0$$
In general, you may have infinitely  many solutions. Each is a point of intersection. If you wish to know if these are points where the surfaces "touch", then you'll have to define what exactly you mean by that, and test for that criteria for every possible $u_1,v_1,u_2,v_2$.
Perhaps by "touch" you're referring to the kind of thing when two circles just barely kiss. If so, then you'd need to check that the subspace (i.e. plane) spanned by the derivative at the point of intersection is the same for both surfaces. i.e. if the surfaces are defined take the $\nabla f = (f_x, f_y)$ of each surface and make sure each is the same up to multiplication.
There are other techniques you can employ, i.e. Lagrangian multipliers, but this depends on the specific surfaces you're dealing with. For example, you have an ellipsoid defined by
$$g(x,y,z) = a(x-x_0)^2 + b(y-y_0)^2 + c(z-z_0)^2 = 0$$
You could could find intersections by solving for this intsead:
$$g(s_2(u,v)) = 0$$
I'm not sure if there is a one-size-fits-all approach. You could write a Euclidean distance function $d(s_1(u_1,v_1),s_2(u_2,v_2))$ and solve for when this is $0$ instead.
