[Math] shortest distance from point to hyperplane lagrange method

lagrange multiplierlinear algebra

I need to find the shortest distance, in D-dimensional Euclidean space ($\mathbb{R}^D$) from a point $\textbf{x}_0$ to a hyperplane $H: \textbf{w}^T \textbf{x} + b = 0$, using the method of Lagrange multipliers. The answer should be an expression in terms of $\textbf{w}, b$ and $\textbf{x}_0$.

Note: I am aware that a few similar questions exist, such this one. I am creating a new question because I need to know how the derivation steps work in order to get a solution in a specific form. I know how to solve this problem in three dimensions, but not with linear algebra. Any help would be appreciated.

Best Answer

Consider the Lagrange function $$L(\mathbf x,\lambda)=\|\mathbf x-\mathbf x_0\|^2+2\lambda(\mathbf w^T\mathbf x+b)$$ The Lagrange multiplier is multiplied by $\,2\,$ to simplify the computations (this is legal).

Since $$L(\mathbf x,\lambda)=\|\mathbf x\|^2-2(\mathbf x_0-\lambda \mathbf w)^T\mathbf x+2\lambda b+\|\mathbf x_0\|^2$$ one has $$\frac {\partial L}{\partial \mathbf x}=2\mathbf x-2(\mathbf x_0-\lambda \mathbf w)$$ using formulas (69) and (131) in the pdf quoted by @user25004.

Solving $\,\dfrac {\partial L}{\partial \mathbf x}=0\,$, one obtains $$\mathbf x=\mathbf x_0-\lambda \mathbf w$$ which, substituted in the equation of the hyperplane, gives $$\lambda=\frac {\mathbf w^T\mathbf x_0+b}{\|\mathbf w\|^2}$$ so the shortest distance is $$\|\mathbf x_0-\lambda \mathbf w-\mathbf x_0\|=|\lambda|\|\mathbf w\|=\frac {|\mathbf w^T\mathbf x_0+b|}{\|\mathbf w\|}$$

Related Question