Distance From the Origin to the Plane 2x + 3y + 4z = 12
Find the shortest distance from the origin to the plane $$2x + 3y + 4z = 12,$$ and the point on the plane where that distance is attained.
Solve it as a constrained optimization problem using Lagrange multipliers, then generalize: what is the distance from the origin to the plane $ax + by + cz = d$?
Hints
- Minimize the squared distance $x^2 + y^2 + z^2$ (same minimizer as the distance, but differentiable everywhere) subject to $2x + 3y + 4z = 12$.
- Form $L = x^2 + y^2 + z^2 - \lambda(2x + 3y + 4z - 12)$ and set all partial derivatives to zero. Each of $x, y, z$ comes out proportional to the corresponding coefficient of the plane.
- Substituting $x = \lambda, y = 3\lambda/2, z = 2\lambda$ into the constraint gives $\lambda = 24/29$. The minimizer is $\frac{12}{29}(2, 3, 4)$, which is a multiple of the normal vector, as it should be.
Worked Solution
How to Think About It: The distance from a point to a plane is a constrained minimization: minimize $\|(x,y,z)\|$ subject to the plane equation. Lagrange multipliers turn it into a linear system, and the geometry (closest point along the normal) falls out of the stationarity conditions.
Quick Estimate: The plane crosses the axes at $(6, 0, 0)$, $(0, 4, 0)$ and $(0, 0, 3)$, so the distance to the origin is less than $3$. The normal $(2, 3, 4)$ has length $\sqrt{29} \approx 5.39$, and $12/5.39 \approx 2.23$.
Formal Solution:
*Step 1 -- Set up the Lagrangian.* Minimize $f(x, y, z) = x^2 + y^2 + z^2$ subject to $g(x, y, z) = 2x + 3y + 4z - 12 = 0$: $$L(x, y, z, \lambda) = x^2 + y^2 + z^2 - \lambda\,(2x + 3y + 4z - 12).$$
*Step 2 -- Stationarity conditions.* $$\frac{\partial L}{\partial x} = 2x - 2\lambda = 0, \quad \frac{\partial L}{\partial y} = 2y - 3\lambda = 0, \quad \frac{\partial L}{\partial z} = 2z - 4\lambda = 0,$$ so $x = \lambda$, $y = \tfrac{3}{2}\lambda$, $z = 2\lambda$: the point is $\tfrac{\lambda}{2}(2, 3, 4)$, a multiple of the plane's normal vector.
*Step 3 -- Impose the constraint.* $$2\lambda + \tfrac{9}{2}\lambda + 8\lambda = \tfrac{29}{2}\lambda = 12 \;\Longrightarrow\; \lambda = \frac{24}{29}.$$ The minimizer is $$(x^*, y^*, z^*) = \left(\frac{24}{29}, \frac{36}{29}, \frac{48}{29}\right) = \frac{12}{29}(2, 3, 4).$$
*Step 4 -- Distance.* $$\sqrt{x^{*2} + y^{*2} + z^{*2}} = \frac{12}{29}\sqrt{4 + 9 + 16} = \frac{12\sqrt{29}}{29} = \frac{12}{\sqrt{29}} \approx 2.228.$$ Because $f$ is convex and the constraint is affine, this stationary point is the global minimum.
*Step 5 -- General plane $ax + by + cz = d$.* The same computation gives the minimizer $\frac{d}{a^2 + b^2 + c^2}(a, b, c)$ and $$\text{dist} = \frac{|d|}{\sqrt{a^2 + b^2 + c^2}},$$ which is the projection of any point of the plane onto the unit normal $(a, b, c)/\sqrt{a^2 + b^2 + c^2}$.
Answer: The distance is $\dfrac{12}{\sqrt{29}} \approx 2.228$, attained at $\left(\frac{24}{29}, \frac{36}{29}, \frac{48}{29}\right)$. In general, the distance from the origin to $ax + by + cz = d$ is $\dfrac{|d|}{\sqrt{a^2 + b^2 + c^2}}$.
Intuition
The closest point on a plane to the origin lies along the plane's normal vector $(a, b, c)$, and Lagrange multipliers say exactly that: at the optimum the gradient of the objective $(2x, 2y, 2z)$ is parallel to the gradient of the constraint $(a, b, c)$. The resulting formula $|d|/\sqrt{a^2 + b^2 + c^2}$ is the same projection used for the distance of a portfolio from a budget or factor-neutrality constraint, and the minimum-norm solution of an underdetermined linear system.