Tutorials › Calculus III › Closest Points On Ellipsoids

Applied Multivariable Optimization · Tutorial 482 of 999

Closest Points On Ellipsoids

Set up the distance-minimization problem, find and compare its candidates, and use the ellipsoid’s geometry to verify nearest points.

Advanced 12 min read

What You'll Learn

  • Formulate nearest-point problems on an ellipsoid as constrained minimizations of squared distance.
  • Derive the Lagrange multiplier equations and their scalar form.
  • Recognize and handle multiplier values where the scalar formula has a zero denominator.
  • Verify an outward-normal candidate is globally nearest using the ellipsoid equation.
  • Compare all stationary candidates when the target lies inside the ellipsoid.
  • Identify when an ellipsoid has more than one closest point.

Introduction

A point outside an ellipsoid has a natural nearest point on its surface. Finding that point is not simply a matter of moving toward the ellipsoid’s center: the direction of shortest distance depends on the ellipsoid’s shape. The same problem can be more subtle when the given point is inside the ellipsoid, because there may be several equally close points on the surface.

The method is to minimize squared distance subject to the ellipsoid equation. Lagrange multipliers produce candidate points, but the multiplier equations must be handled carefully: some values make a commonly used formula undefined, and a stationary point is not automatically the nearest point. The geometry of the ellipsoid provides a useful way to check candidates.

Setting Up the Problem

Consider an ellipsoid in \(n\)-dimensional space, centered at the origin and aligned with the coordinate axes. Let its positive semiaxis lengths be \(a_1,\dots,a_n\), and let the given point be \(\mathbf{p}=(p_1,\dots,p_n)\). A point \(\mathbf{x}=(x_1,\dots,x_n)\) lies on the ellipsoid when

$$ g(\mathbf{x}) = \sum_{i=1}^{n}\frac{x_i^2}{a_i^2}-1 = 0. $$

The squared distance from \(\mathbf{x}\) to \(\mathbf{p}\) is \(\sum_{i=1}^n(x_i-p_i)^2\). Minimizing this is equivalent to minimizing half the squared distance; the factor of one half makes the derivatives simpler.

Definition: A closest point to \(\mathbf{p}\) on the ellipsoid is a point \(\mathbf{x}_*\) on the ellipsoid such that \(\|\mathbf{x}_*-\mathbf{p}\|\leq\|\mathbf{x}-\mathbf{p}\|\) for every point \(\mathbf{x}\) on the ellipsoid. It is enough to minimize the squared distance, since squaring preserves the order of nonnegative distances.

The ellipsoid is closed and bounded, so it is compact. The squared-distance function is continuous, so it attains a minimum on the ellipsoid. Moreover, its constraint is regular everywhere on the ellipsoid: its gradient is

$$ \nabla g(\mathbf{x}) = \left(\frac{2x_1}{a_1^2},\dots,\frac{2x_n}{a_n^2}\right). $$

This gradient can vanish only when every \(x_i=0\), but the origin does not lie on the ellipsoid. Therefore, the Lagrange multiplier condition applies at every constrained minimum.

The Multiplier Equations

Minimize \(F(\mathbf{x})=\frac12\sum_{i=1}^n(x_i-p_i)^2\) subject to \(g(\mathbf{x})=0\). With the convention \(\nabla F+\lambda\nabla g=\mathbf{0}\), the coordinate equations are

$$ x_i-p_i+\lambda\frac{x_i}{a_i^2}=0, \qquad i=1,\dots,n. $$

Whenever \(a_i^2+\lambda\neq 0\), each equation can be rearranged to give

$$ x_i=\frac{a_i^2p_i}{a_i^2+\lambda}. $$

Substituting these coordinates into the ellipsoid equation gives a one-variable equation for the multiplier:

$$ \sum_{i=1}^{n} \frac{a_i^2p_i^2}{(a_i^2+\lambda)^2} = 1. $$

Solving this equation gives candidate multipliers, and the coordinate formula then gives candidate points. But the formula is valid only when none of its denominators is zero. If \(\lambda=-a_j^2\), the \(j\)-th multiplier equation instead reads \(-p_j=0\). Thus this multiplier value is possible only if \(p_j=0\); when it is possible, that equation does not determine \(x_j\). Such cases must be checked in the original equations and the ellipsoid constraint rather than discarded.

Important: A solution of the multiplier equations is a stationary candidate, not automatically a closest point. The ellipsoid is compact, so a global minimum exists, but there can be multiple stationary candidates. Compare their distances, or use a valid geometric argument to establish that a candidate is globally nearest.

Why the Normal Direction Gives a Geometric Check

The multiplier equations say that the vector from the candidate point on the ellipsoid to the given point is a scalar multiple of the ellipsoid’s normal vector:

