Error of composite trapezium rule

527 Views Asked by At

Given the integral $$\int_{1}^{\infty} \frac{e^{-x}}{x^2}dx$$ I want to find a value of $b >1$, and a number of intervals $n$ such that the error in $$\int_{1}^{b} \frac{e^{-x}}{x^2}dx$$ is less than $10^{-2}$. Now, I know the formula for the error of the composite trapezium rule in this example is $\leq \frac{(b-1)^3}{12n^2} M_2$, where $M_2$ is the maximum of the modulus of the derivative in the interval $[1,b]$. I can find a bound on $M_2$, but I still end up with one inequality for 2 unknowns? Am I supposed to just pick an $n$ and a $b$ that work, or is there something i'm mising?

2

There are 2 best solutions below

2
On

We want to approximate the integral $\int_1^\infty{\exp(-t)t^{-2}dt}$ with 2-point decimals. Substitute $t=x^{-1},$ then the integral transformed into $\int_0^1{\exp(-1/x)dx}$. Let $f(x)=\exp(-1/x)$, $f''(x)= - \frac{2}{{x^3 }}\exp \left( { - \frac{1}{x}} \right) + \frac{1}{{x^4 }}\exp \left( { - \frac{1}{x}} \right)$, by maximizing $f''$ on $(0,1)$, we find that \begin{align*} \sup|f''(x)|&= - \frac{2}{{\left( {\frac{1}{2} - \frac{1}{6}\sqrt 3 } \right)^3 }}\exp \left( { - \frac{1}{{\frac{1}{2} - \frac{1}{6}\sqrt 3 }}} \right) + \frac{1}{{\left( {\frac{1}{2} - \frac{1}{6}\sqrt 3 } \right)^4 }}\exp \left( { - \frac{1}{{\frac{1}{2} - \frac{1}{6}\sqrt 3 }}} \right) \\ &\approx 2.549960274 \end{align*}
Thus,the error $Er(f)=\frac{(1-0)^3}{12 n^2}\times \sup|f''(x)|=\frac{0.2124966895}{n^2}\le 10^{-2}$. Solving for $n$ we get $n \ge 4.6$, so that $n\ge \left\lceil 4.6 \right\rceil =5$.

0
On

The total error of the calculation comes from two sources: the error from the trapezoidal rule and the error from the truncation of the integral. The bounds of these errors are \begin{eqnarray} \epsilon_{trap} &\le& \frac{(b-1)^3}{12n^2}\sup\left|\frac{d^2}{dx^2}\frac{e^{-x}}{x^2}\right| \approx \frac{(b-1)^3}{3n^2}\\ \epsilon_{trunc} &=& \int_b^\infty \frac{e^{-x}}{x^2}dx \le \frac{e^{-b}}{b^2} \end{eqnarray} So the total error will be bounded by $$ \epsilon_{total} \le \frac{(b-1)^3}{3n^2} + \frac{e^{-b}}{b^2} $$ The second term primarily serves to put a lower bound on $b$. If we need $\epsilon_{total} < 10^{-2}$, this means $b > 2.65$, though obviously it's going to be higher than this when we factor in the first error term. Still, from this bound on $b$ alone we're going to need $n > 12.2$. Actually going through with the optimization gives $n = 25, b = 3.11$.

Now this is actually a very conservative estimate, as a few things pull down the error. The first is that the region of high second derivative is all at one end of the interval. The error from the trapezoidal rule is much larger there than elsewhere in the interval. The second is that the trapezoidal error and truncation error have opposite signs.

There's also the fact that this is an infinite interval and you're forcing equal size intervals. The truncation error wants the interval to be longer, but the trapezoidal error wants small intervals near 1 to handle the higher second derivative there. This gives a very large number of intervals. Some ways to deal with this:

  1. Use unequally-sized intervals. This lets you use fewer intervals in places where the function isn't changing as much.
  2. Find a good estimate for the truncation error and add it to the result. This can allow you to choose much lower $b$ values, but may not be possible depending on the function.
  3. Use a substitution to transform the integral into one over a finite region. This is what mwomath's answer does. This eliminates any consideration of $b$, though the Jacobian of the transformation can potentially create undesirable large derivatives.