Elliptic Integrals: Mathematica and Gradshteyn and Ryzhik

In Gradshteyn and Ryzhik, (specifically starting with the section 3.13) there are several results involving integrals of polynomials inside square root. These are given in terms of combinations of elliptic integrals. See for instance:

where $$F[\alpha, p]$$ is the elliptic integral of first kind. I tried to reproduce the first result above in Mathematica (version 12) but failed. I would appreciate if anyone could point out what I am doing wrong. My first attempt is

Integrate[1/Sqrt[(a - x) (b - x) (c - x)], {x, -Infinity, u}, Assumptions -> { a > b > c >= u}]

which returned no result:

Then I tried without integration limits, and take the limits after

Integrate[1/Sqrt[(a - x) (b - x) (c - x)], x, Assumptions -> { a > b > c}]

giving:

taking now the upper limit and simplifying

Simplify[Limit[(2 (a - x)^(3/2) Sqrt[(b - x)/(a - x)] Sqrt[(c - x)/(a - x)]
EllipticF[ArcSin[Sqrt[a - b]/Sqrt[a - x]], (a - c)/(a - b)])/(Sqrt[a - b] Sqrt[(a - x) (-b + x) (-c + x)]), x -> u], Assumptions -> { a > b > c >= u}]

giving:

whereas the integral vanishes when $$x\rightarrow -\infty$$. Clearly, the above result given by Mathematica differs from the Gradshteyn and Ryzhik's. Two results match if the substitution: $$b \rightarrow c$$, $$c \rightarrow b$$ is made but this would then be at odds with the condition: $$a > b > c$$.

• If one uses the assumption as follows, Assumptions -> {a > b > c > u > 0} already the definite integral works with the result (2 EllipticF[ArcSin[Sqrt[(a - b)/(a - u)]], (a - c)/(a - b)])/Sqrt[a - b]. However, this result is, indeed, not the one you from the Handbook. I did not manage to convert one result into another. Dec 11 '19 at 13:38
• Assumptions -> {a > b > c > u} is sufficient. Dec 11 '19 at 16:13

Mathematica can perform the 3.31 integral, if Assumptions is changed from { a > b > c >= u} to {a > b > c > u}.

s = Integrate[1/Sqrt[(a - x) (b - x) (c - x)], {x, -Infinity, u},
Assumptions -> {a > b > c > u}]
(* (2 EllipticF[ArcSin[Sqrt[(a - b)/(a - u)]], (a - c)/(a - b)])/Sqrt[a - b] *)

To compare this with the expression as given in Gradshteyn and Ryzhik (7th edition, 2007), it is important to realize that this compendium defines the second argument of Elliptic Integral F differently than from that in Mathematica. Comparing the second example under "Possible Issues" in the EllipticF documentation with 11.112 #2 of Gradshteyn and Ryzhik indicates that p^2 (see question) should be used as the second argument of the Gradshteyn and Ryzhik expression when employing the Mathematica representation of EllipticF; i. e.,

gr = 2 EllipticF[ArcSin[Sqrt[(a - c)/(a - u)]], (a - b)/(a - c)]/Sqrt[a - c]

which differs from s only by the interchange of b and c. But, it is obvious from the integrand of the integral above that the relative order of {a, b, c} is irrelevant. As verification, I have evaluated s and gr numerically for several parameters, for instance,

vals = Thread[{a, b, c, u} -> Reverse@Sort@RandomReal[{-5, 5}, 4]]
(* {a -> 3.47807, b -> 2.65797, c -> -1.04855, u -> -1.17253} *)

Chop[gr /. vals]
(* 1.38108 *)

Chop[s /. vals]
(* 1.38108 *)

and in each case they are the same and agree with the original integral evaluated numerically.

NIntegrate[1/Sqrt[(a - x) (b - x) (c - x)] /. vals, {x, -Infinity, u /. vals},
Method -> {Automatic, "SymbolicProcessing" -> False}]
(* 1.38108 *)

Therefore, the apparent discrepancy between the result in Gradshteyn and Ryzhik (7th edition, 2007) and the corresponding Mathematica result is due merely to differences in notation.

