7
$\begingroup$

I wanted to confirm the value of the integral

$$\frac12\int_{\partial\Bbb D}\frac{\sin z}{\cosh z-1}\, dz$$

where $\partial\Bbb D$ is the boundary of the disk of radius $1$. Thus I had written the code

Integrate[With[{z = E^(I t)}, (I z Sin[z])/(2 Cosh[z] - 2)], {t, 0, 2 Pi}]

what found the wrong result of zero. Using NIntegrate instead of Integrate it approach the correct answer, what is $2\pi i$. This seems a bug, right? Or Im doing something wrong?

P.S.: I have confirmed the same result on 11.2 and 11.3 versions of Wolfram Mathematica.


ACTUALIZATION: this was fixed on version 12.

$\endgroup$
5
  • $\begingroup$ Oh, I am deeply sorry. I deleted my post. Now I claim the opposite: Looks buggy to me. $\endgroup$ Commented Apr 2, 2018 at 20:58
  • $\begingroup$ no problem @Henrik, you are welcome $\endgroup$
    – user44169
    Commented Apr 2, 2018 at 21:37
  • $\begingroup$ What is your version of the system? Evaluating the above integral it yields 2 I Pi not zero, at least in 10.3. $\endgroup$
    – Artes
    Commented Apr 3, 2018 at 1:15
  • $\begingroup$ On my MMA 10.2 gives 2 I Pi $\endgroup$ Commented Apr 3, 2018 at 20:34
  • 1
    $\begingroup$ This appears to be an issue in Limit, or is at least consistent with the fact that Limit gets a wrong result for the antiderivative when approaching the origin from the right. $\endgroup$ Commented Apr 3, 2018 at 21:09

2 Answers 2

2
$\begingroup$

The symbolic integral is evaluated correctly:

f[t] = Integrate[With[{z = E^(I t)}, (I z Sin[z])/(2 Cosh[z] - 2)], t]
 1/4 I (-E^(-I E^(I t)) Hypergeometric2F1[-I, 1, 1 - I, E^E^(I t)]
 + E^(I E^(I t)) Hypergeometric2F1[I, 1, 1 + I, E^E^(I t)]
 - (1/2 - I/2) E^((1 - I) E^(I t)) Hypergeometric2F1[1, 1 - I, 2 - I, E^E^(I t)]
 + (1/2 + I/2) E^((1 + I) E^(I t)) Hypergeometric2F1[1, 1 + I, 2 + I, E^E^(I t)]
 + 2 I Coth[E^(I t)/2] Sin[E^(I t)])
Plot[{Re[f[t]], Im[f[t]]}, {t, 0, 2 Pi}]

enter image description here

f[t] /. {t -> N[2 Pi]}
-0.446818 + 3.14159 I
f[t] /. {t -> 0.00001}
-0.446818 - 3.14158 I

But the symbolic Limit of f[t] as $t \rightarrow 0^{+}$ is incorrect:

Limit[ f[t], t -> 0, Direction -> "FromAbove"]
1/8 E^-I ( -2 I Hypergeometric2F1[-I, 1, 1 - I, E]
           +2 I E^(2 I) Hypergeometric2F1[I, 1, 1 + I, E] 
           -(1 + I) E Hypergeometric2F1[1, 1 - I, 2 - I, E] 
           -(1 - I) E^(1 + 2 I) Hypergeometric2F1[1, 1 + I, 2 + I, E] 
           -4 E^I Coth[1/2] Sin[1])
N[%]
-0.446818 + 3.14159 I
$\endgroup$
3
  • $\begingroup$ mmm... this seems strange... Using the residue theorem it value must be $2\pi i$, and the graph of the integral doesn't seems to show that it cancels. $\endgroup$
    – user44169
    Commented Apr 2, 2018 at 21:54
  • $\begingroup$ The graph shows that the contour integral is $2 \pi i$, in agreement with the residue theorem. $\endgroup$
    – ulvi
    Commented Apr 3, 2018 at 1:18
  • $\begingroup$ Well, You should rather evaluate Plot[ReIm[f[t]], {t, -2 Pi, 2 Pi}, PlotStyle -> Thick, Evaluated -> True, AspectRatio -> Automatic] $\endgroup$
    – Artes
    Commented Apr 3, 2018 at 1:26
5
$\begingroup$

