0

I have an integral

$$\int_{a2}^{a1}\frac{dx}{\sqrt{(a1 -x)(a2 - x)(a3 - x)}}$$

And I'm trying to integrate it with

F[u] = (u1 - u)*(u2 - u)*(u3 - u)

L = Integrate[1/Sqrt[F[u]], {u, u1, u2}]

But it won't run. Any ideas why?

Roberto_1986
  • 157
  • 5
  • Does this have a closed-form formula? –  Mar 10 '22 at 22:14
  • Not sure. It doesn't evaluate – Roberto_1986 Mar 10 '22 at 22:32
  • Yes, but that's my question. Why were you expecting an analytic answer from Mathematica? Is there a formula from a book or something? Or were you just wondering IF this has an analytic solution and wanted Mathematica to find it? –  Mar 10 '22 at 22:34
  • Well I know it relates to elliptic integrals and that's about it – Roberto_1986 Mar 10 '22 at 22:42
  • @kcr It is an elliptic integral. So yes it has a closed form expression in terms of elliptic functions. – TimRias Mar 10 '22 at 22:54
  • Plug in values for u1, u2, u3, a1, a2 and I get a result in terms of elliptic integrals. – Bill Watts Mar 10 '22 at 23:09
  • Maybe if you make just the right assumptions, you can get away without specifying values. – Bill Watts Mar 10 '22 at 23:10
  • 2
    I answered many similar questions and you should examine them all carefully, e.g. 1, 2, 3 this list can be continued. – Artes Mar 10 '22 at 23:11
  • 2
    Read also 4, 5, 6, 7. – Artes Mar 10 '22 at 23:15
  • 2
    And it can be expressed automatically if you prescribe appropriate numbers insted of symbolic (unknown) constants, e.g. Integrate[1/Sqrt[(1 - u) (2 - u) (3 - u)], {u, 1, 2}] yields -2 I EllipticK[-1] – Artes Mar 10 '22 at 23:24
  • @mmeent yes, I know. that was not the point. –  Mar 10 '22 at 23:42
  • to build a bit upon the arguments given by @Artes compare this Integrate[1/Sqrt[(1 - u) (2 - u) (2 - u)], {u, 1, 2}] and this Integrate[1/Sqrt[(1 - u) (2 - u) (1 - u)], {u, 1, 2}] against Integrate[1/Sqrt[(1 - u) (2 - u) (3 - u)], {u, 1, 2}] or Integrate[1/Sqrt[(1 - u) (2 - u) (4 - u)], {u, 1, 2}] –  Mar 10 '22 at 23:43
  • 2
    final comment: thanks @Artes for providing the links. the answers are thoroughly detailed. very useful stuff. (+1) to all. –  Mar 10 '22 at 23:46
  • @kcr I'm affraid the system will remove these upvotes since they were all in a minute from one user, anyway thanks. I wrote these posts for the readers' benefits. – Artes Mar 11 '22 at 00:14
  • @Artes I'll check back again later. Good answers should be upvoted and accepted every time :-) –  Mar 11 '22 at 00:17
  • @kcr that's not what I asked. I asked how to evaluate that with symbolic limits. – Roberto_1986 Mar 11 '22 at 08:36
  • I understood what you asked. However, from the excellent answers in the links provided by @Artes and from the examples I provided in the comments it should be obvious that the integral CANNOT be performed without any assumptions. Think of it this way: if you could do the integral for any values of $u_{1,2,3}$ without assuming anything, I would not have been able to find an example where the integral does not converge. Is that clear now? –  Mar 11 '22 at 15:54

3 Answers3

6
Clear["Global`*"]

$Version

(* "13.0.1 for Mac OS X x86 (64-bit) (January 28, 2022)" *)

F[u_] = (u1 - u)*(u2 - u)*(u3 - u);

