My original question is to calculate the indefinite integral
$$I(x) = \int \operatorname{sech}(x) \cos(x) \,\Bbb dx.$$
However, I have been unable to find a closed form expression with elementary functions. To get an idea of how the integral might behave, I asked Wolfram Alpha to calculate the direct integral from $-\infty$ to $\infty$. W.A. happily gave me:
$$\int_{-\infty}^{\infty} \operatorname{sech}(x) \cos(x) \,\Bbb dx = \pi \operatorname{sech}\frac{\pi}{2}.$$
I don’t know how to calculate this direct integral either. W.A. does not tell me how it calculated this either. I would love to know how W.A. did that calculation and if there is any way I can harness it to calculate a cleaner indefinite integral.
$$I(x) = \int\cos (x)\, \text{sech}(x) \,dx=\int \frac{e^{(1-i) x}+e^{(1+i) x}}{e^{2 x}+1}\,dx$$
Use $$\int \frac{e^{a x}}{e^{b x}+1}\, dx=\frac{e^{a x} }{a}\,\, \, _2F_1\left(1,\frac{a}{b};\frac{a+b}{b};-e^{b x}\right)$$ where appears the Gaussian hpergeometric function.
As a result
$$\color{blue}{I(x)=\frac{1+i}{2} \,e^x }$$ $$\color{blue}{\left(e^{-i x} \, _2F_1\left(\frac{1-i}{2},1;\frac{3-i}{2};- e^{2 x}\right)-i e^{i x} \, _2F_1\left(\frac{1+i}{2},1;\frac{3+i}{2};- e^{2 x}\right)\right)}$$