Quite a common problem with symbolic integrals is caused by an arbitrary choice of a complex function branch and in general it cannot be chosen to match any calculation. Therefore such inconsistencies shouldn't be classified as bugs. One could find many similar problems on this site. Behind the scene the system encounters the branch cut issue and this can be found in the documentation page of Hypergeometric2F1:

  • Hypergeometric2F1[a,b,c,z] has a branch cut discontinuity in the complex z plane running from 1 to Infinity.

Namely, calculating the indeterminate integral (all the following functions are evaluated in version 10.3) we obtain the result in terms of the hypergeometric function:

f[t_] = Integrate[(I E^(I t) Sin[E^(I t)])/(-2 + 2 Cosh[E^(I t)]), t]
1/4 I (-E^(-I E^(I t)) Hypergeometric2F1[-I, 1, 1 - I, E^E^(I t)]
 + E^(I E^(I t)) Hypergeometric2F1[I, 1, 1 + I, E^E^(I t)]
 - (1/2 - I/2) E^((1 - I) E^(I t)) Hypergeometric2F1[1, 1 - I, 2 - I, E^E^(I t)]
 + (1/2 + I/2) E^((1 + I) E^(I t)) Hypergeometric2F1[1, 1 + I, 2 + I, E^E^(I t)] 
 + 2 I Coth[E^(I t)/2] Sin[E^(I t)])  

and evaluating f[2Pi] - f[0] one finds (incorrectly) it is 0.

Plot[ReIm[f[t]], {t, -2 Pi, 2 Pi}, PlotStyle -> Thick, Evaluated -> True,
                                   AspectRatio -> Automatic]

enter image description here

However being aware of the issue we can find the correct value:

FullSimplify[ Limit[f[2 Pi - t] - f[0 + t], t -> 0, Direction -> -1]]
 2 I Pi

Sometimes Mathematica yields incorrect results in specific versions of the system, while it works fine in another versions, see e.g. Symbolic integration error where ver. 10.0.0 provided incorrect value, while it has been fixed in newer versions. The problem at hand seems to involve a reverse issue, the newest version provides a wrong value.

By a direct calculation in v. 10.3 I get the correct result of the integral:

Integrate[(I E^(I t) Sin[E^(I t)])/(-2 + 2 Cosh[E^(I t)]), {t, 0, 2 Pi}]
2 I Pi 

This can be also found from the residue theorem:

Reduce[ Cosh[z] - 1 == 0 && Abs[z] <= 1, z]
z == 0
int = 2 Pi I Residue[1/2 Sin[z]/(Cosh[z] - 1), {z, 0}]
2 I  Pi 

One can find it also using a different contour (using the Cauchy integral theorem), e.g.:

FullSimplify[ Integrate[(Sin[z])/(2 Cosh[z] - 2), {z, 1 + I, -1 + I, -1 - I, 1 - I, 1 + I}]]
2 I Pi

It takes more than 1 minute to evaluate because of a quite involved symbolic result hidden behind FullSimplify.

Concluding, this issue is not a bug, but rather a common inappropriate usage of the computer system.

$\endgroup$
8
  • 1
    $\begingroup$ Well, there seems to be a bug in calculating the symbolic limit of the hypergeometric function as $z \rightarrow 1^+$ (even though this is on the branch cut); see my answer above. $\endgroup$
    – ulvi
    Commented Apr 3, 2018 at 1:20
  • $\begingroup$ No, this is a branch cut issue, evaluate e.g. f[t] /. {t -> -0.00001} $\endgroup$
    – Artes
    Commented Apr 3, 2018 at 1:24
  • 1
    $\begingroup$ Yes, there is a discontinuity in f[t] at $t = 0$. But the limit from above at 0 is still well defined, and is equal to $-0.446818 -\pi i$; Mathematica evaluates this limit symbolically as $-0.446818 + \pi i$. $\endgroup$
    – ulvi
    Commented Apr 3, 2018 at 1:28
  • 1
    $\begingroup$ Compute N[Limit[f[t], t -> 0, Direction -> "FromAbove"]]. In 11.3 the answer is wrong. $\endgroup$
    – ulvi
    Commented Apr 3, 2018 at 1:49
  • 1
    $\begingroup$ There have been crucial changes in Limit in 11.3, the OP also claims that Integrate[With[{z = E^(I t)}, (I z Sin[z])/(2 Cosh[z] - 2)], {t, 0, 2 Pi}] yields 0 which in 10.3 yields 2 I Pi. Therefore it is plausible that there is also something wrong behind Integrate in 11.3 $\endgroup$
    – Artes
    Commented Apr 3, 2018 at 2:18

Your Answer

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