Let’s run through some operations that we need to answer some of the questions in #23 on p. 517.

Integrate[Exp[x^2],x]

Integrate[Exp[x^2],{x,-1,5}]

f[x_]:=Exp[Cos[x]]

a:=0

b:=2*Pi

n:=100

You can use Greek letters in Mathematica. Try this by entering a backslash (\) followed by [CapitalDelta]

Δx:=(b-a)/n

Here’s a command to use the Midpoint rule for n rectangles (in this case, we’ve chosen n to be 10).

Sum[f[(a+(i-1)*Δx+a+i*Δx)/2]*Δx,{i,1,n}]

N[%]

Here’s the left and right endpoint approximations.

Sum[f[a+(i-1)*Δx]*Δx,{i,1,n}]

N[%]

Sum[f[a+i*Δx]*Δx,{i,1,n}]

N[%]

Here’s a command that invokes the Trapezoidal Rule

Δx/2*(f[a]+f[b]+2*Sum[f[a+i*Δx],{i,1,n-1}])

N[%]

Finally, here’s a command that invokes Simpson’s Rule

Δx/3*(f[a]+f[b]+4*Sum[f[a+(2*i+1)*Δx],{i,0,(n-2)/2}]+2*Sum[f[a+2*i*Δx],{i,1,(n-2)/2}])

N[%]

Plot[Abs[f''[x]],{x,a,b}]

Note that 2.8 is an upper bound on the absolute value of the 2nd derivative of f.

Plot[Abs[f''''[x]],{x,a,b}]

Note then that 12 is an upper bound on absolute value of the fourth derivative of f.

To do part j of # 23, we need to use the fact we determined earlier that 12 is an upper bound on the absolute value of the fourth derivative of f. Now using the error bound for Simpson’s Rule on p. 514: I’m using a ‘q’ here instead of an ‘n’ because I used ‘n’ up above.

Reduce[12*(2*Pi)^5/(180*q^4)<0.0001,q]

So we would need n to be at least 51 to guarantee that the approximation we get using Simpson’s Rule is within 0.0001 of the exact value.