All Euler problems
Project Euler

Rolling Ellipse

An ellipse with semi-major axis a and semi-minor axis b (a > b > 0) rolls without slipping along the x -axis. Compute the arc length of the path traced by the center of the ellipse over one complet...

Source sync May 21, 2026
Problem #0525
Level Level 21
Solved By 580
Languages C++, Python
Answer 44.69921807
Length 403 words
geometryanalytic_mathlinear_algebra

Problem Statement

This archive keeps the full statement, math, and original media on the page.

An ellipse $E(a, b)$ is given at its initial position by equation: $\dfrac {x^2} {a^2} + \dfrac {(y - b)^2} {b^2} = 1$

The ellipse rolls without slipping along the $x$ axis for one complete turn. Interestingly, the length of the curve generated by a focus is independent from the size of the minor axis: $$F(a,b) = 2 \pi \max(a,b)$$

Problem illustration

This is not true for the curve generated by the ellipse center. Let $C(a, b)$ be the length of the curve generated by the center of the ellipse as it rolls without slipping for one turn.

Problem animation

You are given $C(2, 4) \approx 21.38816906$.

Find $C(1, 4) + C(3, 4)$. Give your answer rounded to $8$ digits behind the decimal point in the form $ab.cdefghij$.

Problem 525: Rolling Ellipse

Mathematical Foundation

Theorem (Ellipse Arc Length). The arc length of the ellipse x2a2+y2b2=1\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1 from parameter 00 to θ\theta is

s(θ)=∫0θa2sin⁡2t+b2cos⁡2t dt=a E(θ∣e2)s(\theta) = \int_0^{\theta} \sqrt{a^2 \sin^2 t + b^2 \cos^2 t}\, dt = a \, E(\theta \mid e^2)

where e=1−b2/a2e = \sqrt{1 - b^2/a^2} is the eccentricity and E(ϕ∣m)E(\phi \mid m) is the incomplete elliptic integral of the second kind with parameter mm.

Proof. Parameterize the ellipse as r(t)=(acos⁡t,bsin⁡t)\mathbf{r}(t) = (a\cos t, b\sin t). Then r′(t)=(−asin⁡t,bcos⁡t)\mathbf{r}'(t) = (-a\sin t, b\cos t) and

∣r′(t)∣=a2sin⁡2t+b2cos⁡2t.|\mathbf{r}'(t)| = \sqrt{a^2 \sin^2 t + b^2 \cos^2 t}.

Write a2sin⁡2t+b2cos⁡2t=a2−(a2−b2)cos⁡2t=a2(1−e2cos⁡2t)a^2 \sin^2 t + b^2 \cos^2 t = a^2 - (a^2 - b^2)\cos^2 t = a^2(1 - e^2 \cos^2 t). Thus

s(θ)=a∫0θ1−e2cos⁡2t dt=a E(θ∣e2)s(\theta) = a \int_0^{\theta} \sqrt{1 - e^2 \cos^2 t}\, dt = a \, E(\theta \mid e^2)

by the definition of the incomplete elliptic integral of the second kind. □\square

Lemma (Distance from Center to Tangent). When the ellipse is tangent to a line at the point corresponding to parameter θ\theta, the perpendicular distance from the center of the ellipse to the tangent line is

h(θ)=aba2sin⁡2θ+b2cos⁡2θ.h(\theta) = \frac{ab}{\sqrt{a^2 \sin^2 \theta + b^2 \cos^2 \theta}}.

Proof. The tangent line to the ellipse at the point (acos⁡θ,bsin⁡θ)(a\cos\theta, b\sin\theta) has the equation

xcos⁡θa+ysin⁡θb=1.\frac{x \cos\theta}{a} + \frac{y \sin\theta}{b} = 1.

The distance from the origin to this line is

h=1cos⁡2θ/a2+sin⁡2θ/b2=abb2cos⁡2θ+a2sin⁡2θ.h = \frac{1}{\sqrt{\cos^2\theta / a^2 + \sin^2\theta / b^2}} = \frac{ab}{\sqrt{b^2 \cos^2\theta + a^2 \sin^2\theta}}.

□\square

Theorem (Center Trajectory). When the ellipse has rotated so that the contact point is at parameter θ\theta, the center of the ellipse is located at

Xc(θ)=s(θ)−(a2−b2)sin⁡θcos⁡θa2sin⁡2θ+b2cos⁡2θ,Yc(θ)=aba2sin⁡2θ+b2cos⁡2θ.X_c(\theta) = s(\theta) - \frac{(a^2 - b^2)\sin\theta\cos\theta}{\sqrt{a^2\sin^2\theta + b^2\cos^2\theta}}, \quad Y_c(\theta) = \frac{ab}{\sqrt{a^2\sin^2\theta + b^2\cos^2\theta}}.

