Possible bug with contour integration

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.


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