Numerical Integration

Review

Question

What is the fundamental theorem of calculus?

Question

Can we find antiderivatives for every nice function?

Question

Approximate the area between the x-axis and y=(e^(-(x^2))) for 0≤x≤2 using four rectangles.

Different types of rectangles

Left endpoint rule: (∫_a^b)f(x) d x=(∑_(k=1)^n)f((Subscript[x, k-1]))Δ x=(f((Subscript[x, 0]))+f((Subscript[x, 1]))+…+f((Subscript[x, n-1])))Δ x
Right endpoint rule: (∫_a^b)f(x) d x=(∑_(k=1)^n)f((Subscript[x, k]))Δ x=(f((Subscript[x, 1]))+f((Subscript[x, 2]))+…+f((Subscript[x, n])))Δ x
Midpoint rule: (∫_a^b)f(x) d x=(∑_(k=1)^n)f((((Subscript[x, k-1])+(Subscript[x, k]))/2))Δ x=(f((((Subscript[x, 0])+(Subscript[x, 1]))/2))+f((((Subscript[x, 1])+(Subscript[x, 2]))/2))+…+f((((Subscript[x, n-1])+(Subscript[x, n]))/2)))Δ x

Trapezoid rule

The trapezoid rule for estimating (∫_a^b)f(x) d x with n trapezoids is the average of the left endpoint rule and the right endpoint rule each with n rectangles. Let Δ x=((b-a)/n) and (Subscript[x, k])=a+k Δ x.

Questions

What is a formula for the trapezoid rule using n trapezoids?

Is the trapezoid rule the same as the midpoint rule?

Use the trapezoid rule to estimate (∫_0^2)(Sqrt[1+(x^3)])d x with 5 trapezoids.

Errors in numerical integration

When you approximate a quantity, typically you want to have some idea about how good your approximation is.

Definition

The absolute error E in estimating value V with approximation A is
	E=|V-A|

Questions

Use the trapezoid rule with n=5 to estimate (∫_0^1)(x^2)d x.

Determine the actual error (you can actually compute this integral!) in using this approximation.

Error bounds

Suppose |f''(x)|≤K for a≤x≤b where K is a constant. The error in approximating (∫_a^b)f(x)d x

with the trapezoid rule using n trapezoids is error≤(((K(b-a))^3)/(12(n^2))).

with the midpoint rule using n rectangles is error≤(((K(b-a))^3)/(24(n^2))).

Questions

We want to approximate (∫_0^1)(e^(-(x^2)))d x. Let f(x)=(e^(-(x^2))).

What is f''(x)?

We want a constant value for K, in |f''(x)|≤K. What are some possibilities?

Estimate (∫_0^1)(e^(-(x^2)))d x with the trapezoid rule using 4 trapezoids.

What do we know about the error in our approximation?

Simpson’s rule

Estimation formula

To approximate (∫_a^b)f(x)d x, let n be an even number and Δ x=((b-a)/n), then Simpson’s rule is
	(∫_a^b)f(x)d x≈((Δ x)/3)(f((Subscript[x, 0]))+4f((Subscript[x, 1]))+2f((Subscript[x, 2]))+4f((Subscript[x, 3]))+2f((Subscript[x, 4]))+…+2f((Subscript[x, n-2]))+4f((Subscript[x, n-1]))+f((Subscript[x, n])))

Error bound

The error in the above approximation is
	error≤(((K(b-a))^5)/(180(n^4)))
where K is a constant such that |(f^((4)))(x)|≤K for a≤x≤b.

An easier computation

The Simpson’s rule approximation is actually a clever average of the midpoint and trapezoidal methods:
	S=((2M+T)/3)
This is motivated by the form of the error terms for Midpoint and Trapezoidal: it looks like, in general, the midpoint method is about twice as good as the trapezoidal. Interestingly enough, it is often the case that, if one of the two methods is an underestimate, then the other is an overestimate. So by taking 2 estimates from midpoint, we double its error, which, if it is of opposite sign from the trapezoidal error, will just cancel -- and give us our best method: Simpson’s rule.

Questions

We want to approximate (∫_0^1)(e^(-(x^2)))d x. Let f(x)=(e^(-(x^2))).

f[x_]=(E^(-(x^2)))

f''''[x]

The fourth derivative is
	(f^((4)))(x)=12 (e^(-(x^2)))-48 (e^(-(x^2))) (x^2)+16 (e^(-(x^2))) (x^4)
and its graph is

Plot[f''''[x],{x,0,1}]

We want a constant value for K, in |(f^((4)))(x)|≤K. What are some possibilities?

Estimate (∫_0^1)(e^(-(x^2)))d x with the Simpson’s rule using n=4.

What do we know about the error in our approximation?