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!
