Show that $\int_{-\infty}^{\infty} \frac{\cos (\theta) e^{\theta y}}{2 \cosh(\pi y/2)} y dy=\tan (\theta)$.
How one should approach an integral like this.
Lots of ways - but trying to find an antiderivative isn't one of them.
We need $|\theta| < \frac{\pi}{2}$ for the integral to converge, so that the $\cosh$ in the denominator will be large enough to overwhelm the $e^{\theta y}$ in the numerator.
First thought: complex analysis. Close the loop around some large chunk of the complex plane, treat it as a contour integral, and apply the residue theorem. Looking at our function, in the imaginary direction, $\cosh\left(\frac{\pi}{2}y\right)$ and $e^{\theta y}$ are both periodic. That suggests we use a rectangle that doesn't go too high. From $\cosh(t+i\pi) = -\cosh t$, we integrate around a rectangle with height $2$. The vertical segments at $\pm R$ go to zero as $R\to\infty$, and $$\int_{-\infty}^{\infty}\frac{\cos\theta\cdot e^{\theta y}}{2\cosh\frac{\pi y}{2}}\cdot y\,dy - \int_{-\infty}^{\infty}\frac{\cos\theta\cdot e^{\theta (y+2i)}}{2\cosh\frac{\pi (y+2i)}{2}}\cdot (y+2i)\,dy = 2\pi i\text{Res}_{z=i}(f)=2\pi i\frac{i\cos\theta e^{i\theta}}{\pi\sinh\frac{\pi i}{2}}$$ $$I(\theta) + e^{2i\theta}I(\theta) +2i\cos\theta e^{2i\theta}\int_{-\infty}^{\infty} \frac{e^{\theta y}}{2\cosh\frac{\pi y}{2}}\,dy = 2i\cos\theta e^{i\theta}$$ $$2\cos(\theta)I(\theta) = 2i\cos\theta\left(1-e^{i\theta}\int_{-\infty}^{\infty}\frac{e^{\theta y}}{2\cosh\frac{\pi y}{2}}\,dy\right)$$ Now, we need to evaluate that integral with a $\cosh$ in the denominator but no multiplication by $y$. How? Just do the same thing again - integrate around the same rectangular contour. $$\int_{-\infty}^{\infty}\frac{e^{\theta y}}{2\cosh\frac{\pi y}{2}}\,dy - \int_{-\infty}^{\infty}\frac{e^{\theta (y+2i)}}{2\cosh\frac{\pi (y+2i)}{2}}\,dy = 2\pi i\text{Res}_{z=i}(g) = 2\pi i\frac{e^{i\theta}}{\pi i}$$ $$\left(1+e^{2i\theta}\right)\int_{-\infty}^{\infty}\frac{e^{\theta y}}{2\cosh\frac{\pi y}{2}}\,dy = 2e^{i\theta}$$ $$\int_{-\infty}^{\infty}\frac{e^{\theta y}}{2\cosh\frac{\pi y}{2}}\,dy = \frac1{\cos\theta}$$ Substituting that in, $$I(\theta) = i\left(1-e^{i\theta}\cdot\frac1{\cos\theta}\right) = i\left(1-\frac{\cos\theta+i\sin\theta}{\cos\theta}\right)=\tan\theta$$ Done.
OK, I did a bunch of things without really explaining them. Let's go through them. First, the residue theorem is an enormously useful calculation tool from complex analysis, allowing us to calculate exact values for many integrals without finding antiderivatives. I've linked a part of the article with an example of such a calculation.
In this case, we use a rectangular contour with endpoints at $-R,R,R+2i,-R+2i$ and then let $R\to\infty$. On the vertical segments from $R$ to $R+2i$ and $-R+2i$ to $-R$, the function we're integrating at is comparable to $\frac{Re^{\pm R\theta}}{e^{R\theta}}$, which decays exponentially. In the limit, those vertical segments don't affect the integral. On the horizontal segments, we traverse the boundary counterclockwise, so the segment from $-R$ to $R$ is traversed "forward" with a $+$ sign and the segment from $-R+2i$ to $R+2i$ is traversed "backward" with a $-$ sign.
Then, we calculate the residues at the poles of the function we're integrating. The only way we can get a pole here is for that denominator $\cosh (\pi y/2) = \cos(i\pi y/2)$ to be zero - which, inside our contour, happens at exactly one point $y=i$. The calculation shortcut I used for the residue: evaluate the other parts at that point, divide by the derivative of the term in the denominator that goes to zero.
Also, I named the integral we wanted to find $I(\theta)$. That's just a notational convenience, but it is a definition that needs to be written down somewhere.
There are likely other approaches that work. If someone wants to try them, be my guest.