Optimization on Ellipses & 3D Surfaces

Published

September 5, 2025

This lesson addresses the problem of finding the closest point on a curve or surface to a given external point. We begin with ellipses in two dimensions, then extend the analysis to three-dimensional ellipsoids. The central technique is a geometric condition — perpendicularity of the line of closest approach — that renders these optimization problems tractable.

Finding the closest point on a curve arises in numerous applications:

  • GPS navigation: a device finds the nearest point on a road to the user’s location.
  • Robotics: a robot arm computes the closest approach to a curved surface.
  • Computer graphics: ray tracing determines where light intersects curved objects such as helmets and planets.
  • Satellite orbits: mission control computes the closest approach of an elliptical orbit to a space station.

Ellipses and ellipsoids are among the most common shapes in nature — planets, orbits, and even eggs are approximately ellipsoidal.

Topics Covered

  • Ellipse review: center, axes, standard form
  • Optimization: closest point on an ellipse to an external point
  • Using differential equations to find the normal vector
  • Geometric insight: the normal must point toward the external point
  • Setting up and solving the system of equations
  • Extension to 3D: ellipsoids and tangent planes
  • 3D optimization: closest point on an ellipsoid

Lecture Video

Key Frames from the Lecture

Prerequisites

An ellipse is a curve obtained by scaling a circle by different factors along two perpendicular axes.

The standard form of an ellipse centered at the origin is:

\[\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1\]

  • \(a\) = half the width (semi-major axis if \(a > b\))
  • \(b\) = half the height (semi-minor axis if \(a > b\))

If the center is at \((h, k)\) instead of the origin:

\[\frac{(x - h)^2}{a^2} + \frac{(y - k)^2}{b^2} = 1\]

The distance between two points \((x_1, y_1)\) and \((x_2, y_2)\) is:

\[d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\]

This comes straight from the Pythagorean theorem. In 3D, with points \((x_1, y_1, z_1)\) and \((x_2, y_2, z_2)\):

\[d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}\]

When an equation such as \(x^2 + y^2 = 25\) (a circle) is given, \(y\) is not expressed explicitly as a function of \(x\). To find \(\frac{dy}{dx}\), one differentiates both sides with respect to \(x\), treating \(y\) as a function of \(x\):

\[2x + 2y\frac{dy}{dx} = 0 \quad\Rightarrow\quad \frac{dy}{dx} = -\frac{x}{y}\]

This yields the slope of the tangent line at any point on the curve.

A tangent line just touches a curve at a point and goes in the direction the curve is heading. A normal vector is perpendicular (at a right angle) to the tangent line.

If the tangent has slope \(m\), the normal has slope \(-\frac{1}{m}\) (the negative reciprocal).

Normal vectors indicate the direction pointing “straight out” from the surface — perpendicular to the tangent at the point of contact.

Key Concepts

Ellipse Review

Our ellipse is centered at \((5, -3)\) with semi-major axis \(a = 8\) (horizontal) and semi-minor axis \(b = 6\) (vertical):

\[\frac{(x - 5)^2}{64} + \frac{(y + 3)^2}{36} = 1\]

The Optimization Problem

Goal: Find the point \(P = (x_0, y_0)\) on the ellipse that is closest to the external point \(A = (20, 0)\).

We want to minimize the distance:

\[d = \sqrt{(x_0 - 20)^2 + (y_0 - 0)^2}\]

subject to the constraint that \((x_0, y_0)\) lies on the ellipse.

Finding the Normal Vector via Differentiation

Differentiate the ellipse equation implicitly with respect to \(x\):

\[\frac{2(x - 5)}{64} + \frac{2(y + 3)}{36}\cdot\frac{dy}{dx} = 0\]

Simplify:

\[\frac{x - 5}{32} + \frac{(y + 3)}{18}\cdot\frac{dy}{dx} = 0\]

So the tangent slope at a point \((x_0, y_0)\) on the ellipse is:

\[\frac{dy}{dx} = -\frac{18(x_0 - 5)}{32(y_0 + 3)}\]

The tangent direction at \((x_0, y_0)\) is along the vector \(\left(1, \; -\frac{18(x_0 - 5)}{32(y_0 + 3)}\right)\), and a vector normal (perpendicular) to the ellipse at that point is:

ImportantKey Idea: Normal Vector to an Ellipse

The normal vector points perpendicularly outward from the ellipse at any point. It is obtained by computing the gradient of the ellipse equation. For an ellipse centered at \((h, k)\), the normal at \((x_0, y_0)\) is proportional to \(\left(\frac{x_0 - h}{a^2}, \frac{y_0 - k}{b^2}\right)\).

\[\vec{n} = \left(\frac{x_0 - 5}{32}, \;\frac{y_0 + 3}{18}\right)\]

Interactive: Finding the Closest Point on an Ellipse

Closest Point on Ellipse to Target

The orange point P sweeps around the ellipse. The purple line shows the normal vector at P. The red point marks the closest point, where the normal aligns with the direction to the target A.

The Geometric Insight

ImportantKey Idea: The Closest Point Condition

At the closest point on a curve to an external point, the line connecting them must be perpendicular to the curve. If it were not, one could slide along the curve and achieve a shorter distance. This means the direction from the closest point to the target must be parallel to the normal vector.

At the closest point \(P\) on the ellipse to \(A\), the line from \(P\) to \(A\) must be perpendicular to the ellipse — that is, it must lie along the normal direction. If it were not perpendicular, one could slide along the ellipse and reduce the distance.

