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?
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?
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").
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
(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
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}]
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.
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]))
u1, u2, u3, a1, a2and I get a result in terms of elliptic integrals. – Bill Watts Mar 10 '22 at 23:09Integrate[1/Sqrt[(1 - u) (2 - u) (3 - u)], {u, 1, 2}]yields-2 I EllipticK[-1]– Artes Mar 10 '22 at 23:24Integrate[1/Sqrt[(1 - u) (2 - u) (2 - u)], {u, 1, 2}]and thisIntegrate[1/Sqrt[(1 - u) (2 - u) (1 - u)], {u, 1, 2}]againstIntegrate[1/Sqrt[(1 - u) (2 - u) (3 - u)], {u, 1, 2}]orIntegrate[1/Sqrt[(1 - u) (2 - u) (4 - u)], {u, 1, 2}]– Mar 10 '22 at 23:43