Proof. The rolling constraint requires that the arc length along the ellipse from the initial contact point to the current contact point equals the distance traveled along the xx-axis. The center is displaced from the contact point on the line by a horizontal offset (due to the tangent angle) and a vertical offset h(θ)h(\theta). The tangent vector at parameter θ\theta makes an angle α\alpha with the horizontal, where tan⁡α=−asin⁡θbcos⁡θ\tan\alpha = -\frac{a\sin\theta}{b\cos\theta} (after appropriate sign conventions). The horizontal displacement of the center from the contact point on the line is −h(θ)sin⁡α-h(\theta)\sin\alpha. Combining with the rolling constraint xcontact=s(θ)x_{\text{contact}} = s(\theta) and computing h(θ)sin⁡αh(\theta)\sin\alpha yields the stated formula for Xc(θ)X_c(\theta). □\square

Theorem (Arc Length of Center Path). The arc length of the center’s trajectory over one complete revolution (θ∈[0,2π]\theta \in [0, 2\pi]) is

L=∫02π(dXcdθ)2+(dYcdθ)2 dθ.L = \int_0^{2\pi} \sqrt{\left(\frac{dX_c}{d\theta}\right)^2 + \left(\frac{dY_c}{d\theta}\right)^2}\, d\theta.

This integral does not admit a closed-form expression in terms of standard functions and must be evaluated numerically.

Proof. The arc length formula for a parametric curve (Xc(θ),Yc(θ))\bigl(X_c(\theta), Y_c(\theta)\bigr) is standard. The integrand involves compositions of trigonometric functions and square roots of rational expressions in sin⁡θ,cos⁡θ\sin\theta, \cos\theta with parameters a,ba, b, which cannot be reduced to elementary functions or standard elliptic integrals. □\square

Editorial

An ellipse rolls along the x-axis. Track the center’s path (elliptic trochoid). We compute dX_c/dtheta and dY_c/dtheta by differentiation. Finally, adaptive Gauss-Kronrod quadrature.

Pseudocode

Compute dX_c/dtheta and dY_c/dtheta by differentiation
Adaptive Gauss-Kronrod quadrature

Complexity Analysis

  • Time: O(N)O(N) where NN is the number of quadrature points used by the adaptive integration. Typically N=O(1/ϵ)N = O(1/\epsilon) for tolerance ϵ\epsilon with Gauss-Kronrod rules.
  • Space: O(N)O(N) for the recursion stack and function evaluations in adaptive quadrature; O(1)O(1) for fixed-point quadrature.

Answer

44.69921807\boxed{44.69921807}

Code

Each problem page includes the exact C++ and Python source files from the local archive.

C++ project_euler/problem_525/solution.cpp
#include <bits/stdc++.h>
using namespace std;

// Rolling ellipse: compute center path and arc length

// Numerical integration using Simpson's rule
double simpson(function<double(double)> f, double a, double b, int n) {
    double h = (b - a) / n;
    double s = f(a) + f(b);
    for (int i = 1; i < n; i += 2) s += 4 * f(a + i * h);
    for (int i = 2; i < n; i += 2) s += 2 * f(a + i * h);
    return s * h / 3.0;
}

// Arc length of ellipse from 0 to theta
double arc_length(double a, double b, double theta) {
    auto integrand = [a, b](double t) {
        return sqrt(a * a * sin(t) * sin(t) + b * b * cos(t) * cos(t));
    };
    return simpson(integrand, 0, theta, 10000);
}

// Circumference of ellipse
double circumference(double a, double b) {
    return arc_length(a, b, 2 * M_PI);
}

int main() {
    double a = 2.0, b = 1.0;

    cout << fixed << setprecision(8);
    cout << "Ellipse a=" << a << ", b=" << b << endl;
    cout << "Circumference = " << circumference(a, b) << endl;

    // Compute center path
    int N = 10000;
    vector<double> X(N), Y(N);

    for (int i = 0; i < N; i++) {
        double theta = 2.0 * M_PI * i / (N - 1);

        // Arc length up to theta
        double s = arc_length(a, b, theta);

        // Height of center
        double denom = sqrt(a * a * sin(theta) * sin(theta) + b * b * cos(theta) * cos(theta));
        double h = a * b / denom;

        // Tangent angle
        double tx = -a * sin(theta);
        double ty = b * cos(theta);
        double alpha = atan2(ty, tx);

        // Center offset from contact
        double dx_ell = -a * cos(theta);
        double dy_ell = -b * sin(theta);

        double rot = -alpha + M_PI / 2.0;
        double cr = cos(rot), sr = sin(rot);

        X[i] = s + dx_ell * cr - dy_ell * sr;
        Y[i] = abs(dx_ell * sr + dy_ell * cr);
    }

    // Compute arc length of center path
    double total_arc = 0;
    for (int i = 1; i < N; i++) {
        double dx = X[i] - X[i-1];
        double dy = Y[i] - Y[i-1];
        total_arc += sqrt(dx * dx + dy * dy);
    }

    cout << "Center path arc length = " << total_arc << endl;

    return 0;
}