Assuming that I am given a matrix (A) and a vector (b) which represents a surface, say

\begin{bmatrix}2&0&1\\0&1&0\\1&0&2\end{bmatrix} and \begin{bmatrix}4\\0\\2\end{bmatrix}

and the equation representing the surface as: $r^TAr+b^Tr=1$

If I am asked to find the closest distance between point "a" and the surface, represented by a position vector of


What am I supposed to do?

Below is what I've attempted:

Using this as an example, I tried to rewrite the equation representing the surface into quadratic form, in this case:

$x^T Ax=3$

where $r=x+a$ (note: $a$ is the point where I am trying to find it's distance from the surface).

I'm thinking about rotating the axis, however I am stuck here (my teacher told me to try not consider a rotation matrix).

  • $\begingroup$ @Peter: Look closer at the definition -- the surface is not a plane but has degree $2$. $\endgroup$ – Henning Makholm Dec 22 '16 at 18:46
  • $\begingroup$ Sorry, I did not notice that $\endgroup$ – Peter Dec 22 '16 at 18:47
  • $\begingroup$ The surface is an ellipsoid (E). Do you know how to compute the normal to any point $(x,y,z)$ ? $\endgroup$ – Jean Marie Dec 22 '16 at 18:58
  • $\begingroup$ @JeanMarie: No I don't know how to compute the normal to any point (x,y,z). $\endgroup$ – The First StyleBender Dec 22 '16 at 18:59
  • 1
    $\begingroup$ @JeanMarie: No, I have not learnt anything about Lagrange multipliers nor about maxi/minimization under constraints. This question should all be about Linear Algebra. My Physics professor suggested I should consider the rotation of axis in this question (but also explicitly mentioned that using/computing a rotational matrix is unnecessary and shouldn't be used). $\endgroup$ – The First StyleBender Dec 22 '16 at 19:13

My first idea for what to do: First, rewrite your equation $$r^TAr + b^Tr = 1 $$ into $$(r-c)^TA(r-c) = d$$ (You can find a suitable $c$ by multiplying out $(r-c)^TA(r-c)$, rewriting $r^TAc=c^TAr$ and solving $b^T = -2c^TA$. Then $d$ must be $1+c^TAc$ -- though I haven't triple-checked my reasoning for sign errors; caveat lector).

$A$ is real symmetric and therefore orthogonally diagonalizable; it is easy to see that its eigenvalues are $1,1,3$ and therefore your surface is an oblate spheroid centered on $c$.

Now the natural thing to do would be to transform $a-c$ by the orthogonal diagonalizing matrix, so you end up with $a-c$ in a coordinate system where $A=\operatorname{diag}(1,1,3)$. Then by symmetry the shortest line betwen $a$ and the spheroid would be in the plane that contains the transformed point and the $z$-axis, and we've reduced the problem to finding the shortest distance between a point and an ellipse. That seems to have no nice closed-form solution, but at least it is now easy to parameterize the ellipse and find a minimum numerically by setting the derivative of the squared distance to $0$.

However, this works because the diagonalizing matrix for $A$ can be chosen to be orthogonal -- that is, a rotation matrix -- which sounds like what your teacher is asking you not to do.

It is possible that you're supposed to use Lagrange multipliers instead.


We are fortunate that the surface is an ellipsoid and (-1,0,0) is the center.

$2x^2 + y^2 + 2z^2 + 2xz + 4x + 2z = 1\\ 4x^2 + 2y^2 + 4z^2 + 4xz + 8x + 4z = 2\\ 3(x+z+1)^2 + 2y^2 + (x-z+1)^2 = 6$

The shortest distance from (-1,0,0) to the edge of the ellipse is in the (1,0,1) direction.

$x+1 = z, y = 0$

$3(2z)^2 = 6$

the closest point on the surface is $(\frac {\sqrt 2}{2} - 1, 0, \frac {\sqrt 2}{2})$ and the distance from $(-1,0,0)$ is $1$

Suppose you want to do this using linear algebra.

$r = u + x_0 \\ u^T A u +2x_0^TA u + b^t u + x_0^tAx_0 + b^Tx_0 = 1$

$2x_0^TA u = b^t u$ since $x_0$ is the center

$u^T A u = 3\\ A = P^TDP\\ v = Pw\\ v^T\begin{bmatrix} 3\\&1\\&&1\end{bmatrix}v = 3$

  • $\begingroup$ Caution: the coefficient of $z^2$ is $2$ in the first equation. $\endgroup$ – Jean Marie Dec 22 '16 at 22:37
  • $\begingroup$ Indeed, transcription error. Thanks. $\endgroup$ – Doug M Dec 22 '16 at 22:40
  • $\begingroup$ @DougM: by the way, are you dougal main from oxford university? $\endgroup$ – The First StyleBender Dec 23 '16 at 6:13
  • $\begingroup$ @foxielmao do I look like dougal main? sorry no. $\endgroup$ – Doug M Dec 23 '16 at 20:01

Here is a solution using gradients. I am aware that the OP has said that he has not studied this concept. May this first contact wet his/her apetite for understanding this very fundamental tool, maybe with the assistance of his physics teacher that helps him/her.

Definition: the gradient at a certain point $M(x,y,z)$ of a surface $(S)$ with implicit equation $f(x,y,z)=0$ is the vector of partial derivatives

$$grad(f):=(\partial f/\partial x, \partial f/\partial y,\partial f/\partial z)$$

with respect to the different variables.

The fundamental property of $grad(f)$: it gives the orientation of the normal to surface $(S)$ at point $M(x,y,z).$

Consider now our surface (S) with equation:

$$f(x,y,z)=2x^2 + y^2 + 2z^2 + 2xz + 4x + 2z -1=0$$

Our formulation will rely on a basic property: the shortest distance of point $B(-1,0,0)$ to surface $(S)$ is realized for a point $M(x,y,z)$ of $(S)$ such that $\vec{BM} \perp (S)$. Otherwise said, such that $\vec{BM}$ is proportional to $grad(f)$. Let $\lambda$ be the proportionality ratio. We thus have a system of 4 equations in 4 unknowns $x,y,z,\lambda$, the first 3 equations express the upsaid proportionality, the last one expresses that $M(x,y,z)$ lies on surface $(S)$:

$$\begin{cases}x + 1 = \lambda*(4x + 2z + 4)\\y = \lambda * 2y\\z = \lambda*(4z + 2x + 2)\\ 2x^2 + y^2 + 2z^2 + 2x z + 4 x + 2 z=1\end{cases}$$

This system can be solved by a Computer Algebra Software (Mathematica), which gives the following set of solutions:

$$\begin{cases}x=-z-1 & y=\pm\sqrt{3-2z^2} & \text{for any} \ z \in [-\sqrt{6}/2,\sqrt{6}/2] & \lambda=1/2 & \\ x=-1\pm\sqrt{2}/2 & y=0 & z=\pm\sqrt{2}/2 & \lambda=1/6 \end{cases}$$

(the values of $\lambda$ are unimportant).

The first line means that there is an infinite set of candidate solutions on a certain sectional ellipse.

One verifies that it is the second line which gives an optimal solution with $\pm$ replaced by $+$. This coincides with the result of @Doug M.

Remark: There are many solutions because we are in a very particular case: $B$ is situated at the center of surface $(S)$ (an ellipsoid).


Closest distance between a plane and a line goes like this: If plane is ax+by+cz=d where a,b,c,d are constants and the point is (h,k,l) Then shortest distance is (ha+bk+cl-d)/root(a^2+b^2+c^2)

  • $\begingroup$ Not relevant, surface not a plane. $\endgroup$ – coffeemath Dec 22 '16 at 18:54
  • $\begingroup$ Its ok but for plane it goes like what i mentioned above $\endgroup$ – H4K3R Dec 22 '16 at 18:55
  • $\begingroup$ Something is strange: you mention the distance between a plane and a line, and afterwards, from a plane to a point. $\endgroup$ – Jean Marie Dec 22 '16 at 19:01
  • $\begingroup$ #jeanmaire just figure out my answer is correct $\endgroup$ – H4K3R Dec 22 '16 at 19:08
  • $\begingroup$ The fact that the last sentence is correct is not all. As you are new in math SE, you will improve ! But take care when answering that you have coherent writing, and coherence also with the question. A last remark, you need an absolute value sign on the numerator of your formula. $\endgroup$ – Jean Marie Dec 22 '16 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.