# What to do to calculate $\int_{-\pi/4}^{+\pi/4}e^{-\tan\theta}\mathrm{d}\theta$

• I have to calculate the following integral: $$A=\int_{-\pi/4}^{+\pi/4}e^{-\tan\theta}\mathrm{d}\theta.$$ What I did: Let $t=\tan\theta$. Thus, $\dfrac{\mathrm{d}t}{\mathrm{d}\theta}=1+\tan^2\theta=1+t^2.$ Therefore, $$A=\int_{-1}^{+1}\dfrac{e^{-t}}{1+t^2}\mathrm{d}t.$$ Now, I write $\dfrac{1}{1+t^2}=\sum\limits_{k=0}^{\infty}(-t^2)^k.$ And therefore, $$A=\int_{-1}^{+1}\sum\limits_{k=0}^{\infty}(-1)^k t^{2k}e^{-t}\mathrm{d}t.$$ What to do now?

• Also, what to do to calculate $$B=\int_{\pi/4}^{\pi/2}e^{-\tan\theta}\mathrm{d}\theta.$$ Should I do the same as the previous case?

Thanks.

• In $A=\int_{-1}^{+1}\dfrac{e^{-t}}{1+t^2}\mathrm{d}t.$, try putting $t=-x$ – Shubham May 22 '14 at 17:59
• this does not look nice, here is MMA output $$\frac{1}{2} i e^{-i} \left(e^{2 i} (\text{Ei}(-1-i)-\text{Ei}(1-i))-\text{Ei}(-1+i)+\text{Ei}(1+i)\right)$$ do you want to get answer in this form? or is there some other nice form? – Santosh Linkha May 22 '14 at 18:03

Along the OP's line of thought, $$A=\int_{-1}^1\frac{e^{-t}}{1+t^2}dt=\sum_{k=0}^{\infty}(-1)^k\int_{-1}^1 t^{2k}e^{-t}dt=\sum_{k=0}^{\infty}(-1)^kI_{2k}$$ $$I_{k}=\int_{-1}^{1}t^{k}e^{-t}dt=-e^{-t}t^{k}|_{-1}^1+kI_{k-1}\\ \Rightarrow I_{k}=(e-e^{-1})+kI_{k-1}=\alpha+kI_{k-1}$$ where $\alpha=e-e^{-1}$. Then, iterating we get $$I_{k}=k!\alpha S_k(1)$$ where $\displaystyle S_n(x):=\sum_{j=0}^n\frac{x^n}{n!}$ So, $$A=\sum_{k=0}^{\infty}(-1)^k(2k)! \alpha S_{2k}(1)=\alpha\sum_{k=0}^{\infty}(-1)^k(2k)!S_{2k}(1)$$ It doesn't look pretty though.

I found a fast convering series with a bit of manipulation. Note $$\int_{-\pi/4}^{\pi/4} e^{-\tan \theta} \mathrm{d}\theta = \int_{0}^{\pi/4} e^{-\tan \theta} + e^{\tan \theta} \mathrm{d}\theta = 2 \int_{0}^{1} \frac{\cosh y}{1+y^2} \mathrm{d}y$$ The first bit follows by splitting the integral and using the substitution in the negaitve integral. The last transition is done using $\frac{e^{-x}+e^x}{2} = \cosh x$ and the substitution $y \mapsto \tan \theta$. Using the series expansion for $\cosh y$ we have $$\int_{-\pi/4}^{\pi/4} e^{-\tan \theta} \mathrm{d}\theta = \int_0^{1} \left( \sum_{n=0}^\infty \frac{2}{(2k)!} \frac{y^{2k}}{1+y^2} \right) \mathrm{d}y \tag{1}$$ The integral on the right is still tough to compute, but since the integral converges fast only a few values is needed. It seems for each term added, the number of correct digits increased by 3. Using the first three terms we get the approximation $$\int_{-\pi/4}^{\pi/4} e^{-\tan \theta} \mathrm{d}\theta \sim \int \frac{2}{1+y^2} + \frac{y^2}{1+y^2} + \frac{1}{12}\frac{y^4}{1+y^2}\mathrm{d}y =1 + \frac{\pi}{4} + \frac{1}{12}\left( \frac{\pi}{4}-\frac{2}{3}\right)$$ This approximates to $1.795292455$ not far from the actual value of $1.795521284$ =) We can calculate the integral explicitly as $$\int_0^1 \frac{y^{2k}}{1+y^2} \mathrm{d}y (-1)^k\left(\frac\pi4-1+\frac13-\frac15+\dots+\frac{(-1)^k}{2k-1}\right) = (-1)^k \left( \frac{\pi}{4} + \sum_{p=1}^k\frac{(-1)^p}{2p-1}\right)$$ By again rewriting the integrand as a geometric series. Inserting this in $(1)$ and cleaning up gives $$\int_{-\pi/4}^{\pi/4} e^{-\tan \theta} \mathrm{d}\theta = \frac{\pi}{2} \left( \sum_{k=0}^\infty \frac{(-1)^k}{(2k)!} \right)+ 2 \sum_{k=1}^\infty \frac{(-1)^k}{(2k)!}\sum_{p=1}^k \frac{(-1)^{p}}{2p-1}$$ Same convergence as before, and confirms "our?" suspicion that the partial sum always is on the form $a_n \pi + b_n$, with $a_n, b_n \in \mathbb{Q}$.

