# Integrals of the square root of a cubic polynomial

Say I have a function

$$V(x)=A(x-x_1)(x-x_2)(x-x_3)$$

where $x_1$, $x_2$, $x_3$ are the three roots in increasing order and $A$ is positive. Clearly $V(x)$ is positive at large $x > x_3$, negative between $x_2$ and $x_3$, and so on.

Now, say I wish to evaluate

$$\int_{x_2}^{x_3}\sqrt{-V(x)}\mathrm dx$$

How do I do it?

-

This is an elliptic integral and can be expressed in terms of the complete elliptic integral of the second kind.

-

Well, you can't integrate it in terms of elementary functions like the arctangent or the logarithm in general (unless there is some special configuration of your roots). Having an integrand that contains the square root of a cubic will result in the use of so-called "elliptic integrals".

I'll evaluate the integral explicitly here for reference; most of the current computing environments seem to be unable to return reasonable expressions for elliptic integrals.

For this solution, I will assume $A=1$; you can multiply the result of the following by $\sqrt{A}$ afterwards.

Now, we consider first the indefinite integral (let's worry about the limits later)

$$\int\sqrt{(x_3-x)(x-x_2)(x-x_1)}\;\mathrm dx,\qquad x_3 > x_2 > x_1$$

The first step here is to perform an appropriate Möbius (rational) transformation, which is equivalent to projecting your cubic to a quartic or quadratic, which hopefully has a nice factorization. I'll skip the details on how to obtain it, and point out that the required substitution is

$$x=\frac{x_2-x_1\frac{x_3-x_2}{x_3-x_1}u}{1-\frac{x_3-x_2}{x_3-x_1}u}$$

Performing this substitution yields

$$\frac{(x_3-x_2)^2(x_2-x_1)^2}{(x_3-x_1)\sqrt{x_3-x_1}}\int\frac1{\left(1-\frac{x_3-x_2}{x_3-x_1}u\right)^3}\sqrt{\frac{u(1-u)}{1-\frac{x_3-x_2}{x_3-x_1}u}}\mathrm du$$

It is at this point that we require the services of the Jacobian elliptic functions $\mathrm{sn}(v|m)$, $\mathrm{cn}(v|m)$, and $\mathrm{dn}(v|m)$. The elliptic function identities pertinent to this problem are the two Pythagorean relations

$$\mathrm{cn}^2(v|m)+\mathrm{sn}^2(v|m)=1,\qquad \mathrm{dn}^2(v|m)+m\,\mathrm{sn}^2(v|m)=1$$

and the differential relation

$$\frac{\mathrm d}{\mathrm dv}\mathrm{sn}(v|m)=\mathrm{cn}(v|m)\mathrm{dn}(v|m)$$

thus, letting $u=\mathrm{sn}^2(v|m)$ (and letting $\Delta$ be the constant in front to avoid clutter), we have

$$2\Delta\int\frac{\mathrm{sn}(v|m)\mathrm{cn}(v|m)\mathrm{dn}(v|m)}{\left(1-\frac{x_3-x_2}{x_3-x_1}\mathrm{sn}^2(v|m)\right)^3}\sqrt{\frac{\mathrm{sn}^2(v|m)(1-\mathrm{sn}^2(v|m))}{1-\frac{x_3-x_2}{x_3-x_1}\mathrm{sn}^2(v|m)}}\mathrm dv$$

and if we let $m=\frac{x_3-x_2}{x_3-x_1}$, both Pythagorean relations can be applied to yield

$$2\Delta\int\frac{\mathrm{sn}^2(v|m)\mathrm{cn}^2(v|m)}{\mathrm{dn}^6(v|m)}\mathrm dv$$

At this point, we now insert the proper limits for the definite integral by performing the inverses of the last two transformations on the limits $x=x_2$ and $x=x_3$. The new limits are seen to be $v=0$ and $v=K(m)=K\left(\frac{x_3-x_2}{x_3-x_1}\right)$, where $K(m)$ is the complete elliptic integral of the first kind. The definite integral is now

$$2\Delta\int_0^{K(m)}\frac{\mathrm{sn}^2(v|m)\mathrm{cn}^2(v|m)}{\mathrm{dn}^6(v|m)}\mathrm dv$$

Using formula 361.18 in Byrd/Friedman (and after much tears and algebra), we finally arrive at the result

\begin{align*} \frac2{15}\sqrt{x_3-x_1}&\left(2(x_1^2+x_2^2+x_3^2-x_1 x_2-x_2 x_3-x_1 x_3)E\left(\frac{x_3-x_2}{x_3-x_1}\right)-\right.\\ &\left.\quad(x_2-x_1)(x_3-x_1+x_2-x_1)K\left(\frac{x_3-x_2}{x_3-x_1}\right)\right) \end{align*}

where $E(m)$ is the complete elliptic integral of the second kind.

Byrd/Friedman would be one of the best references on this subject; they have a comprehensive listing of formulae for reducing elliptic integrals to the Legendre-Jacobi forms.

-
In a sense, this is one of the few cases where having a closed form is better than resorting to numerical integration, since both complete elliptic integrals can be computed relatively quickly via the arithmetic-geometric mean, which is much faster than using a numerical quadrature method. –  Guess who it is. May 5 '11 at 7:28