# How do i determine the distance between x^2+y^2-z^2=1 and the point P(1,3,1) ?

May 21, 2016

$d = 1.35669$

#### Explanation:

Given $f \left(x , y , z\right) = {x}^{2} + {y}^{2} - {z}^{2} - 1$, and $p = \left(x , y , z\right)$, the distance between point ${p}_{0} = \left(1 , 3 , 1\right)$ and $p \in f \left(x , y , z\right) = 0$ is given by $d = \left\lVert p - {p}_{0} \right\rVert$. Here instead of $d$ we will consider ${d}^{2} = \left(p - {p}_{0}\right) \cdot \left(p - {p}_{0}\right)$ observing that the minimum of $d$ is also the minimum of ${d}^{2}$.

The problem restated is:
Find the point ${p}^{+} = \left({x}^{+} , {y}^{+} , {z}^{+}\right)$ such that
$\min {d}^{2} \left(x , y , z\right) = {d}^{2} \left({x}^{+} , {y}^{+} , {z}^{+}\right)$ and obeying $f \left({x}^{+} , {y}^{+} , {z}^{+}\right) = 0$
We know that ${d}^{2} = {\left(x - {x}_{0}\right)}^{2} + {\left(y - {y}_{0}\right)}^{2} + {\left(z - {z}_{0}\right)}^{2}$.

First we formulate the Lagrangian which is:
$L \left(x , y , z , \lambda\right) = f \left(x , y , z\right) + \lambda {d}^{2} \left(x , y , z\right)$
$L \left(x , y , z , \lambda\right) = {x}^{2} + {y}^{2} - {z}^{2} - 1 + \lambda \left({\left(x - {x}_{0}\right)}^{2} + {\left(y - {y}_{0}\right)}^{2} + {\left(z - {z}_{0}\right)}^{2}\right)$

Second we calculate the partial derivatives of $L$ regarding $\left(x , y , z , \lambda\right)$ so

${L}_{x} = 2 \left(- 1 + x\right) + 2 x \lambda$
${L}_{y} = 2 \left(- 3 + y\right) + 2 y \lambda$
${L}_{z} = 2 \left(- 1 + z\right) - 2 z \lambda$
${L}_{\lambda} = - 1 + {x}^{2} + {y}^{2} - {z}^{2}$

Third we equate ${L}_{x} = 0 , {L}_{y} = 0 , {L}_{z} = 0 , {L}_{\lambda} = 0$
solving for $\left({x}^{+} , {y}^{+} , {z}^{+}\right)$ finding

$\left\{\begin{matrix}{x}_{1}^{+} = - 0.322242 \\ {y}_{1}^{+} = - 0.966725 \\ {z}_{1}^{+} = 0.195953 \\ {\lambda}_{1}^{+} = - 4.10326\end{matrix}\right.$

and

$\left\{\begin{matrix}{x}_{2}^{+} = 0.678696 \\ {y}_{2}^{+} = 2.03609 \\ {z}_{2}^{+} = 1.89902 \\ {\lambda}_{2}^{+} = 0.473413\end{matrix}\right.$

Fourth we qualify the found points. Calculating the Hessian matrix
of ${d}^{2} \left(x , y , z\right)$ obtaining

$H \left(x , y , z\right) = \left(\begin{matrix}{f}_{x x} & {f}_{x y} & {f}_{x z} \\ {f}_{y x} & {f}_{y y} & {f}_{y z} \\ {f}_{z x} & {f}_{z y} & {f}_{z z}\end{matrix}\right) = \left(\begin{matrix}2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 2\end{matrix}\right)$,

with positive eigenvalues, qualifying the point as a local minimum.

Fifth we calculate ${d}_{1} = \sqrt{{d}^{2} \left({x}_{1}^{+} , {y}_{1}^{+} , {z}_{1}^{+}\right)} = 4.2579$
and ${d}_{2} = \sqrt{{d}^{2} \left({x}_{2}^{+} , {y}_{2}^{+} , {z}_{2}^{+}\right)} = 1.35669$
as local minimal distances.