\[ I \da \int_\RR {e^{x\over 2}\over 1+e^x}\dx .\]
Solution
Replication: find \(b\) such that \(f(z) = f(z+ib)\) and use a rectangle. \[ f(z+ib) = {e^{z\over 2}e^{ib\over 2} \over 1 + e^{ib}e^z} = e^{ib\over 2} {e^{z\over 2} \over 1 + e^{ib}e^z } = f(z) \impliedby e^{ib} = 1 \impliedby b=2\pi ,\] in which case \[ f(z + 2\pi i) = e^{ib\over 2}f(z) = e^{2\pi i \over 2}f(z) = -f(z) .\]
So take the following rectangle where \(H_-\) is at \(2\pi i\) and \(H_+\) is at 0, with sides at \(\pm R\):
Write \(\Gamma\) for the entire contour. Note that integrating left-to-right on \(H_-\) yields \(-I\), since \(w = z+2\pi i\) for \(w\in H_-\) and \(f(w) = -f(z)\). Then reversing the orientation, going right-to-left yields \(\int_{H_i} f = I\).
Claim: the integrals over the sides \(V_{\pm}\) vanish. For the right, \[ \abs{\int_{V_+} f(z) \dz} &\leq 2\pi \sup_{t\in [0, 2\pi]} \abs{e^{R + it\over 2} \over 1 + e^{R + it} } \\ &\leq 2\pi \sup_t {\abs{ e^{R\over 2} e^{it \over 2} } \over \abs{e^{R}e^{it}} - 1} \\ &\leq 2\pi \sup_t {\abs{ e^{R\over 2} } \over \abs{e^{R}} - 1} \\ &\in \bigo(e^{- {R\over 2} }) \to 0 .\]
For the left: \[ \abs{\int_{V_-} f(z) \dz} &\leq \sup_{t\in [0, 2\pi] } \abs{ e^{-R-it\over 2} \over 1 + e^{-R- it}} \\ &\leq \sup_{t\in [0, 2\pi]}\abs{e^{-R\over 2} e^{-it\over 2}} \\ &\leq \sup_{t\in [0, 2\pi]}\abs{e^{-R\over 2}} \\ &\in \bigo(e^{- {R\over 2} }) \to 0 ,\] where we’ve thrown away positive terms in the denominator, which only makes this quantity larger.
Finding the poles within \(\Gamma\): the poles occur when the denominator vanishes, i.e. when \(e^z = -1\); writing \(z = x + iy\), \(e^z = e^x e^{iy} = -1\) forces \(e^x = 1\) (so \(x = 0\)) and \(e^{iy} = -1\) (so \(y = (2k+1)\pi\)), giving \(z = (2k+1)\pi i\) for \(k \in \ZZ\). Exactly one falls into this contour, \(z_k = i\pi\). By the residue theorem, \[ 2\pi i \Res_{z=i\pi} f(z) = \int_\Gamma f(z) \dz = \qty{\int_{H_-} + \int_{H_+}} f = 2I \implies I = \pi i \Res_{z=i\pi } f .\] Computing this residue: \[ \pi i \Res_{z=i\pi }f(z) &= \pi i \lim_{z\to i\pi} { (z-i\pi) e^{z\over 2}\over e^z + 1} \\ &\eqLH \pi i \lim_{z\to i\pi} {e^{z\over 2} \over e^z} \\ &= \pi i e^{-i\pi \over 2} \\ &= \pi .\]