Estimates for Integral Approximations  - ErrorIntegral2.nb

Error Estimates for the Left Riemann Sum - Theory

Riemann Sums compute the integral exactly for constant functions, but the Left Riemann Sum underestimates the integral for increasing functions (and overestimates for decreasing functions, respectively). 
It is thus natural to expect the size of the derivative of the integrand to determine the quality of the approximation: the larger the absolute value of the derivative of the integrand is, the larger we expect the error to be when we use the Left Riemann Sum to approximate the integral.
Let us assume that we know an upper bound M for the size of the the derivative of the integrand f(x) :
More precisely, we assume that |f' (x) | ≤ M for all x in the domain [a,b], over which we integrate. What can we say about functions satisfying this condition? If we know where they start, we know that they lie in a cone of "slope" M.
As an example we consider the function f(x) = 5 + (x^2)from x=1 to x=2. Then we know that \(TraditionalForm
      \`\(|\(f' \((x)\) | \) = |\) 2  x | \( ≤ 4\)\) for all x ϵ [1, 2]. This implies that the function is contained in the "cone" of slope 4 with "vertex" at the left endpoint (1, f(1) = 6).

\(\(	\(Plot[{6, 5 + x^2}, {x, 1, 2}, 
      PlotStyle -> {{AbsoluteThickness[2], RGBColor[0, 0, 0]}, {
            AbsoluteThickness[2], RGBColor[0, 0, 1]}}, 
      Prolog -> {RGBColor[1, 0, 0], Polygon[{{1, 6}, {2, 10}, {2, 2}}]}, 
      \ \ \ PlotRange -> {0, 10}, AspectRatio -> 1]; \)
\)\)

Here is a picture of the general situation:
The Left Riemann Sum approximation is the black line in the middle, the function f(x) itself is depicted in blue

\(\(	\(Plot[{6, 5 + x^2}, {x, 1, 2}, 
      PlotStyle -> {{AbsoluteThickness[2], RGBColor[0, 0, 0]}, {
            AbsoluteThickness[2], RGBColor[0, 0, 1]}}, 
      Prolog -> {RGBColor[1, 0, 0], Polygon[{{1, 6}, {2, 10}, {2, 2}}]}, 
      \ \ \ PlotRange -> {0, 10}, AspectRatio -> 1, 
      AxesLabel -> {"x", "y"}, 
	
      Ticks -> {

          			{				{1, \*""\!\(x\_0\)""}, {2, 
              \*""\!\(x\_0\)+Δx""}\ \ \ }, 

          			{\ \ \ \ \ \ \ \ \ {2, 
              \*""f(\!\(x\_0\))-M Δx""}, 
            \ \ {6, \*""f(\!\(x\_0\))""}, {10, 
              \*""f(\!\(x\_0\))+M Δx""}}
		}]; \)

    \)\)

What is the worst case scenario for the difference in the integral contribution given by the black line and the integral of the function f(x)? - This might take a second of reflection: the worst case scenario occurs when the blue line runs along the edge of the red triangle!
Thus the error will not be bigger than half the area of the red triangle, i.e., 
the error (for one little subinterval) is bounded by (1/2) Δx (M Δx) = (1/2) ((M( Δx))^2).

If we split the original interval [a,b] into n pieces, each of equal length Δx=(b-a)/n, then we have to multiply the error for one subinterval by the number of subintervals :

The total error is bounded by (1/2) ((M(Δx))^2)n=(1/2)((M(((b - a)/n)))^2)n=(1/2)((M(b - a))^2)(1/n)

Consequently when we double n, the number of subintervals, we do not change M, a and b, and thus we expect the error to be cut in half!

Error Estimates for the Left Riemann Sum - An Example

Suppose we want to give an a priori estimate for computing the integral of the function f(x) = (e^(-(x^2)))from x=0 to x=1 using the Left Riemann Sum with n=100,000 subintervals. If you look back to the formula above, the problem reduces to finding the maximal value of  | f' (x) |  on the interval [a, b]. For this we use the following extension of what you have learnt in Calculus I:
		The absolute maximum for |f' (x) |  occurs at a critical point of 		\(TraditionalForm\`\(								
      f' \((x)\)\ \ or\ at\ an\ endpoint\)\)
Here is the second derivative of f(x) :

\(f[x_] = Exp[\(-x^2\)]; 
\(\(f'\)'\)[x]\)

The only critical point for f' (x) on the interval [0, 1] occurs at x = (1/(Sqrt[2])):

Solve[Simplify[f''[x]] == 0]

Evaluating |f' (x) |  at the critical point and the endpoints reveals that the global maximum of |f' (x) |  equals about 0.8578:

N[Abs[f'[1/Sqrt[2]]]]N[Abs[f'[0]]]N[Abs[f'[1]]]

Thus our a priori estimate for the error is given  by

1/2 * 0.8578*(1 - 0)^2 /100000

At this point we know that  (∫_0^1)(e^(-(x^2))) dx will not differ from the Left Riemann Sum approximation with 100,000 subintervals by more than 4.2889999999999997`*^-6. 
Note that we have arrived at this conclusion without either knowing the exact value of (∫_0^1)(e^(-(x^2))) dx or performing the actual Riemann approximation!

Etc.

Author: H. Knaust (helmut@math.utep.edu)
Created: August 2000
Last Edits: August 28, 2000