# Contour integral around complex plane

I have this integral where it is singular at the points $$p=\{0,\pi i\}$$, where the solid contour is given in the image below. My goal is to find the integral in the range $$[0,\infty]$$ (the horizontal solid contour) OR in the range $$[\pi i,0]$$ (the vertical solid contour) but the integral is divergent. My strategy is to use the solid contour and close the contour using the dashed lines then since there are no poles inside the closed contour, the integral in the closed contour is zero. Since the vertical dashed line contribution to the integral vanishes as $$p=r \rightarrow \infty$$ as I will show below, the rest of the contour can be related.

d = 2;
func[p_] := 1/(Cosh[p/2] Sinh[p/2])

Residue[func[p], {p, 0}]
2

Residue[func[p], {p, Pi I}]
-2

vert1[a_] = Integrate[func[p], {p, a I, Pi I - a I}, Assumptions -> a > 0] (*vertical solid line*)
ConditionalExpression[4 Log[Cot[a/2]], 2 a < \[Pi] || \[Pi]/2 < a < \[Pi]]

vert2[r_] = Integrate[func[p], {p, r + 0 I, r + Pi I}, Assumptions -> r > 0](*vertical dashed line*)
4 Log[Coth[r/2]]

Limit[vert2[r], r -> Infinity]
0

horz2[r_, a_] = Integrate[func[p], {p, a + Pi I, r + Pi I}, Assumptions -> {r > 0, a > 0}](*horizontal dashed line*)
2 Log[Coth[r/2] Tanh[a/2]]

Limit[horz2[r, a], r -> Infinity]
2 Log[Tanh[a/2]]


The contribution of $$C_1$$ and $$C_2$$ given the residues are $$-i \pi$$ and $$i \pi$$ respectively so they just cancel. Note that the indentation is given by a small radius $$a$$ around the poles. For the straight line contours, given that in my code I integrated from bottom to up and left to right, and since the contour is counter-clockwise, I need to put a minus sign in the results in my code. Thus,

$$lim_{p\rightarrow \infty} \int_0^p \frac{1}{\cosh(p/2)\sinh(p/2)} dp + lim_{a\rightarrow 0}\Bigg(-4 \log(\cot(a/2)) - 2 \log(\tanh(a/2))\Bigg) = 0$$

$$lim_{p\rightarrow \infty} \int_0^p \frac{1}{\cosh(p/2)\sinh(p/2)} dp = lim_{a\rightarrow 0}\Bigg(4 \log(\cot(a/2)) + 2 \log(\tanh(a/2)) \Bigg)$$

As you see, the limit $$a \rightarrow 0$$ produces divergences on both terms. Is there anyway to solve this? I tested $$a \rightarrow 1$$, they produce different values so maybe there is a way to make the divergences cancel?

NOTE: I have edited the question to a more sensible and simpler one as compared to the previous. I apologize for the need to edit. If you have any other suggestion on closing the contour to find the correct solution I would greatly appreciate it!

The integral divergence in the range $$[0,\infty]$$

d = 2;
func[p_] :=
1/(Cosh[p/2]^(2/d) Tanh[p/2] Sqrt[
1 - (Cosh[p/2]^(4 - 4/d) Tanh[p/2]^2)/(-0.419602)]) //
Rationalize[#, 0] &;
Integrate[func[p], {p, r, ∞}, Assumptions -> r > 0]
Limit[%, r -> 0, Direction -> "FromAbove"]



$$\log \left(\frac{\sqrt{81193660402}-2 \sqrt{8517255573}}{2 \sqrt{8517255573}+\sqrt{81193660402}}\right)-\log \left(\frac{\sqrt{40596830201 \cosh (r)-6527807909}-2 \sqrt{8517255573} \cosh \left(\frac{r}{2}\right)}{2 \sqrt{8517255573} \cosh \left(\frac{r}{2}\right)+\sqrt{40596830201 \cosh (r)-6527807909}}\right)$$

∞

• BTW, It seems that if we use such contour,we can't use Residue, but we can also calculate the 1/4 circle integral in complex plane by(clockwise)
Integrate[I*r*Exp[I*r*t]*func[p] /. p -> Exp[I*r*t], {t, π/2, 0},
Assumptions -> r > 0]


And let r->0.

and calculate the line integral in imaginary axis by

Integrate[func[p], {p, π/2*I, r*I},
Assumptions -> 0 < r < π/2]

• Confirm the above line integral and Residue
NIntegrate[
I*r*Exp[I*r*t]*func[p] /. p -> Exp[I*r*t] /. r -> 1, {t, 0,
2 π}]/(2 π*I)//Chop
Residue[func[p], {p, 0}]


2.0

2

• NIntegrate[func[p], {p, 0, \[Infinity]}, AccuracyGoal -> 3, PrecisionGoal -> 3, Method -> "LocalAdaptive"] produces 74.1973. Jul 23 at 4:10
• @user64494 NIntegrate[func[p], {p, .0000000001, \[Infinity]}, AccuracyGoal -> 3, PrecisionGoal -> 3, Method -> "LocalAdaptive"] get 8780.57 Jul 23 at 4:15
• Series[Rationalize[ 1/(Cosh[p/2]^(2/d) Tanh[p/2] Sqrt[ 1 - (Cosh[p/2]^(4 - 4/d) Tanh[p/2]^2)/(-0.419602)])], {p, 0, 2}] results in $\frac{2}{p}-\frac{1709801 p}{2517612}+O\left(p^3\right)$, confirming the divergence. Jul 23 at 4:16
• @cvgmt I'm sorry, I have had a major update on my question which makes the problem more sensible and I think the solution becomes easier to handle but still not sure how. Jul 23 at 16:16