Remarks in italics are by me for extra explanation. These comments would not be necessary for full marks in an exam situation. Exercises taken from p.87 of these notes.

Question 1

Estimate \int_0^1\cos(x^2)\,dx using  (a) the Trapezoidal Rule and (b) the Midpoint Rule, each with n=4.

Solution

Part (a)

For the Trapezoidal Rule, we have \Delta x=0.25 and we have the points x_0=0x_1=0.25x_2=0.5x_3=0.75x_4=1. Hence using the formula:

\int_0^1\cos(x^2)\,dx\approx\frac{0.25}{2}[\cos(0)+2[\cos(0.25^2)+\cos(0.5^2)+\cos(0.75^2)]

+\cos(1)]\approx 0.895795.

Part (b)

In this case we have \Delta x=0.25 and have midpoints x_1=0.125x_2=0.375x_3=0.625 and x_4=0.875. Hence using the formula:

\int_0^1\cos(x^2)\,dx\approx (0.25)[\cos(0.125^2)+\cos(0.375^2)+\cos(0.625^2)

+\cos(0.875^2)]\approx 0.908907.

Question 2 (b) (first integral only)

Use Simpson’s Rule to approximate to six decimal places.

\int_0^\pi x^2\sin x\,dx, with n=8.

Integrate by parts and compare these approximate values with the real value.

Not completed.

Solution

Now in this case \Delta x=\pi/8 and x_i=i\pi/8. Hence using the formula:

\int_0^\pi x^2\sin x\,dx\approx \frac{\pi/8}{3}[(0)^2\sin 0+4(\pi/8)^2\sin(\pi/8)+2(\pi/4)^2\sin(\pi/4)+

4(3\pi/8)^2\sin(3\pi/8)+2(\pi/2)^2\sin(\pi/2)+4(5\pi/8)^2\sin(5\pi/8)+

2(3\pi/4)^2\sin(3\pi/4)+4(7\pi/8)^2\sin(7\pi/8)+\pi^2\sin \pi]\approx 5.869247.

Now to integrate I by parts choose u=x^2 by the LIATE rule; and thus dv=\sin x\,dx. We have

\frac{du}{dx}=2x\Rightarrow du=2x\,dx and v=-\cos x.

Hence by the formula (we will put in limits later):

I=x^2(\cos x)-\int \cos x(-2x\,dx)=-x^2\cos x+2\underbrace{\int x\cos x\,dx}_{:=J}.

Now to integrate J we must integrate by parts a second time. Again by LIATE choose u=x, thus dv=\cos x\,dx. Hence

\frac{du}{dx}=1\Rightarrow du=dx and v=\sin x;

\Rightarrow J=x\sin x-\int\sin x\,dx=x\sin x+\cos x,

\Rightarrow I=-x^2\cos x+2x\sin x+2\cos x.

We must evaluate between the limits:

\left[-x^2\cos x+2x\sin x+2\cos x\right]_0^\pi=-\pi^2\cos \pi+2\pi\sin\pi+2\cos \pi

-\left(-(0)^2\cos(0)+2(0)\sin 0+2\cos 0\right)=\pi^2-4\approx 0.8696014.

Hence, in this case, E_S=-0.000357.

Question 4 (without implementation)

Estimate the errors involved in the approximations T_8 and M_8 for \int_0^1 \cos(x^2)\,dx. How large do we have to choose n so that the approximations T_n and M_n are accurate to within 0.00001?

Solution

We have the upper bounds:

|E_T|\leq\frac{K(b-a)^2}{12n^2}, and

|E_M|\leq\frac{K(b-a)^3}{24n^2}.

where K=\max_{x\in[a,b]}|f''(x)|. Now

f'(x)=-\sin (x^2)(2x)

f''(x)=-\sin(x^2)(2)-2x\cos(x^2)(2x)=-2(\sin(x^2)+2x^2\cos(x^2)).

In terms of MATH6037 we haven’t gone into how to find the maximum of such a function. This question should not have been put in your exercises. In fact even the method I would use for solving this — namely the Closed Method http://129.81.170.14/~solson2/HO6.pdf (bottom of page 1) — has a great difficulty solving it. In this case I would leave K as it is — as K.

We know that b-a=1 and n=8. Hence