Consider the transformation $t = \tan\theta$ for which the integral in question becomes \begin{align} I &= \int_{a}^{b} e^{- \tan\theta} d\theta \\ &= \int_{x}^{y} \frac{ e^{-t} \ dt}{1+t^{2}}. \end{align} where $x=\tan a$ and $y=\tan b$. Now consider \begin{align} \frac{1}{1+t^{2}} = \frac{i}{2} \left( \frac{1}{i+t} + \frac{1}{i -t} \right) \end{align} for which the integral $I$ becomes \begin{align} I &= \frac{i}{2} \int_{x}^{y} \left( \frac{e^{-t}}{i+t} + \frac{e^{-t}}{i-t} \right) \ dt \\ &= \frac{i}{2} \left[ e^{i} \ \int_{i+x}^{i+y} \frac{e^{-u} \ du}{u} - e^{-i} \ \int_{i-x}^{i-y} \frac{e^{-u} \ du}{u} \right] \\ &= \frac{i}{2} \left[ e^{i} Ei(-t-i) - e^{-i} Ei(i-t) \right]_{x}^{y} \\ &= \frac{i}{2} \left[ e^{i} \left( Ei(-\tan b - i) - Ei(-\tan a - i) \right) \right. \nonumber\\ & \hspace{15mm} \left. - e^{-i} \left( Ei(i-\tan b ) - Ei(i -\tan a) \right) \right]. \end{align} which is \begin{align} \int_{a}^{b} e^{- \tan\theta} d\theta &= \frac{i}{2} \left[ e^{i} \left( Ei(-\tan b - i) - Ei(-\tan a - i) \right) \right. \nonumber\\ & \hspace{15mm} \left. - e^{-i} \left( Ei(i-\tan b ) - Ei(i -\tan a) \right) \right]. \end{align}

In the case that $-a = b = \pi/4$ then this becomes \begin{align} \int_{-\pi/4}^{\pi/4} e^{- \tan\theta} d\theta &= \frac{i}{2} \left[ e^{i} \left( Ei(-1 - i) - Ei(1 - i) \right) \right. \nonumber\\ & \hspace{15mm} \left. - e^{-i} \left( Ei(i-1 ) - Ei(i +1) \right) \right]. \end{align} Using \begin{align} -1-i &= - \sqrt{2} e^{\pi i/4} \\ 1-i &= \sqrt{2} e^{-\pi i/4} \\ -1+i &= \sqrt{2} e^{-\pi i/4} \\ 1+i &= \sqrt{2} e^{\pi i/4} \end{align} and the series form of the Exponential integral \begin{align} Ei(x) = \gamma + \ln|x| + \sum_{k=1}^{\infty} \frac{x^{k}}{k \cdot k!} \end{align} then after some reductions it is seen that \begin{align} \int_{-\pi/4}^{\pi/4} e^{- \tan\theta} d\theta = - \frac{\pi}{2} \cos(1) - 2 \sum_{k=1}^{\infty} \frac{2^{k/2}}{k \cdot k!} \ \cos\left( \frac{k \pi}{2} +1\right) \ \sin\left( \frac{3 k \pi}{4} \right). \end{align}

