Minimizing the squared distance from a line to a hyperbola? Consider the minimization problem:
Minimize $$|(z-x, w-y)|^2$$,
Where $(x, y) \in \mathbb{R}^2$ is on a straight line defined by the equation $ax + by = c$,
and $(z, w) \in \mathbb{R}^2$ is on the hyperbola defined by $\{(z, w): 2z^2 - 3w^2 = 1, z \geq 0\}$.
Additionally, we assume that the line does not intersect with the hyperbola.
For the sake of this exercise, I want to frame this problem as a constrained optimization problem with inequality constraints, and use the first-order necessary condition to find the candidates for the local minimum. So the three constraints I come up with are:
$h_1(x, y, z, w) = ax + by - c = 0$
$h_2(x, y, z, w) = 2z^2 - 3w^2 - 1 = 0$
$g(x, y, z, w) = -x \leq 0$
And then attempted to solve for the candidates using the KKT condition.
However the calculation seems really messy and seems to be going towards nowhere... Any hint on how I should proceed?
 A: We have the following function to minimize:
$f(z,w,x,y)=(z-x)^2+(w-y)^2$
and the constraints:
$g_1(z,w,x,y) = 2z^2-3w^2-1 = 0$
$g_2(z,w,x,y) = ax+by+c = 0$
At minimum point, by Lagrange multipliers, we must have the gradient of the objective function parallel to the gradients of all the constraints, i.e., a linear combination of the gradients of the constraints:
$\nabla f(z,w,x,y) = \sum\limits_{i=1}^2 \lambda_i\nabla g_i(z,w,x,y)$,
for some $\lambda_i$.
Here, we have
$\nabla{f} = \begin{bmatrix}-2(z-x)\\-2(w-y)\\2(z-x)\\2(w-y)\\\end{bmatrix}$,
$\nabla{g_1} = \lambda_1\begin{bmatrix}4z\\6w\\0\\0\\\end{bmatrix}$
$\nabla{g_2} = \lambda_2\begin{bmatrix}0\\0\\a\\b\\\end{bmatrix}$
s.t.,
$\begin{bmatrix}-2(z-x)\\-2(w-y)\\2(z-x)\\2(w-y)\\\end{bmatrix}$ $= \begin{bmatrix}4\lambda_1 z\\6\lambda_1 w\\\lambda_2 a\\ \lambda_2 b\\\end{bmatrix}$ ,
Eliminate $\lambda_2$ from the last 2 equations and use $2z^2-3w^2=1$ to get
$z^2=\frac{9a^2}{2(9a^2-6b^2)} \implies z=\pm\frac{3a}{\sqrt{2(9a^2-6b^2)}} $
$w^2=\frac{2b^2}{9a^2-6b^2} \implies w=\pm\frac{\sqrt{2}b}{\sqrt{9a^2-6b^2}}$
Let's assume $a>0$ and use the solution $(z,w)=\left(\frac{3a}{\sqrt{2(9a^2-6b^2)}}, \frac{-\sqrt{2}b}{\sqrt{9a^2-6b^2}}\right)$ (explore the other solutions too) and similarly, eliminate $\lambda_1$ from the first 2 equations and use $ax+by=c$ to get
$(x,y)=\left(\frac{ca+\frac{5ab^2}{\sqrt{2(9a^2-6b^2)}}}{a^2+b^2}, 
             \frac{bc-\frac{5a^2b}{\sqrt{9*a^2-6*b^2}}}{a^2+b^2}\right)$
The following animation shows the solution for different values of $a,b$ for the straight line (with $c=0$):