• Thanks a lot for the explanation. I feel the relative order of a, b, c must not be overlooked because the integrand has branch cuts. I still don't quite get why we should not get the same answer without having to make the substitution $b\rightarrow c, \,\, c \rightarrow b$. Have you tried to the verify the second problem above ? I ran into similar problem there. Mathematica integrates the second expression alright but the first argument of $F$ turns out to be $\gamma$ instead of $\beta$. Dec 12 '19 at 9:34
• @user91411 I am confident that the order of a, b, c makes no difference in 3.131 #1. Do you mean 3.13#2 when referring to "the second problem above"? Dec 19 '19 at 1:22
• If the ordering makes no difference, should not the final expression for the integral be symmetric under any permutation of $a, \, b,\, c$ ? Because the integrand has already an exchange symmetry for $a,\, b, \, c$. And yes I meant 3.131 problem #2. Dec 19 '19 at 9:34
• Evaluating Chop[s /. vals] with the values of b and c interchanged yields the same numerical value given in my answer above. The same is true, if b and c are interchanged in the numerical integration. This is true for every set of random values I have tried.. Dec 19 '19 at 10:08

Since TheDoctor mentioned my package, I'll present how to use CarlsonRF[] in conjunction with DLMF formula 19.29.4 to evaluate the three cases in Gradshteyn and Ryzhik's formula 3.131. Because CarlsonRF[] is Orderless, it is especially suitable for exploiting the inherent permutation symmetry in the given integrals.

Load the package first:

<<Carlson`

For case 1, this combines 19.29.4 with 19.29.6:

With[{cc = {{a, -1}, {b, -1}, {c, -1}, {1, 0}}, pairs = {{1, 2}, {1, 3}, {2, 3}}},
2 Apply[CarlsonRF,
Table[With[{g1 = cc[[id]], g2 = cc[[Complement[Range[4], id]]]},
Apply[Times, Sqrt[-g2[[All, -1]]] Sqrt[g1.{1, u}]] +
Apply[Times, Sqrt[-g1[[All, -1]]] Sqrt[g2.{1, u}]]],
{id, pairs}]^2]]
2 CarlsonRF[a - u, b - u, c - u]

An example:

With[{c = 3, b = 5, a = 9, u = 1, prec = 25},
{NIntegrate[1/Sqrt[(a - x) (b - x) (c - x)], {x, -∞, u}, WorkingPrecision -> prec],
N[2 CarlsonRF[c - u, b - u, a - u], prec]}]
{0.9688576532724524632309018, 0.9688576532724524632309018}

Case 2 and case 3 use 19.29.5 instead:

With[{cc = {{a, -1}, {b, -1}, {c, -1}, {1, 0}},
pairs = {{1, 2}, {1, 3}, {2, 3}}, x = c, y = u},
2 Apply[CarlsonRF,
Table[With[{g1 = cc[[id]], g2 = cc[[Complement[Range[4], id]]]},
(Apply[Times, Sqrt[g1.{1, x}] Sqrt[g2.{1, y}]] +
Apply[Times, Sqrt[g2.{1, x}] Sqrt[g1.{1, y}]])/(x - y)],
{id, pairs}]^2]]
2 CarlsonRF[(a - c) (b - c)/(c - u), (b - c) (a - u)/(c - u), (a - c) (b - u)/(c - u)]

With[{cc = {{a, -1}, {b, -1}, {-c, 1}, {1, 0}},
pairs = {{1, 2}, {1, 3}, {2, 3}}, x = u, y = c},
2 Apply[CarlsonRF,
Table[With[{g1 = cc[[id]], g2 = cc[[Complement[Range[4], id]]]},
(Apply[Times, Sqrt[g1.{1, x}] Sqrt[g2.{1, y}]] +
Apply[Times, Sqrt[g2.{1, x}] Sqrt[g1.{1, y}]])/(x - y)],
{id, pairs}]^2]]
2 CarlsonRF[(a - c) (b - c)/(-c + u), (b - c) (a - u)/(-c + u), (a - c) (b - u)/(-c + u)]

Here's an example for case 3:

With[{c = 3, b = 5, a = 9, u = 4, prec = 25},
{NIntegrate[1/Sqrt[(a - x) (b - x) (x - c)], {x, c, u}, WorkingPrecision -> prec],
N[2 CarlsonRF[(a - c) (b - c)/(u - c), (b - c) (a - u)/(u - c), (a - c) (b - u)/(u - c)],
prec]}]
{0.6623825396975077898366125, 0.6623825396975077898366125}

(Someday, when I am much less occupied with other pressing stuff, I'll work on adding functionality for facilitating the symbolic use of the Carlson integrals. But not today.)

You may find DLMF Chapter 19 on Elliptic Integrals, authored by B. C. Carlson interesting and helpful. Carlson introduced symmetric standard integrals that simplify many aspects of theory, applications, and numerical computation of Elliptic Integrals.

And there is also the Carlson package implementing the symmetric elliptic integrals.