Assuming[{u3 > u2 > u1},
 L = Integrate[1/Sqrt[F[u]], {u, u1, u2}] // Simplify]

(* (2 (-9 I EllipticK[(u1 - u3)/(u1 - u2)] + 
   EllipticK[(-u2 + u3)/(u1 - u2)]))/Sqrt[-u1 + u2] *)

EDIT: As pointed out in a comment by Akku14, there appears to be a problem with this result.

Looking at the specific case of {u1 -> 2, u2 -> 3, u3 -> 4}

L2 = L /. {u1 -> 2, u2 -> 3, u3 -> 4}

(* 2 (EllipticK[-1] - 9 I EllipticK[2]) *)

Using arbitrary precision to avoid machine-precision calculations,

N[L2, 15]

(* -20.9764604343370 - 23.5985179886291 I *)

Comparing with integration after substitution,

L3 = Integrate @@ ({1/Sqrt[F[u]], {u, u1, u2}} /. 
     {u1 -> 2, u2 -> 3, u3 -> 4})

(* -2 I EllipticK[-1] *)

N[L3, 15]

(* -2.62205755429212 I *)

This result agrees with direct numeric integration

L3 == NIntegrate[##, 
    WorkingPrecision -> 15] & @@ ({1/Sqrt[F[u]], {u, u1, u2}} /. {u1 -> 2, 
    u2 -> 3, u3 -> 4})

(* True *)

This indicates a problem with the general result, L. I will submit this to Wolfram Tech Support (CASE:4924364. Response: "It does appear that Integrate is returning an incorrect result in this case. I have forwarded an issue report to our developers with the information you provided").

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • Just a comment that I think is noteworthy: you can get an answer for other ordering than $u_3 > u_2 > u_1$ as well. At least in some cases. For instance Integrate[1/Sqrt[(2 - u) (3 - u) (1 - u)], {u, 2, 3}] evaluates to 2 EllipticK[-1]. I am on v12. –  Mar 10 '22 at 23:48
  • May be a typo or a bug in 13.0.1 @BobHanlon ? NIntegrate says the result is (2 (-I EllipticK[(u1 - u3)/(u1 - u2)] + EllipticK[(-u2 + u3)/(u1 - u2)]))/ Sqrt[-u1 + u2] /. {u1 -> 2, u2 -> 3, u3 -> 4} // N without the factor 9 at the beginning. NIntegrate[1/Sqrt[F[u] /. {u1 -> 2, u2 -> 3, u3 -> 4}], Evaluate[{u, u1, u2} /. {u1 -> 2, u2 -> 3, u3 -> 4}]] yield 0. - 2.62206 I . – Akku14 Mar 11 '22 at 08:01
4

If the variables can be ordered such that $0 < \mathtt{u3} < \mathtt{u2} < \mathtt{u} < \mathtt{u1}$ , then the integral gives :

Integrate[1/Sqrt[(u1 - u)*(u2 - u)*(u3 - u)], {u, u2, u1}, 
Assumptions -> {0 < u3 < u2 < u1}]

(* (2EllipticK[-((u1 - u2)/(u2 - u3))])/Sqrt[u2 - u3] )

If you don't like the negative argument of the elliptic integral, apply the imaginary modulus transformation to get:

(2/Sqrt[u1 - u3])*EllipticK[(u1 - u2)/(u1 - u3)]

which seems correct as seen in the plot:

u1 = 3; u2 = 2; Plot[{NIntegrate[1/Sqrt[(u1 - u)*(u2 - u)*(u3 - u)], {u, u2, u1}], 
(2/Sqrt[u1 - u3])*EllipticK[(u1 - u2)/(u1 - u3)]}, {u3, 0, u2}, 
PlotStyle -> {Blue, Dashed}]

plot

Edit: The case $\mathtt{u2} < \mathtt{u1} < \mathtt{u3}$ gives

Integrate[1/Sqrt[(u1 - u)*(u2 - u)*(u3 - u)], {u, u2, u1}, 
Assumptions -> {0 < u2 < u1 < u3}]
(* (2*(EllipticK[(u1 - u3)/(u1 - u2)] - 
 I*EllipticK[(-u2 + u3)/(u1 - u2)]))/Sqrt[u1 - u2] *)

a pure imaginary result and

the case $\mathtt{u2} < \mathtt{u3} < \mathtt{u1}$ contains a singularity within the integration range at $\mathtt{u3}$,that requires more attention...

u1 = 3; u2 = 2; Plot[{Abs[
NIntegrate[1/Sqrt[(u1 - u)*(u2 - u)*(u3 - u)], {u, u2, u1}]], 
Abs[(2*(EllipticK[(u1 - u3)/(u1 - u2)] - 
I*EllipticK[(-u2 + u3)/(u1 - u2)]))/Sqrt[u1 - u2]]},    {u3,u2, u1}],

because the numerical integration becomes unstable.

noisy plot

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Andreas
  • 3,297
  • 1
  • 5
  • 12
0

The machinery I presented in this answer can be used to obtain a result in terms of the Carlson symmetric integrals. To wit,

With[{cc = {{a1, -1}, {a2, -1}, {a3, -1}, {1, 0}}, 
      pairs = {{1, 2}, {1, 3}, {2, 3}}, x = a2, y = a1}, 
     -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]] // Simplify
   -π CarlsonRK[a1 - a3, a2 - a3]

where we immediately obtain an answer in terms of the complete Carlson integral of the first kind, CarlsonRK[]. As a numerical example:

With[{a1 = 2, a2 = 3, a3 = -5},
     {N[-π CarlsonRK[a1 - a3, a2 - a3], 25], 
      NIntegrate[1/Sqrt[(a1 - x) (a2 - x) (a3 - x)], {x, a2, a1}, WorkingPrecision -> 25]}]
   {-1.148105728739062085568889, -1.148105728739062085568889}

This can of course be expressed in terms of the usual arithmetic-geometric mean (AGM):

-π CarlsonRK[a1 - a3, a2 - a3] /. CarlsonRK[x_, y_] :> 1/ArithmeticGeometricMean[Sqrt[x], Sqrt[y]]
   -(π/ArithmeticGeometricMean[Sqrt[a1 - a3], Sqrt[a2 - a3]])

which can then be expressed in terms of EllipticK[]:

Assuming[a1 > a3 && a2 > a3, FullSimplify[FunctionExpand[%]]]
   -((4 EllipticK[(Sqrt[a1 - a3] - Sqrt[a2 - a3])^2/
                  (Sqrt[a1 - a3] + Sqrt[a2 - a3])^2])/
     (Sqrt[a1 - a3] + Sqrt[a2 - a3]))
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574