# numerical evaluation of an integral

I have this integral:

$$\int_{-1}^{1} \frac{e^x}{\sqrt{1-x^2}}\,dx$$

How can I get rid of the infinities at the ends of the interval so that I can evaluate this integral numerically? I tried to make some substitutions but didn't succeed.

-

There are many ways to evaluate this numerically. Let $$I = \int_{-1}^1 \dfrac{e^x}{\sqrt{1-x^2}}dx$$ One way, I can think of is as follows. Set $x = \sin(\theta)$. We then get that $$I = \int_{-\pi/2}^{\pi/2} e^{\sin(\theta)} d \theta$$ Once you have it in this form, you could recognize this is the modified Bessel function evaluated at $1$. To evaluate this numerically, expand $e^{\sin(\theta)}$ in a series. We have $$I = \int_{-\pi/2}^{\pi/2} \sum_{k=0}^{\infty} \dfrac{\sin^k(\theta)}{k!} d \theta = \sum_{k=0}^{\infty} \int_{-\pi/2}^{\pi/2} \dfrac{\sin^k(\theta)}{k!} d \theta = \sum_{k=0}^{\infty} \int_{-\pi/2}^{\pi/2} \dfrac{\sin^{2k}(\theta)}{(2k)!} d \theta\\ = 2\sum_{k=0}^{\infty} \int_{0}^{\pi/2} \dfrac{\sin^{2k}(\theta)}{(2k)!} d \theta$$ Now recall that $$\int_0^{\pi/2} \sin^{2k}(\theta) d \theta = \dfrac{2k-1}{2k} \dfrac{2k-3}{2k-2} \cdots \dfrac12 \dfrac{\pi}{2} = \dfrac{(2k)!}{4^k k! k!} \dfrac{\pi}2$$ Hence, we have $$I = \pi \sum_{k=0}^{\infty} \dfrac1{4^k \cdot (k!)^2}$$ The series converges at an exponential rate, hence truncating the series after a few terms should give you a very good accuracy.

-
Because integrating by parts $I_{2k}=\int_0^{\pi/2} \sin^{2k}(\theta) d \theta$, we get the recurrence relation $I_{2k}=\frac{2k-1}{2k} I_{2k-2}$ where $I_{0}=\frac{\pi}{2}$ – user 1618033 Dec 30 '12 at 19:55
@Chris'ssister Yes. I have added the link where the integral is evaluated. – user17762 Dec 30 '12 at 19:59
I thought it would be helpful for the unexperienced people. Thanks. – user 1618033 Dec 30 '12 at 20:01

$$\int_{-1}^1 \frac{e^x}{\sqrt{1-x^2}}dx$$

$$x = \sin t; dx=\cos t dt$$

$$\int_{-\frac{\pi}{2}}^{{\frac{\pi}{2}}} \frac{e^{\sin t}}{\sqrt{1-\sin^2 t}} \cos t dt$$

$$\int_{-\frac{\pi}{2}}^{{\frac{\pi}{2}}} e^{\sin t} dt$$

No more infinities.

-