Calculate the following integral $\int_{0}^{\pi}\cot(t-i)dt$ Calculate the following integral $\int_{0}^{\pi}\cot(t-i)dt$
My try is :
$\cot(t-i)=\frac{\frac{e^{i(t-i)}+e^{-i(t-i)}}{2}}{\frac{e^{i(t-i)}-e^{-i(t-i)}}{2i}}=i\frac{e^2z^2+1}{e^2z^2-1},z=e^{it}$
$$\int_{0}^{\pi}\cot(t-i)dt=\int_{|z|=1,\operatorname{Im}(z)>0}i\frac{e^2z^2+1}{e^2z^2-1}dz$$ and the only singularity points are $\pm\frac{1}{\sqrt{e}}$ but if i try to use the residue theorem the singularity points are on the contour and not inside it.
any help will be welcome :)
 A: Since $\cot$ is periodic with period $\pi$, your integral is equal to $\frac12\int_0^{2\pi}\cot(t-i)\,\mathrm dt$. But\begin{align}\int_0^{2\pi}\cot(t-i)\,\mathrm dt&=\int_0^{2\pi}\frac{\cos(t-i)}{\sin(t-i)}\,\mathrm dt\\&=\int_0^{2\pi}\frac{\cos(t)\cosh(1)+\sin(t)\sinh(1)i}{\sin(t)\cosh(1)-\cos(t)\sinh(1)i}\,\mathrm dt\\&=\int_0^{2\pi}R(\cos(t),\sin(t))\,\mathrm dt,\end{align}if you define$$R(x,y)=\frac{x\cosh(1)+y\sinh(1)i}{y\cosh(1)-x\sinh(1)i}.$$Now, let$$f(z)=\frac1zR\left(\frac{z+z^{-1}}2,\frac{z-z^{-1}}{2i}\right).$$Then$$\int_0^{2\pi}R(\cos(t),\sin(t))\,\mathrm dt=\frac1i\int_{|z|=1}f(z)\,\mathrm dz.\tag1$$But$$f(z)=\frac{i \left(e^2 z^2+1\right)}{z \left(e^2 z^2-1\right)}$$and so the residue theorem tells us that the RHS of $(1)$ is equal to $2\pi$ times\begin{multline}\operatorname{res}\left(0,\frac{i\left(e^2 z^2+1\right)}{z\left(e^2 z^2-1\right)}\right)+\operatorname{res}\left(\frac1e,\frac{i\left(e^2 z^2+1\right)}{z\left(e^2 z^2-1\right)}\right)+\operatorname{res}\left(-\frac1e,\frac{i\left(e^2 z^2+1\right)}{z\left(e^2 z^2-1\right)}\right)=\\=-i+i+i=i.\end{multline}So,$$\int_0^{2\pi}\cot(t-i)\,\mathrm dt=2\pi i$$and therefore your integral is equal to $\pi i$.
A: METHODOLOGY $1$:  EVALUATION OF REAL AND IMAGINARY PARTS
Using the $\pi$-periodicity of the cotangent function we can write
$$\begin{align}
\int_0^\pi \cot(x-i)\,dx&=\int_{-\pi/2}^{\pi/2}\cot(x-i)\,dx\\\\
&=\int_{-\pi/2}^{\pi/2}\frac{\sin(x)\cos(x)}{\cosh^2(1)\sin^2(x)+\sinh^2(1)\cos^2(x)}\,dx\\\\
&+i\int_{-\pi/2}^{\pi/2}\frac{\sinh(1)\cosh(1)}{\cosh^2(1)\sin^2(x)+\sinh^2(1)\cos^2(x)}\,dx\\\\
&=i\sinh(2)\int_0^{\pi}\frac{1}{\cosh(2)-\cos(x)}\,dx\\\\
&=i\sinh(2)\left.\left(\frac{2\arctan\left(\frac{\tan(x/2)}{\tanh(1)}\right)}{\sqrt{1-\cosh^2(2)}}\right)\right|_{0}^{\pi}\\\\
&=i\pi
\end{align}$$
as expected.

