## Elliptic integrals, I

This has tripped me up in the past, so let’s write it down.

Imagine we have an ellipse

$\displaystyle\frac{x^2}{a^2} + \displaystyle\frac{y^2}{b^2} = 1$

Let’s say we have some parametrization (x(t), y(t)) of the ellipse and we want to convert it into a unit-speed parametrization. We can do this by composing with the inverse of the function s(t) that tells us how much arclength our parametrization has traced out on [0, t], which is given by

$s(t) = \displaystyle\int_0^t \sqrt{x'(\tau)^2 + y'(\tau)^2} \, d\tau$

Differentiating the equation cutting out our ellipse, we have

$\displaystyle\frac{2}{a^2} \; x \, x' + \displaystyle\frac{2}{b^2} \; y \, y' = 0$

Let’s solve for y’ so that we can eliminate it from the integral:

$y' = \displaystyle \frac{-b^2}{a^2} \, \frac{x}{y} \, x'$

Squaring,

$(y')^2 = \displaystyle \frac{b^4}{a^4} \, \frac{x^2}{y^2} \, (x')^2$

Plugging this in, we have

$s(t) = \displaystyle\int_0^t \sqrt{x'(\tau)^2\left[1 + \frac{b^4}{a^4} \, \frac{x^2}{y^2}\right]} \, d\tau = \displaystyle\int_0^t |x'(\tau)| \, \sqrt{1 + \frac{b^4}{a^4} \, \frac{x^2}{y^2}} \; d\tau$

Let’s eliminate y from the equation as well. From the defining equation of the ellipse, we have

$\displaystyle y^2 = b^2\left(1 - \frac{x^2}{a^2}\right)$

Plugging this in, we get

$s(t) = \displaystyle\int_0^t |x'(\tau)| \, \sqrt{1 + \frac{b^4}{a^4} \left[ \frac{x^2}{b^2\left(1 - \displaystyle\frac{x^2}{a^2}\right)}\right]} \; d\tau$

Now let’s assume that our parametrization has $x(\tau) = 0$ and $x'(\tau) > 0$ for small values of $\tau$ — for instance, we could start the parametrization from the top of the ellipse and go counter-clockwise. Then, for $x(t)$ in the second quadrant, we can write

$s(t) = \displaystyle\int_0^{x(t)} \sqrt{1 + \frac{b^4}{a^4} \left[ \frac{x^2}{b^2\left(1 - \displaystyle\frac{x^2}{a^2}\right)}\right]} \; dx$

$= \displaystyle\int_0^{x(t)} \, \sqrt{1 + \frac{b^2 x^2}{a^4 - a^2 x^2}} \; dx$

$= \displaystyle\int_0^{x(t)} \, \sqrt{1 + \frac{b^2 x^2}{a^4 - a^2 x^2}} \; dx$

$= \displaystyle\int_0^{x(t)} \, \sqrt{\frac{a^4 - (a^2 - b^2)x^2}{a^2(a^2 - x^2)}} \; dx$

$= \displaystyle\int_0^{x(t)} \, \frac{\sqrt{a^2 - \left(1 - \displaystyle\frac{b^2}{a^2}\right)x^2}}{\sqrt{a^2 - x^2}} \; dx$

Putting $k^2 := 1 - \displaystyle\frac{b^2}{a^2}$, this becomes

$s(t) = \displaystyle\int_0^{x(t)} \frac{\sqrt{a^2 - k^2 x^2}}{\sqrt{a^2 - x^2}} \; dx$