|E_T|\leq\frac{K}{768}, and

|E_M|\leq \frac{K}{1536}.

Again we haven’t got the tools to find K but we can still find answers in terms of K.

Now for the second part, looking at the Trapezoidal Rule first, we want to find an n such that:

|E_T|\leq 0.00001.

Now the maximum that |E_T| can be is given by the formula so we can look at the inequality (b-a=1):

\frac{K(b-a)^3}{12n^2}<0.00001.

\Rightarrow n^2>\frac{K}{12(0.00001)}=\frac{25000K}{3}

n>\sqrt{\frac{25000K}{3}}=50\sqrt{\frac{10K}{3}}.

Now looking at the Midpoint Rule, we want to find an n such that:

|E_M|<0.00001,

so again we solve the inequality

\frac{K(b-a^2)}{24n^2}<0.00001

\Rightarrow n^2>\frac{K}{24(0.00001)}=\frac{12500K}{3}

\Rightarrow n>\sqrt{\frac{12500K}{3}}=50\sqrt{\frac{5K}{3}}.

There is another, more elementary (than the closed interval method), option for estimating K — although in our examples I’d like it to be obvious so this is just information really. The triangle inequality holds for all real numbers x,y:

|x+y|\leq |x|+|y|.

Hence, along with the fact that |xy|=|x||y| and that |x|=x for x>0:

|f''(x)|=|-2\sin (x^2)-4x^2\cos(x^2)|\leq 2|\sin(x^2)|+4x^2|\cos(x^2)|.

Now |\sin x|\leq 1 and |\cos x|\leq 1 for all x\in\mathbb{R}. Also x^2 has it’s maximum on [0,1] at x=1:

|f''(x)|\leq 2+4x^2\leq 6.

Now |f''(x)|\leq 6 for all x\in[0,1] so in particular the maximum of |f''(x)|, namely K will also be less than 6. So although it’s not as ‘sharp’ as possible we can still take K=6 and guarantee that our inequality still holds. Above I do it with a general K.

This approximation of K to 6 compares rather with the actual value of K (found using Maple) of about  3.845.

Question 5 (a shortened version of)

Find the maximum error |E_S| when we use the Simpson’s Rule with n=10 to approximate \int_0^1 e^x\,dx. How large should n be to guarantee that the approximations S_n is accurate to 0.00001?

Solution

Now we have the formula:

|E_S|\leq \frac{K(b-a)^5}{180n^4},

where here K=\max_{x\in[a,b]}|f^{(iv)}(x)|. We know that b-a=1 and that n=10. All that remains to calculate is K. Now as f(x)=e^xf^{(iv)}(x)=e^x. Now e^x is an increasing function of x, hence it’s maximum is found when x is large as possible — in this case at 1. Hence K=e^1=e\approx 2.71828. Hence

|E_S|\leq \frac{e}{180(8)^4}\approx 0.000003.

How large to get closer that 0.00001 — well clearly less than (or equal ;-)) 8 in the case of Simpson’s Rule. We need to solve the inequality for n:

\frac{K(b-a)^5}{180n^4}<0.00001

\Rightarrow n^4>\frac{e}{180(0.00001)}=\frac{5000e}{9}

n>\sqrt[4]{\frac{5000e}{9}}\approx 6.2.

Now because the Simpson’s Rule is for even n, that n\geq 8 is both necessary and sufficient for the error to be less than 0.00001; i.e. the answer is 8.

Question 7*

Show that if p is a polynomial of degree 3 or lower, then Simpson’s Rule gives the exact value of \int_a^b p(x)\,dx.

Solution

Let p(x)=ax^3+bx^2+cx+d with a,b,c,d\in\mathbb{R}. Now

p'(x)=3ax^2+2bx+c

p''(x)=6ax+2b

p'''(x)=6a

p''''(x)=0.

Now if the fourth derivative of p is 0 for all x\in\mathbb{R}, then for any interval [a,b]\max_{x\in[a,b]}|f^{(iv)}(x)|=0; hence K=0 and so for any n\in\mathbb{N}:

|E_S|=\frac{K(b-a)}{180n^4}=0,

that is the error in Simpson’s Rule is zero — that is Simpson’s Rule gives the exact value of the integral \bullet

Advertisement