2

Take the following formula:

\begin{equation*} \int_a^b f(x) ~ dx = \frac{h}{2} \left( f(a) + 2\sum_{j=1}^{n-1}f(x_j) + f(b) \right) - \overbrace{\frac{b-a}{12}h^2 f''(\lambda)}^\text{estimation error} \end{equation*}

where $x_0 = a, x_1, \ldots, x_{n-1}, x_n = b$ are evenly spaced points (distance $h$) in the interval $[a, b]$, $f''(\lambda) = \frac{1}{n}\sum_{j=1}^n f''(\zeta_j)$, with $\zeta_j \in (x_{j-1}, x_{j})$.

We wish to determine the minimum value of $n$ such that that the error in the approximation error is $\leq 0.5 \cdot 10^{-6}$ when

$$ f(x) = e^{-x^2}, a = 0, b = 1 $$

I believe I was able to find the right value, but my approach seems very cumbersome. Firstly, I expressed the error as a function of $n$ by noting that, with $a = 0, b = 1$, $h = \frac{1}{2n}$, the second derivative $f$ is

\begin{equation*} f''(x) = 2e^{-x^2}(2x^2 - 1) \end{equation*}

Then, noting that the error can be expressed as

\begin{equation*} E(n) = \frac{1}{12 \cdot 4n^2} f''(\lambda) = \frac{ \sum_{j=1}^n f''(\zeta_j)}{48n^3} \end{equation*}

I found the critical points of $f''$ by equating its derivative to zero:

\begin{aligned} f'''(x) &= 2 \cdot \left( (2x^2-1)\frac{d}{dx} e^{-x^2} + e^{-x^2}(4x) \right) \\ &= 2 \left( (2x^2-1)( -2x )e^{-x^2} + 4x e^{-x^2} \right) \\ &= -4xe^{-x^2}(2x^2-1) + 8x e^{-x^2} \end{aligned}

and

\begin{align*} -4x e^{-x^2}(2x^2-1) + 8x e^{-x^2)} = 0 &\iff x e^{-x^2}(2x^2 -1) - 2xe^{-x^2} = 0 \\ &\iff xe^{-x^2}(2x^2 - 1 - 2) = 0 \\ &\iff ( x = 0 ) \lor ( 2x^2 - 3 = 0 ) \end{align*}

This entails $f''$ has critical points at $x = 0$ and $x = \pm \sqrt{\frac{3}{2}} $. A quick evaluation of $f''$ at these values allows us to see that $\pm \sqrt{\frac{3}{2}} $ are maximums. Then,

\begin{align*} E(n) &= \frac{\sum_{j=1}^n f''(\zeta_j)}{48 n^3} \\ &\leq \frac{ n f'' \left( \sqrt{\frac{3}{2}} \right) }{48n^3} \\ &\leq \frac{0.9}{48n^2} \end{align*}

At last, to make the error less than or equal to $\frac{1}{2} 10^{-6}$, we impose

\begin{aligned} \frac{9}{10\cdot 48n^2} \leq \frac{1}{2}10^{-6} &\iff \frac{18 \cdot 10^6}{10 \cdot 48} \leq n^2 \\ &\iff \sqrt{37500} \leq n \\ &\Leftarrow n = 194 \\ \end{aligned}


The approach given above seems too complicated: first, second, and third derivatives are computed; the third derivative is equated to zero, and to solve it we need to find the roots of a quadratic polynomial; only then can we bound the summation involving $f''(\zeta_j)$. My professor hinted that I was over-complicating the problem, but left as exercise to find a simpler approach. I have failed to do so.

What would be the parsimonious approach to solving this problem?

lafinur
  • 3,783
  • 1
    If you are looking to approximate your integral through quadrature methods (instead of Taylor approximation methods) you can see at general error bounds for such methods in Krylov, V. I. (translated by Stroud, A.), Approximate calculation of integrals, Dover Publications. 2005 pp 89-91. Are is a post that may be of interest – Mittens Feb 04 '25 at 20:52
  • I would be very interested to see what your professor has in mind. It is certainly possible to apply Richardson extrapolation to this problem and accurately estimate the accuracy of Richardson's error estimate using about 64 intervals, but I would hardly describe this approach as simpler than yours. – Carl Christian Feb 08 '25 at 13:54
  • $\sqrt{3/2} > 1$. – PierreCarre Feb 11 '25 at 13:57
  • @lafinur Why do you say that $h=\frac{1}{2n}$? Is it not $\frac 1n$? – PierreCarre Feb 11 '25 at 14:51

2 Answers2

1

$$I=\int_0^1\sum_{n=0}^\infty(-1)^n\frac{x^{2n}}{n!}dx=\sum_{n=0}^\infty(-1)^n\frac{1}{(2n+1)n!}$$ The more terms you take the better the approximation.

Antony Theo.
  • 4,716
  • 1
    Furthermore, the absolute error resulting from truncating the series after any number of terms is bounded above by the absolute value of the first omitted term. – Gary Feb 08 '25 at 06:23
  • 1
    @AntonyTheo This has nothing to do with the question by the OP, which is related with the error in applying the trapezoidal rule. – PierreCarre Feb 11 '25 at 14:47
  • 1
    @PierreCarre, read the title and the last sentence of the question. – Gonçalo Feb 11 '25 at 16:14
1

The relevant values of the second derivative are the ones attained in the interval $[0,1]$... and $\sqrt{3/2}>1$. The third derivative is given by $f'''(x) = 4 e^{-x^2} x \left(3 - 2 x^2\right)$, which is positive in the interval $[0,1]$. Hence, $f''$ is strictly increasing and the maximum of $|f|$ must be attained at either $x=0$ or $x=1$. By substitution you see that the maximum is given by $|f''(0)| = 2$. So, by choosing $n$ such that $\frac{2}{12n^2} < 0.5 \times 10^{-6}$, you get a very simple (yet not so sharp) estimate for $n$, which is $n \ge 578$.

Of coarse, this is not the smallest possible value for $n$. Numerically, I've checked that the minimum value for $n$ is actually $n=351$.

PierreCarre
  • 23,092
  • 1
  • 20
  • 36