You are on page 1of 6

COT4501 Spring 2012

Homework VII
The assignment is due in class on Thursday, April 19, 2012. There are ve regular problems and one computer problem (using MATLAB). For written problems, you need to show your work and it is insufcient to just give the results or answers. For the computer problems, turn in your results (e.g., graphs, plots, simple analysis and so on) and also a printout of your (MATLAB) code. Problem 1 (30pts) 1. True or false: Evaluating a denite integral is always a well-conditioned problem. 2. True of false: The degree of a quadrature rule is the degree of the interpolating polynomial on which the rule is based. 3. How can you estimate the error in a quadrature rule without computing the derivatives of the integrand function that would be required by a Taylor series expansion? 4. Newtwon-Cotes and Gaussian quadrature rules are both based on polynomial interpolation. What specic property characterizes a Newton-Cotes quadrature rule for a given number of nodes? What specic property characterizes a Gaussian quadrature rule for a given number of nodes? 5. Suppose that the quadrature rule
b n

f (x)dx
a i=1

wi f (xi )

is exact for all constant functions. What does this imply about the weights wi or the nodes xi ? 6. For each of the following properties, state which type of quadrature, Newton-Cotes or Gaussian, more accurately ts the description: Easier to compute nodes and weights Easier to apply for a general interval [a, b] More accurate for the same number of nodes Has maximal degree for the number of nodes Nodes easy to reuse as order of rule changes 1

Solution 1. True 2. True 3. by using the E(f ) 4.


T (f )m(f ) 3

(a) it chooses equally spaced points in the interval [a, b] (b) weights and nodes chosen to maximize degree of resulting rule.

5. Since integration of the constant function (f (xi ) = c) is just (b a)c the summation of the weights is equal to (b a). The weights could be replaced by single weight and we just need value on single node. 6. (a) Newton-Cotes (b) Newton-Cotes (c) Gaussian (d) Gaussian (e) Newton-Cotes Problem 2 (15pts) 1. Compute the approximate value of the integral then by the trapezoid rule.
1 0

x3 dx, rst by the midpoint rule and

2. Use the difference between these two results to estimate the error in each of them. 3. Combine the two results to obtain the Simpsons rule approximation to the integral. 4. Would you expect the latter to be exact for this problem? Why? Solution 1. Mf = (10)f (1/2) = 1(1/2)3 = 1/8; Tf = (10)(f (0)+f (1))/2 = (0+1)/2 = 1/2 2. E (T M )/3 = (1/2 1/8)/3 = 1/8 so EM 1/8 and ET 1/4 3. S = 2M/3 + T /3 = 2(1/8)/3 + (1/2) = 3 = 1/12 + 1/6 = 1/4 4. Yes, because Simpsons rule integrates all polynomials of degree 3 exactly.

Problem 3 (20pts) Suppose that Lagrange interpolation at a given set of nodes x1 , , xn is used to derive a quadrature rule. Prove that the corresponding weights are given by the integrals of the Lagrange basis functions
b

wi =
a

li (x)dx,

for i = 1, ..., n. Solution Given a set of nodes xi , i = 1, . . . , n the Lagrange polynomial interpolating the corresponding values of the integrand function f is
n

p(x) =
i=1

f (xi )li (x)

we therefore have
b b n n b

p(x)dx =
a a i=1

f (xi )li (x)dx =


i=1

f (xi )
a

li (x)dx

comparing it with the quadrature rule we can drive that


b

wi =
a

li (x)dx,

Problem 4 (20pts) Given a sufciently smooth function f : R R, use Taylor series to derive a second-order accurate, one-sided difference approximation to f (x) in terms of the values of f (x), f (x + h), and f (x + 2h). Solution In the Taylor series expansion f (x + h) = f (x) + f (x)h + solving for the f (x) f (x) = f (x + h) f (x) f (x) f (x) 2 h h + ..., h 2 6 f (x) f (x) (2h)2 + (2h)3 + . . . , 2 6 f (x) 2 f (x) 3 h + h + ..., 2 6

similarly using Taylor series f (x + 2h) = f (x) + f (x)2h + and solving for the f (x) f (x) = f (x) 2 f (x + 2h) f (x) f (x)h 2 h + ..., 2h 3 3

If we now subtract the second of these series forf (x) from twice the rst and ignoring higher powers 3f (x) + 4f (x + h) f (x + 2h) f (x) 2h its second order accurate and one sided difference approximation to f (x) Problem 5 (20pts) Archimedes approximated the value of by computing the perimeter of a regular polygon inscribing or circumscribing a circle of diameter 1. The perimeter of an inscribed polygon with n sides is given by pn = n sin(/n), and that of a circumscribed polygon by qn = n tan(/n), and these values provide lower and upper bounds, respectively on the value of . 1. Using the power series expansions for the sine and tangent functions, show that pn an qn can be expressed in the form pn = a0 + a1 h2 + a2 h4 + .... and qn = b0 + b1 h2 + b2 h4 + .... where h = 1/n. What are the true values of a0 and b0 ? 2. Given the values p6 = 3.0000 and p12 = 3.1058, use Richardson extrapolation to produce a better estimate for . similarly, given the values q6 = 3.4641 and q12 = 3.2154, use Richardson extrapolation to produce a better estimate for . Solution sin(x) = x so x3 x 5 x7 + + ... 3! 5! 7!

pn = nsin( ) n 3 5 7 pn = h2 + h4 + h6 + . . . 3! 5! 7! where h = 1/n, hence a0 = Similarly for the tangent function tan(x) = x + x3 2x5 17x7 + + + ... 3 15 315 4

therefore qn = +

3 2 2 5 4 17 7 6 h + h + h + ... 3 15 315

therefore b0 = Using the Richardson extrapolation with p = 2 and q = 2 a0 = F (1/6) + b0 = F (1/6) + 3 3.1058 F (1/6) F (1/12) =3+ = 3.1411 2 1 2 0.25 1

F (1/6) F (1/12) 3.4641 3.2154 = 3.4641 + = 3.1325 22 1 0.25 1

Computer Problem 1 (30pts) Use numerical integration to verify or refute each of the following conjectures 1.
0 1

x3 dx = 0.4

2.
0

10

50 dx = 0.5 (2500x2 + 1)
1 0

3.

1 dx = 0.4 1 + 10x2
1 2

4.
0

e9x + e1024(x 2 ) dx = 0.2


100 9

5.

1 |x|

dx = 26

6.
0

10

25e25x dx = 1 7.
0 1

log(x)dx = 1 Solution 5

1 2 3

5 6 7 8 9 10 11 12 13 14 15

function cp08_04 % numerical integration to test conjectures fs = {'sqrt(x.3)' '1./(1+10*x.2)' ... '(exp(-9*x.2)+exp(-1024*(x-0.25).2))/sqrt(pi)' ... '50./(pi*(2500*x.2+1))' ... '1./sqrt(abs(x))' '25*exp(-25*x)' 'log(x)'}; c = [0.4 0.4 0.2 0.5 26 ... 1 -1]; a = [0 0 0 0 -9 0 1e-10]; b = [1 1 1 10 100 10 1]; disp('Truth or falsity of conjecture for given tolerance using quadl:'); disp(' tol abcdefg'); for k = 1:7 tol = 10(-k); for i = 1:7 f = inline(fs{i},'x'); if abs(quadl(f,a(i),b(i),tol)-c(i)) tol, torf(i) = 'T'; else torf(i) = 'F'; end end; fprintf('%8.1e %s\n', tol, torf); end; disp(' ');