This means the vector \(\overrightarrow{PA} = (20 - x_0, \; 0 - y_0)\) must be parallel to the normal vector \(\vec{n}\).

Two vectors are parallel when their components are proportional:

\[\frac{20 - x_0}{\frac{x_0 - 5}{32}} = \frac{-y_0}{\frac{y_0 + 3}{18}}\]

Which simplifies to:

\[\frac{32(20 - x_0)}{x_0 - 5} = \frac{-18\,y_0}{y_0 + 3}\]

Setting Up the System of Equations

We now have two equations in two unknowns (\(x_0\) and \(y_0\)):

Equation 1 (point lies on the ellipse): \[\frac{(x_0 - 5)^2}{64} + \frac{(y_0 + 3)^2}{36} = 1\]

Equation 2 (normal is parallel to \(\overrightarrow{PA}\)): \[\frac{32(20 - x_0)}{x_0 - 5} = \frac{-18\,y_0}{y_0 + 3}\]

Solving this system (by substitution or numerical methods) gives the closest point.

Drag the slider \(t\) to move point \(P\) around the ellipse and observe how the distance changes.

Interactive: Function Values on a Grid (Contour-like View)

Distance Function Shown as Color-Coded Dots

Each dot shows the distance from that grid point to the target A. Darker blue = closer, darker red = farther. The ellipse boundary is overlaid.

Each dot is colored by its distance to the target point A. Blue dots are closer, red dots are farther. Move the target to see how the distance field changes – notice the contour-like pattern of equal-distance rings.

Extension to 3D: Ellipsoids

An ellipsoid is the 3D version of an ellipse. The ellipsoid we consider is:

\[\frac{x^2}{1} + \frac{y^2}{4} + \frac{z^2}{9} = 1\]

This is a stretched sphere: radius 1 along \(x\), radius 2 along \(y\), and radius 3 along \(z\).

Tangent Planes and Normal Vectors in 3D

For a surface defined by \(F(x, y, z) = 0\), the gradient \(\nabla F\) gives the normal vector.

With \(F(x, y, z) = x^2 + \frac{y^2}{4} + \frac{z^2}{9} - 1\), the gradient at a point \((x_0, y_0, z_0)\) on the ellipsoid is:

\[\nabla F = \left(2x_0, \;\frac{y_0}{2}, \;\frac{2z_0}{9}\right)\]

Dropping the common factor of 2, the normal direction is:

ImportantKey Idea: The Gradient Gives the Normal in Any Dimension

For any surface defined by \(F(x,y,z) = 0\), the gradient \(\nabla F\) always points perpendicular to the surface. This is the 3D version of the same normal-vector idea we used in 2D, and it works in any number of dimensions.

\[\vec{n} = \left(x_0, \;\frac{y_0}{4}, \;\frac{z_0}{9}\right)\]

The tangent plane at \((x_0, y_0, z_0)\) is the flat surface that just touches the ellipsoid at that point, and \(\vec{n}\) points straight out of it.

3D Optimization: Closest Point on the Ellipsoid

Goal: Find the point on the ellipsoid closest to \(A = (5, 5, 5)\).

Same idea as 2D — at the closest point, the vector from \(P\) to \(A\) must be parallel to the normal:

\[\overrightarrow{PA} = (5 - x_0, \; 5 - y_0, \; 5 - z_0) \;\parallel\; \left(x_0, \;\frac{y_0}{4}, \;\frac{z_0}{9}\right)\]

This gives us the proportionality conditions:

\[\frac{5 - x_0}{x_0} = \frac{5 - y_0}{\frac{y_0}{4}} = \frac{5 - z_0}{\frac{z_0}{9}}\]

Combined with the ellipsoid equation \(x_0^2 + \frac{y_0^2}{4} + \frac{z_0^2}{9} = 1\), this is a system we can solve.

The geometric reasoning is identical: if the line from the surface to the external point is not perpendicular to the surface, then one could perturb along the surface and reduce the distance. At the true closest point, there is no “lateral” improvement — the direction to \(A\) lies entirely along the normal.

This principle holds in any number of dimensions.

Cheat Sheet

What you want What to do
Ellipse standard form \(\frac{(x-h)^2}{a^2} + \frac{(y-k)^2}{b^2} = 1\), center \((h,k)\)
Normal to ellipse at \((x_0, y_0)\) \(\vec{n} = \left(\frac{x_0 - h}{a^2},\; \frac{y_0 - k}{b^2}\right)\)
Closest point condition \(\overrightarrow{PA} \parallel \vec{n}\) (normal points at the target)
Ellipsoid standard form \(\frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} = 1\)
Normal to ellipsoid at \((x_0, y_0, z_0)\) \(\vec{n} = \left(\frac{x_0}{a^2},\; \frac{y_0}{b^2},\; \frac{z_0}{c^2}\right)\)
Tangent plane at \((x_0, y_0, z_0)\) \(\frac{x_0\,(x - x_0)}{a^2} + \frac{y_0\,(y - y_0)}{b^2} + \frac{z_0\,(z - z_0)}{c^2} = 0\)

The Optimization Recipe

  1. Write the constraint: point must lie on the curve/surface
  2. Differentiate to find the normal vector
  3. Set up: \(\overrightarrow{PA} \parallel \vec{n}\) (proportionality condition)
  4. Solve the system of equations