$$ \mathbf{p}-\mathbf{x} = \lambda\nabla g(\mathbf{x}). $$

This normal-direction condition is necessary for a closest point, but by itself it does not say whether the point is closest or farthest. For this ellipsoid, the constraint equation gives a sharper check when \(\lambda\geq 0\).

Geometric verification: Suppose \(\mathbf{x}\) and \(\mathbf{y}\) lie on the ellipsoid and \(\mathbf{p}-\mathbf{x}=\lambda\nabla g(\mathbf{x})\) with \(\lambda\geq0\). Then \(\mathbf{x}\) is a global closest point on the ellipsoid to \(\mathbf{p}\).

To prove this, write \(\Delta_i=y_i-x_i\). Because both points satisfy the ellipsoid equation, subtracting \(g(\mathbf{x})=0\) from \(g(\mathbf{y})=0\) gives

$$ 0 = \sum_{i=1}^{n} \frac{(x_i+\Delta_i)^2-x_i^2}{a_i^2} = \nabla g(\mathbf{x})\mathbin{\cdot}(\mathbf{y}-\mathbf{x}) + \sum_{i=1}^{n}\frac{\Delta_i^2}{a_i^2}. $$

Consequently, \(\nabla g(\mathbf{x})\mathbin{\cdot}(\mathbf{y}-\mathbf{x})=-\sum_i\Delta_i^2/a_i^2\). Now expand the squared distance from \(\mathbf{p}\) to \(\mathbf{y}\), using \(\mathbf{p}-\mathbf{x}=\lambda\nabla g(\mathbf{x})\):

$$ \begin{aligned} \|\mathbf{p}-\mathbf{y}\|^2 &= \|\mathbf{p}-\mathbf{x}\|^2 -2(\mathbf{p}-\mathbf{x})\mathbin{\cdot}(\mathbf{y}-\mathbf{x}) +\|\mathbf{y}-\mathbf{x}\|^2\\ &= \|\mathbf{p}-\mathbf{x}\|^2 + 2\lambda\sum_{i=1}^{n}\frac{\Delta_i^2}{a_i^2} + \sum_{i=1}^{n}\Delta_i^2\\ &\geq \|\mathbf{p}-\mathbf{x}\|^2. \end{aligned} $$

The inequality follows because \(\lambda\geq0\) and every squared term is nonnegative. It holds for every point \(\mathbf{y}\) on the ellipsoid, proving the claim. If \(\lambda>0\), equality is possible only when every \(\Delta_i=0\), so the closest point is unique. For \(\lambda<0\), this argument does not establish a minimum; compare the candidates.

Worked Example: An Exterior Point and a Global Check

Worked Example: An Exterior Point and a Global Check

Find the closest point on the ellipse \(\frac{x^2}{9}+\frac{y^2}{4}=1\) to \(\mathbf{p}=(11/5,12/5)\). A candidate is \(\mathbf{x}=(9/5,8/5)\). First check that it is feasible:

$$ \frac{(9/5)^2}{9}+\frac{(8/5)^2}{4} = \frac{81}{225}+\frac{64}{100} = \frac{9}{25}+\frac{16}{25} = 1. $$

Here \(g(x,y)=x^2/9+y^2/4-1\), so \(\nabla g(x,y)=(2x/9,y/2)\). At the proposed point,

$$ \nabla g(9/5,8/5) = \left(\frac{2}{5},\frac{4}{5}\right), \qquad \mathbf{p}-\mathbf{x} = \left(\frac{2}{5},\frac{4}{5}\right). $$

Thus \(\mathbf{p}-\mathbf{x}=1\cdot\nabla g(\mathbf{x})\), so the multiplier is \(\lambda=1\). The geometric verification applies because \(\lambda\geq0\): this point is globally closest on the ellipse. Its squared distance is

$$ \|\mathbf{p}-\mathbf{x}\|^2 = \left(\frac{2}{5}\right)^2+\left(\frac{4}{5}\right)^2 = \frac{4}{25}+\frac{16}{25} = \frac{4}{5}. $$

The distance is therefore \(\sqrt{4/5}=2/\sqrt{5}\). The feasibility check and the normal-direction check both agree with the candidate.

Worked Example: The Center of an Ellipse

Worked Example: The Center of an Ellipse

Find the closest points on \(\frac{x^2}{9}+y^2=1\) to the origin. On the ellipse, \(x^2/9+y^2=1\), so \(x^2=9(1-y^2)\). The squared distance to the origin is therefore

$$ x^2+y^2 = 9(1-y^2)+y^2 = 9-8y^2. $$

Since \(0\leq y^2\leq1\), this quantity is minimized when \(y^2=1\). The constraint then gives \(x=0\), so the two closest points are \((0,1)\) and \((0,-1)\), each at distance \(1\).