METHODOLOGY $2$:  EVALUATION USING THE COMPLEX LOGARITHM
Note that we can write the integral of interest as
$$\begin{align}
\int_0^\pi \cot(x-i)\,dx&=\int_0^\pi \frac1{\sin(x-i)}d(\sin(x-i))\\\\
&=\int_C \frac1w\,dw
\end{align}$$
where $C$ is the contour $w=\sin(x-i)=\sin(x)\cosh(1)-i\cos(x)\sinh(1)$, $x\in[0,\pi]$.  This contour is half of an ellipse, with semi-axes $\cosh(1)$ and $\sinh(1)$, in the right-half of the $w$ plane.  Hence, we have
$$\begin{align}
\int_C \frac1w \,dw&=\log(i\sinh(1))-\log(-i\sinh(1))\\\\
&=\log(i)-\log(-i)
\end{align}$$
We can choose any branch cut for $\log(z)$ provided that it does not intersect $C$.  Any for any such choice, we have $\log(i)=i\frac\pi2+i2n\pi$ and $\log(-i)=-i\frac\pi2+2n\pi$.  Therefore, we find that
$$\int_0^\pi \cot(x-i)\,dx=i\pi$$
as expected!
A: In theory we can just integrate directly, giving $[\ln\sin(t-i)]_0^\pi=\ln\frac{\sin(\pi-i)}{\sin(-i)}=\ln(-1)=\pi i$ as per @JoséCarlosSantos's answer. Of course, there are some subtleties to this, because $\ln z$ has multiple branches in complex analysis. We can't, for example, naively do this with an upper limit of $2\pi$, as that would give an answer of $\ln1=0$ instead of twice the above result. This discrepancy is due to discontinuities in the imaginary part of$$\ln\sin(t-i)=\tfrac12\ln(\sin^2t+\sinh^21)+i\operatorname{atan2}(-\cot t\tanh1,\,1),$$and on a length-$\pi$ period of $\cot(t-i)$ the real part makes no contribution (as expected of a root of $e^z=-1$), while the imaginary part is$$i\lim_{t\to\pi^-}\operatorname{atan2}(-\cot t\tanh1,\,1)-i\lim_{t\to^+}\operatorname{atan2}(-\cot t\tanh1,\,1)=\frac{i\pi}{2}-\frac{-i\pi}{2}=i\pi.$$
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
Note that $\ds{\quad\ic \equiv \root{-1}}$ !!!.

\begin{align}
\int_{0}^{\pi}\cot\pars{t - \ic}\,\dd t & =
\int_{-\ic}^{\pi - \ic}\cot\pars{t}\,\dd t =
\int_{-\ic/\pi}^{1 - \ic/\pi}\pi\cot\pars{\pi t}\,\dd t
\\[5mm] & =
\int_{-\ic/\pi}^{1 - \ic/\pi}
\bracks{\Psi\pars{1 - t} - \Psi\pars{t}}\dd t
\\[5mm] & =
\int_{-\ic/\pi}^{1 - \ic/\pi}
\totald{}{t}\bracks{\vphantom{A^{A}}-\ln\pars{\Gamma\pars{1 - t}} - \ln\pars{\Gamma\pars{t}}}\dd t
\\[5mm] & =
-\int_{1 - \ic/\pi}^{-\ic/\pi}
\totald{}{t}\ln\pars{\vphantom{A^{A^{A}}}
\Gamma\pars{1 - t}\Gamma\pars{t}}\,\dd t
\\[5mm] & =
-\int_{-\ic/\pi}^{1 - \ic/\pi}
\totald{}{t}\ln\pars{\pi \over \sin\pars{\pi t}}\,\dd t
\\[5mm] & =
\ln\pars{\sin\pars{\pi\bracks{1 - \ic/\pi}} \over \pi} -
\ln\pars{\sin\pars{\pi\bracks{-\ic/\pi}} \over \pi}
\\[5mm] & =
\ln\pars{\sin\pars{i} \over \pi} - \ln\pars{-\sin\pars{i} \over \pi} =
\ln\pars{-1} = \bbox[15px,#ffd,border:1px solid navy]{\pi\ic}
\end{align}
