2
$\begingroup$

Trying to answer this interesting question Principal value from two different axis I observed a problem using Nintegrate:

The function func[p_] := 1/(Sinh[p/2] Sqrt[Cosh[p]]) has a pol at p==0.

The residue of this point evaluates to

Residue[func[z], {z, 0}] (*2*)
Limit[func[z] z, z -> 0] (*2*)

The result might be confirmed by integrating along a path in the complex plane which contains the pol. For example integrating along a square path

NIntegrate[func[z], {z, 1, I, -1, -I, 1}]/(2 Pi I) (*2*)

evaluates correct value , whereas integrating along a circle

NIntegrate[func[ Exp[I \[CurlyPhi] ]]/(2 Pi I), {\[CurlyPhi], 0, 2 Pi}]  (*~0*)

gives a message NIntegrate failed to converge... and a wrong result 0!

What's wrong with this last integration?

How to modify to get the correct result?

Thanks!

$\endgroup$
2
  • $\begingroup$ Alternate way (equivalent to Method -> "Trapezoidal": With[{n = 64}, First@Fourier[ Table[ func[Exp[I \[CurlyPhi]]]*Exp[I \[CurlyPhi]], {\[CurlyPhi], Most@Subdivide[0., 2 Pi, n]}] ]/Sqrt[n] ] $\endgroup$
    – Michael E2
    Jul 25, 2021 at 17:20
  • $\begingroup$ @MichaelE2 Thank you for this nice answer. Amazingly this "simple" method evaluates the expected result. $\endgroup$ Jul 25, 2021 at 17:53

1 Answer 1

4
$\begingroup$

You forgot the derivative (see Residue of monomial here):

NIntegrate[func[Exp[I \[CurlyPhi]]]/(2 Pi I)*I*Exp[I \[CurlyPhi]], {\[CurlyPhi], 0, 2 Pi}]

1.99993 - 1.11022*10^-16 I

$\endgroup$
7
  • $\begingroup$ I assumed the residum theorem in its common form. Why the derivative? $\endgroup$ Jul 25, 2021 at 17:10
  • $\begingroup$ Additionally see "For continuous functions" in Wiki. $\endgroup$
    – user64494
    Jul 25, 2021 at 17:27
  • $\begingroup$ I'm still convinced that the simple residuum definition (without the derivative) is the commonly accepted form of the residuum theorem. Thanks for your effort.. $\endgroup$ Jul 25, 2021 at 18:00
  • $\begingroup$ When you change variable, you need to include a derivative term to account for the fact that dz!=d[\CurlyPhi] $\endgroup$
    – mikado
    Jul 25, 2021 at 18:12
  • 1
    $\begingroup$ @UlrichNeumann user64494 means the last formula in the wiki section. The derivative is what you get when you substitute $z=e^{i\phi}$ into the $dz$ of the contour integral $\int_\gamma f(z)\,dz$. BTW, Method -> "Trapezoidal" numerical convergence properties than "GlobalAdaptive" on this sort of integral (see Trefethen & Weideman). $\endgroup$
    – Michael E2
    Jul 25, 2021 at 18:12

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