The multiplier equations confirm why the usual coordinate formula needs care. With \(\mathbf{p}=(0,0)\), they are

$$ x+\lambda\frac{x}{9}=0, \qquad y+\lambda y=0. $$

At either closest point, \(x=0\), \(y=\pm1\), and \(\lambda=-1\). The second equation is then \(0=0\); it does not determine \(y\). The ellipsoid constraint gives \(y=\pm1\), and substituting either point back gives squared distance \(0^2+(\pm1)^2=1\), as required.

Worked Example: An Interior Point and a Singular Multiplier

Worked Example: An Interior Point and a Singular Multiplier

Find the closest points on \(\frac{x^2}{4}+y^2=1\) to \(\mathbf{p}=(1,0)\). The multiplier equations are

$$ x-1+\lambda\frac{x}{4}=0, \qquad y+\lambda y=0. $$

First consider \(\lambda\neq-1\). The second equation gives \(y=0\). The constraint then gives \(x^2/4=1\), so \(x=2\) or \(x=-2\). Substituting \(x=2\) into the first equation gives \(1+\lambda/2=0\), hence \(\lambda=-2\). Substituting \(x=-2\) gives \(-3-\lambda/2=0\), hence \(\lambda=-6\). Their squared distances from \((1,0)\) are respectively \(1\) and \(9\).

Now check the exceptional value \(\lambda=-1\) in the original equations. The first equation becomes \(3x/4-1=0\), so \(x=4/3\). The constraint gives

$$ \frac{(4/3)^2}{4}+y^2=1, \qquad y^2=1-\frac{4}{9}=\frac{5}{9}, \qquad y=\pm\frac{\sqrt{5}}{3}. $$

The two resulting candidates are \((4/3,\sqrt{5}/3)\) and \((4/3,-\sqrt{5}/3)\). For each one, substitution into the constraint gives \(4/9+5/9=1\). Its squared distance from \((1,0)\) is

$$ \left(\frac{4}{3}-1\right)^2 + \left(\pm\frac{\sqrt{5}}{3}\right)^2 = \frac{1}{9}+\frac{5}{9} = \frac{2}{3}. $$

The stationary candidates found are \((2,0)\), \((-2,0)\), and the two points with \(x=4/3\). Their squared distances are \(1\), \(9\), and \(2/3\), respectively. Because a minimum exists and every minimum must satisfy the multiplier equations, the least of these candidate distances identifies the global minima. Both points \((4/3,\pm\sqrt{5}/3)\) are closest, each at distance \(\sqrt{2/3}\).

A Common Mistake: Dividing by a Zero Factor

In the interior-point example, it would be incorrect to divide the second multiplier equation \((1+\lambda)y=0\) by \(1+\lambda\) without first checking whether that factor can be zero. Doing so would force \(y=0\), leave only \((2,0)\) and \((-2,0)\), and incorrectly declare \((2,0)\) closest because its distance \(1\) is less than \(3\). The omitted multiplier \(\lambda=-1\) gives two feasible points at distance \(\sqrt{2/3}<1\).

Correction: When rearranging a multiplier equation, record the values that make a denominator or divided factor zero. Check those values in the original equations and the constraint before comparing candidate distances.

A Reliable Procedure

For a specified axis-aligned ellipsoid and target point, the following process keeps the algebra and the geometric check distinct.

1
Write the objective and constraint.
Minimize half the squared distance to the target, subject to the ellipsoid equation.
2
Form the multiplier equations.
Use \(x_i-p_i+\lambda x_i/a_i^2=0\) for each coordinate.
3
Check exceptional multiplier values.
Do not use the coordinate formula where \(a_i^2+\lambda=0\); return to the original equations there.
4
Check feasibility and distances.
Substitute every candidate into the ellipsoid equation, then compare its squared distance to the target.
5
Use geometry when it applies.
If a candidate has \(\lambda\geq0\), the squared-distance identity proves it is globally closest.

The method matters in geometry and design whenever a point must be placed on a curved boundary as close as possible to a specified location. It also illustrates a general lesson in constrained optimization: the equations locate candidates, while feasibility and comparison establish which candidate solves the original problem.

Check Your Understanding

Use the multiplier equations and the ellipsoid geometry to answer these questions.

  1. Why is minimizing half the squared distance equivalent to minimizing the distance itself?
  2. For an ellipsoid with semiaxes \(a_i\), what scalar equation follows when the coordinate formula is valid?
  3. Why must the cases \(a_i^2+\lambda=0\) be checked in the original multiplier equations?
  4. What does the sign condition \(\lambda\geq0\) allow you to conclude from the distance comparison identity?
  5. In the ellipse \(\frac{x^2}{4}+y^2=1\), why are there two closest points to \((1,0)\), and what is their common distance?