2
$\begingroup$

Integrate[(1/Sqrt[(x + 1)^2 + 1])*(1/Sqrt[1 + x^2]), {x, 0, 1}]

yields

-2*(EllipticF[ArcCsc[Sqrt[11/5 + (2*I)/5]], 5] + EllipticF[ArcSin[Sqrt[2/5 + I/5]], 5])

which evaluates to -2.4665 - 4.44089*10^-16 I.

But on the other hand,

NIntegrate[(1/Sqrt[(x + 1)^2 + 1])*(1/Sqrt[1 + x^2]), {x, 0, 1}]

yields 0.502323.

I suspect the issue is related to branch cuts, so that the original answer might be correct if the multi-valued complex functions assumed the "correct" values, whereas N computes the expression using the "incorrect" values/branches. How can we fix this? More generally, I'd like to have an analytical result for

Integrate[(1/Sqrt[(x + a)^2 + b^2])*(1/Sqrt[c^2 + x^2]), {x, 0, d}]

assuming a, b, c, d > 0, which yields the correct real-valued answer when evaluated numerically. Is there a way to do this? Mathematica returns a complicated expression when I evaluate this, but again the numerical values are not correct.

$\endgroup$
5
  • $\begingroup$ it looks like a bug. Maple gives same analytical result as NIntegrate. Screen shot: i.sstatic.net/UXHm45ED.png $$\frac{4 \boldsymbol{\mathit{K}}\! \left(\frac{\sqrt{5}\, \sqrt{2}}{\sqrt{5+3 \sqrt{5}}}\right)}{\sqrt{5}+1}-\frac{2 F\! \left(\frac{\sqrt{5}+3}{2 \sqrt{5+\sqrt{5}}}, \frac{\sqrt{5}\, \sqrt{2}}{\sqrt{5+3 \sqrt{5}}}\right)}{\sqrt{5}+1}-\frac{2 F\! \left(\frac{2 \sqrt{5}+4}{\sqrt{50+10 \sqrt{5}}}, \frac{\sqrt{5}\, \sqrt{2}}{\sqrt{5+3 \sqrt{5}}}\right)}{\sqrt{5}+1} $$ Where $K$ is Elliptick and $F$ is the EllipticF functions. The above numerically is 0.502322695 $\endgroup$
    – Nasser
    Commented Aug 8 at 4:31
  • $\begingroup$ @Nasser Does Maple evaluate the more general integral I gave at the bottom of the post? $\endgroup$
    – WillG
    Commented Aug 8 at 4:37
  • 1
    $\begingroup$ Adding assumption worked. Result is too large to post. Will make screen shot. THis is partial screen shot of the output. Too large to show. But it worked when adding assumptions i.sstatic.net/OlhEYsK1.png This is the command used integrand := (1/sqrt((x + a)^2 + b^2))*(1/sqrt(c^2 + x^2)); result:=int(integrand,x=0..d) assuming a>0,d>0,c>0,d>0; $\endgroup$
    – Nasser
    Commented Aug 8 at 4:45
  • $\begingroup$ Best I can tell, the path singularity for the antiderivative is located at (-1 + Sqrt[5])/2. But Limit fails to correctly assess the upper value at the jump. I'm not sure why this is although possibly it is a matter of a time constraint stopping the attempt before it finishes. $\endgroup$ Commented Aug 9 at 18:11
  • 2
    $\begingroup$ I reported this as a bug. $\endgroup$ Commented Aug 9 at 19:22

3 Answers 3

2
$\begingroup$

Since at least version 11, the complex elliptic integrals and Jacobi elliptic functions are so buggy that they are useless.

One is working in an algebraic field with square roots and equalities of squares. So all results should at least be correct by their squares. The linear forms need special scrutinity, they contain tons of complex square roots.

$$\left( \int \frac{1}{\sqrt{x^2+1} \ \sqrt{(x+1)^2+1}} \, dx\right)^2 == 4\ F \left(\left.\sin ^{-1}\left(\sqrt{\frac{(3-i)+(1-2 i) x}{(5-5 i)+5 x}}\right)\right| 5\right)^2 $$

 D[2 EllipticF[
    ArcSin[ Sqrt[((3-I) + (1-2 I) x)/((5-5 I) + 5 x)]], 5 ],x]^-2 \\
   FullSimplify

   (1 + x^2) (2 + x (2 + x))

