1
$\begingroup$

I have numerically calculated the integral $$\int_{-1}^{1}\frac{e^{-x^2}}{\sqrt{1-x^2}}dx$$ using Gauss-Legendre and Gauss-Chebyshev quadrature. Now, I am asked to calculate the integral using the trapezoidal rule and compare the different methods. I had previously used the trapezoidal method for other integrals, however, with this one, I can't evaluate the function at the limits of the integral, since the denominator is $0$.

How can I calculate this integral using the trapezoidal rule? Is it even possible?

$\endgroup$
0

3 Answers 3

3
$\begingroup$

$\require{cancel}$

Calculate

\begin{eqnarray} \int_{-1}^{1} \frac{e^{-x^2}}{\sqrt{1-x^2}} \,{\rm d}x&=& 2\int_{0}^{1} \frac{e^{-x^2} - \color{blue}{e^{-1} + e^{-1}}}{\sqrt{1-x^2}} \,{\rm d}x\\ &=& 2\int_{0}^{1}\frac{e^{-x^2} - \color{blue}{e^{-1}}}{\sqrt{1-x^2}} \,{\rm d}x+ 2\color{blue}{e^{-1}}\int_{0}^{1} \frac{1}{\sqrt{1-x^2}}\,{\rm d}x \\ &=& 2\int_{0}^{1} \frac{e^{-x^2} - \color{blue}{e^{-1}}}{\sqrt{1-x^2}} \,{\rm d}x+ \frac{\pi}{e} \end{eqnarray}

The advantage of doing this is that

$$ \lim_{x\to 1}\frac{e^{-x^2} - \color{blue}{e^{-1}}}{\sqrt{1-x^2}} = 0 $$

So when you evaluate this node in your code you just set it to zero. That is, if

$$ f(x) = \frac{e^{-x^2}- e^{-1}}{\sqrt{1 - x^2}} $$

then

$$ \int_0^1 f(x)\,{\rm d}x \approx \frac{h}{2}[f(0) + 2f(x_1) + 2 f(x_2) + \cdots + 2 f(x_{n-1}) + \cancelto{0}{f(1)}] $$

$\endgroup$
2
  • $\begingroup$ (+1) for the solid answer. $\endgroup$
    – Mark Viola
    May 21, 2018 at 17:29
  • $\begingroup$ @MarkViola Thanks for edit :) $\endgroup$
    – caverac
    May 21, 2018 at 17:30
1
$\begingroup$

$$ \int_{-1}^1 \frac{e^{-x^2}}{\sqrt{1-x^2}} \, dx $$ Let $x=\sin\theta,$ so that $\theta$ goes from $-\pi/2$ to $\pi/2$ as $x$ goes from $-1$ to $1,$ and $dx=\cos\theta\,d\theta$ and $\sqrt{1-x^2} = \cos\theta.$ Then the integral becomes $$ \int_{-\pi/2}^{\pi/2} e^{-\sin^2\theta} \, d\theta. $$ This is a bounded continuous function and can be evalutated by the trapezoidal rule without worrying about any impropriety at the endpoints.

$\endgroup$
-1
$\begingroup$

Hint: Calculate

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

using the trapezoidal rule. The expression should be a function of $\varepsilon$. Then calculate $\varepsilon \to 1$ for that expression.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .