Problem 7.7.7 From an Earlier Edition

Question

Use Trapezoidal Rule, Midpoint Rule, and Simpson's Rule with n=8 partitions to approximate

(∫_0^2)(((1+(x^2)))^(1/4))dx

Solution

Here, we will solve the problem essentially by hand, and use Mathematica simply as a calculator for n=8 partitions.

f[x_]=(1+x^2)^(1/4)

General Setup of Partitions

Since a=0, b=2, and we will be using 8 partitions, we have Δx = (b-a)/n = (2-0)/8 = 0.25. Therefore, the partitions have endpoints given by

({{(Subscript[x, 0]), 0.00}, {(Subscript[x, 1]), 0.25}, {(Subscript[x, 2]), 0.50}, {(Subscript[x, 3]), 0.75}, {(Subscript[x, 4]), 1.00}, {(Subscript[x, 5]), 1.25}, {(Subscript[x, 6]), 1.50}, {(Subscript[x, 7]), 1.75}, {(Subscript[x, 8]), 2.00}})

Plot[f[x],{x,0,2},GridLines->{{0.00,0.25,0.50,0.75,1.00,1.25,1.50,1.75,2.00},None}]

Trapezoidal Rule

Here is the Trapezoidal Rule for 8 partitions:

(Subscript[T, 8])= ((Δx)/2) (f((Subscript[x, 0]))+2f((Subscript[x, 1]))+2f((Subscript[x, 2]))+2f((Subscript[x, 3]))+2f((Subscript[x, 4]))+2f((Subscript[x, 5]))+2f((Subscript[x, 6]))+2f((Subscript[x, 7]))+f((Subscript[x, 8])))
=(( 0.25)/2)(f(0.00)+2f(0.25)+2f(0.50)+2f(0.75)+2f(1.00)+2f(1.25)+2f(1.50)+2f(1.75)+f(2.0))

Let's use Mathematica like a calculator and work this out:

(0.25/2)*(f[0.00]+2f[0.25]+2f[0.50]+2f[0.75]+2f[1.00]+2f[1.25]+2f[1.50]+2f[1.75]+f[2.0])

This is the Trapezoidal Rule approximation to the integral

(∫_0^2)(((1+(x^2)))^(1/4))dx

MidPoint Rule

For the Midpoint Rule, we need to use the midpoint of each partition.

Here is the Midpoint Rule for 8 partitions:

(Subscript[M, 8])= Δx (f((Subscript[(OverBar[x]), 1]))+f((Subscript[(OverBar[x]), 2]))+f((Subscript[(OverBar[x]), 3]))+f((Subscript[(OverBar[x]), 4]))+f((Subscript[(OverBar[x]), 5]))+f((Subscript[(OverBar[x]), 6]))+f((Subscript[(OverBar[x]), 7]))+f((Subscript[(OverBar[x]), 8])))
= 0.25(f(0.125)+f(0.375)+f(0.625)+f(0.875)+f(1.125)+f(1.375)+f(1.625)+f(1.875))

Let's use Mathematica like a calculator and work this out:

0.25(f[0.125]+f[0.375]+f[0.625]+f[0.875]+f[1.125]+f[1.375]+f[1.625]+f[1.875])

This is the Midpoint Rule approximation to the integral

(∫_0^2)(((1+(x^2)))^(1/4))dx

Simpson's  Rule

Here is Simpson's Rule for 8 partitions:

(Subscript[T, 8])= ((Δx)/3) (f((Subscript[x, 0]))+4f((Subscript[x, 1]))+2f((Subscript[x, 2]))+4f((Subscript[x, 3]))+2f((Subscript[x, 4]))+4f((Subscript[x, 5]))+2f((Subscript[x, 6]))+4f((Subscript[x, 7]))+f((Subscript[x, 8])))
=(( 0.25)/3)(f(0.00)+4f(0.25)+2f(0.50)+4f(0.75)+2f(1.00)+4f(1.25)+2f(1.50)+4f(1.75)+f(2.0))

Let's use Mathematica like a calculator and work this out:

0.25/3*(f[0.00]+4f[0.25]+2f[0.50]+4f[0.75]+2f[1.00]+4f[1.25]+2f[1.50]+4f[1.75]+f[2.0])

This is Simpson's Rule approximation to the integral

(∫_0^2)(((1+(x^2)))^(1/4))dx

Mathematica NIntegrate Result

Integrate[f[x],{x,0,2}]

N[%]

Better Solution using More Partitions

In practice, if we were faced with that integral since we know the form of the integrand we should use a large number of partitions, and vary the number of partitions to get an approximation to the solution with some idea of how accurate our approximation is.

M[n_,a_,b_] := SetPrecision[(b-a)/n  Sum[f[a+(b-a)/(2n)*(2i-1)],{i,1,n}],10]
T[n_,a_,b_] := SetPrecision[(b-a)/(2n) ( f[a]+f[b]+2Sum[f[a+(b-a)/n*i],{i,1,n-1}]),10]
S[n_,a_,b_]:=T[n/2,a,b]/3+2M[n/2,a,b]/3

f[x_]=(1+x^2)^(1/4)
a=0
b=2
Table[{n,M[n,a,b],T[n,a,b],S[n,a,b]},{n,40,70,2}];
TableForm[%,TableHeadings->{None,{"n","Midpoint","Trapezoidal","Simpson's"}}]