So its plain wrong.

A modulus of $5>1$ is not allowed directly, it should be converted to its inverse by a Landen transform.

$$(1+x^2)(1+ k^2 x^2) \frac{1}{dx^2} \to (1+\frac{1}{k^2} y )(1+y^2)\ \frac{k^2}{dy^2} $$

The relevant formula is

$$ F(\varphi , \ m)\ = \ \frac{1}{\sqrt{m}} \ F\left(\sin ^{-1}\left(\sqrt{m} \ \sin (\varphi )\right)\ , \ \frac{1}{m}\right)$$

(Gradshteyn/Rhyzik 8.127 p 908 converted to m = k^2)

So just adapt the constants until the square of the derivative comes right

  D[I/b EllipticF[I ArcSinh[b  x], 1/b^2], x]^-2 

 (1 + x^2) (1 + b^2 x^2)
$\endgroup$
2
$\begingroup$
$Version
(*"14.1.0 for Microsoft Windows (64-bit) (July 16, 2024)"*)

Integrate[(1/Sqrt[(x + 1)^2 + 1])*(1/Sqrt[1 + x^2]), {x, 0, 1}] 
(*Can't compute gives INPUT. Weakness! *)

Integrate[1/(Sqrt[(x + a)^2 + b^2] Sqrt[c^2 + x^2]), {x, 0, d}, 
Assumptions -> {a > 0, b > 0, c > 0, d > 0}]
(*Gives incorrect answer!*)

With Rubi package:

<< Rubi`
L = Int[1/(Sqrt[(x + a)^2 + b^2] Sqrt[c^2 + x^2]), x] // Simplify;
Solution = (L /. x -> d) - (L /. x -> 0) // Simplify(*Shorter answer than Maple solution *)

(*(1/((b^2 - a Sqrt[-b^2]) (a^2 - b^2 + 2 a Sqrt[-b^2] + c^2)^(
 1/4)))(a^4 + b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
a^2 (2 b^2 + c^2))^(
 1/4) ((1/Sqrt[(
c^2)])(a + Sqrt[-b^2])^(3/2) Sqrt[(
b^2 (-a^2 + b^2 - 2 a Sqrt[-b^2]) c^2)/((a + Sqrt[-b^2])^2 (a^4 + 
   b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
   a^2 (2 b^2 + c^2)) (1 + ((a^2 + b^2) Sqrt[
    a^2 - b^2 + 2 a Sqrt[-b^2] + c^2])/((a + Sqrt[-b^2]) Sqrt[
    a^4 + b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
     a^2 (2 b^2 + c^2)]))^2)] (1 + ((a^2 + b^2) Sqrt[
   a^2 - b^2 + 2 a Sqrt[-b^2] + c^2])/((a + Sqrt[-b^2]) Sqrt[
   a^4 + b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
    a^2 (2 b^2 + c^2)])) EllipticF[
 2 ArcTan[(
   Sqrt[a^2 + b^2] (a^2 - b^2 + 2 a Sqrt[-b^2] + c^2)^(1/4))/(
   Sqrt[a + 
     Sqrt[-b^2]] (a^4 + b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
      a^2 (2 b^2 + c^2))^(1/4))], 
 1/2 (1 + ((a + Sqrt[-b^2]) (a^2 + b^2 + c^2))/(
    Sqrt[a^2 - b^2 + 2 a Sqrt[-b^2] + c^2] Sqrt[
     a^4 + b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
      a^2 (2 b^2 + c^2)]))] - (1/(
 Sqrt[c^2 + d^2] Sqrt[
 a^2 + b^2 + 2 a d + d^2]))(a + Sqrt[-b^2] + d)^(3/2) Sqrt[
 a^2 + b^2 + a d + 
 Sqrt[-b^2] d] (1 + (
  Sqrt[a^2 - b^2 + 2 a Sqrt[-b^2] + 
    c^2] (a^2 + b^2 + a d + Sqrt[-b^2] d))/(
  Sqrt[a^4 + b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
    a^2 (2 b^2 + c^2)] (a + Sqrt[-b^2] + d))) Sqrt[(
 b^2 (-a^2 + b^2 - 2 a Sqrt[-b^2]) (c^2 + d^2))/((a^4 + b^4 - 
   b^2 c^2 + 2 a Sqrt[-b^2] c^2 + a^2 (2 b^2 + c^2)) (a + 
   Sqrt[-b^2] + d)^2 (1 + (
   Sqrt[a^2 - b^2 + 2 a Sqrt[-b^2] + 
     c^2] (a^2 + b^2 + (a + Sqrt[-b^2]) d))/(
   Sqrt[a^4 + b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
     a^2 (2 b^2 + c^2)] (a + Sqrt[-b^2] + d)))^2)]
 EllipticF[2 ArcTan[((a^2 - b^2 + 2 a Sqrt[-b^2] + c^2)^(1/4) Sqrt[
    a^2 + b^2 + (a + Sqrt[-b^2]) d])/((a^4 + b^4 - b^2 c^2 + 
      2 a Sqrt[-b^2] c^2 + a^2 (2 b^2 + c^2))^(1/4) Sqrt[
    a + Sqrt[-b^2] + d])], 
 1/2 (1 + ((a + Sqrt[-b^2]) (a^2 + b^2 + c^2))/(
    Sqrt[a^2 - b^2 + 2 a Sqrt[-b^2] + c^2] Sqrt[
     a^4 + b^4 - b^2 c^2 + 2 a Sqrt[-b^2] c^2 + 
      a^2 (2 b^2 + c^2)]))])*)
  
 f[a_, b_, c_, d_] := Evaluate[(L /. x -> d) - (L /. x -> 0)];
 g[a_, b_, c_, d_] := NIntegrate[1/(Sqrt[(x + a)^2 + b^2] Sqrt[c^2 + x^2]), {x, 0, d}];
 {f[1, 1, 1, 1] // N, g[1, 1, 1, 1]}
 (*{0.502323 - 1.11022*10^-15 I, 0.502323}*)
  
$\endgroup$
6
  • $\begingroup$ Thanks for the Rubi recommendation, I had never used it before. However, Mathematica is going absolutely crazy with the way it is unstable under small changes to the evaluation assumptions and variables used... $\endgroup$
    – WillG
    Commented Aug 8 at 16:21
  • $\begingroup$ $Version (*13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)*) $\endgroup$
    – WillG
    Commented Aug 8 at 16:21
  • $\begingroup$ L = Int[1/(Sqrt[(x + a)^2 + b^2] Sqrt[c^2 + x^2]), x] // Simplify; f[a_, b_, c_, d_] := Evaluate[(L /. x -> d) - (L /. x -> 0)]; f[1, 1, 1, 1] // N (* 0.502323 + 0. I *) $\endgroup$
    – WillG
    Commented Aug 8 at 16:22
  • $\begingroup$ Now add an assumption in the first line: L = Simplify[Int[1/(Sqrt[(x + a)^2 + b^2]*Sqrt[c^2 + x^2]), x], Element[{a, b, c}, PositiveReals]]; Keep next two lines the same. (* -0.502323 + 0. I *) $\endgroup$
    – WillG
    Commented Aug 8 at 16:26
  • 1
    $\begingroup$ It's the buggiest behavior I've ever seen in Mathematica! $\endgroup$
    – WillG
    Commented Aug 8 at 16:30
2
$\begingroup$

I usually try a path integral in such cases:

Integrate[(1/Sqrt[(x + 1)^2 + 1])*(1/Sqrt[1 + x^2]), {x, 0, I/2, 1}]
(*
2 (EllipticF[ArcCsc[Sqrt[17/13 - (6 I)/13]], 5] - 
    EllipticF[ArcSin[Sqrt[2/5 + I/5]], 5]) - 
 2 EllipticF[ArcSin[1/5 Sqrt[11 - 2 I]], 5] - 
 2 EllipticF[ArcSin[1/5 Sqrt[17 + 6 I]], 5] + (
 4 EllipticK[1/5])/Sqrt[5]
*)

% // N

(*  0.502323 + 0. I  *)

The result of FullSimplify[]:

(*
-2 (EllipticF[ArcCsc[Sqrt[11/5 + (2 I)/5]], 5] + 
    EllipticF[ArcSin[Sqrt[2/5 + I/5]], 5]) +
  (4 EllipticK[1/5])/Sqrt[5]
*)

I was using V14.1.0, if it matters.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.