In a similar manor when $b = \pi/2$ and $a = - \pi/4$ the resulting form, in series, is \begin{align} \int_{-\pi/4}^{\pi/2} e^{- \tan\theta} d\theta &= \left( \gamma + \frac{1}{2} \ln(2) \right) \sin(1) - \frac{\pi}{4} \cos(1) \nonumber\\ & \hspace{5mm} + i \sum_{k=1}^{\infty} \frac{2^{k/2}}{k \cdot k!} \ e^{\frac{k \pi i}{2}} \cos\left( \frac{k \pi}{4} + 1 \right). \end{align}

Another approach using Laplace transforms.

\begin{eqnarray*} A(x) &=&\int_{-1}^{+1}dt\frac{\exp [-xt]}{1+t^{2}} \\ \partial _{x}A(x) &=&\int_{-1}^{+1}dt\frac{-t}{1+t^{2}}\exp [-xt] \\ \partial _{x}^{2}A(x) &=&\int_{-1}^{+1}dt\frac{t^{2}}{1+t^{2}}\exp [-xt] \\ &=&\int_{-1}^{+1}dt\frac{1+t^{2}-1}{1+t^{2}}\exp [-xt]=\int_{-1}^{+1}dt\exp [-xt]-A(x) \\ &=&\frac{\exp [+x]-\exp [-x]}{x}-A(x)=\frac{2\sinh x}{x} \end{eqnarray*} \begin{eqnarray*} \partial _{x}^{2}A(x)+A(x) &=&\int_{-1}^{+1}dt\exp [-xt] \\ A(0) &=&\int_{-1}^{+1}dt\frac{1}{1+t^{2}} \\ (\partial _{x}A)(0) &=&\int_{-1}^{+1}dt\frac{t}{1+t^{2}}=0 \end{eqnarray*} Complex Laplace transform ($\Gamma$ is a straight line above and parallel to the real axis) \begin{eqnarray*} \hat{f}(z) &=&\int_{0}^{\infty }dx\exp [izx]f(x),\mathrm{{Im}}z>0 \\ f(x) &=&\frac{1}{2\pi }\int_{\Gamma }dz\exp [-izx]\hat{f}(z) \end{eqnarray*} We have, noting that $(\partial _{x}A)(0)=0$, \begin{eqnarray*} \int_{0}^{\infty }dt\exp [izx]\int_{-1}^{+1}dt\exp [-xt] &=&\int_{-1}^{+1}dt% \frac{1}{t-iz} \\ \int_{0}^{\infty }dt\exp [izx]\partial _{x}^{2}A(x) &=&izA(0)-z^{2}\hat{A}(z) \end{eqnarray*} so \begin{eqnarray*} izA(0)-(z^{2}-1)\hat{A}(z) &=&\int_{-1}^{+1}dt\frac{1}{t-iz} \\ \hat{A}(z) &=&\frac{iz}{z^{2}-1}A(0)-\int_{-1}^{+1}dt\frac{1}{z^{2}-1}\frac{1% }{t-iz} \end{eqnarray*} and \begin{eqnarray*} A(x) &=&\frac{1}{2\pi }\int_{\Gamma }dz\exp [-izx]\{\frac{iz}{z^{2}-1}% A(0)-\int_{-1}^{+1}dt\frac{1}{z^{2}-1}\frac{1}{t-iz}\} \\ &=&\frac{1}{2\pi i}\int_{\Gamma }dz\exp [-izx]\{-\frac{z}{z^{2}-1}% A(0)+\int_{-1}^{+1}dt\frac{1}{z^{2}-1}\frac{1}{z+it}\} \end{eqnarray*} Continuing analytically in the lower half plane we encounter poles in $z=\pm 1$ and $z=-it$ (the latter is in the upper half plane for negative $t$, sufficiently large) and obtain $A(x)$ in terms of residues.

Perhaps you could write $\sum_{k=0}^\infty (-1)^k t^{2k}e^-t=\sum_{k,l=0}^\infty (-1)^k t^{2k}(-1)^lt^l/l!=\sum_{k,l=0}^\infty (-1)^{k+l} t^{2k+l}/l!$

Now try integrating this.