Ma 449: Numerical Applied Mathematics Model Solutions to Homework Assignment 1 Prof. Wickerhauser Exercise 9(a*) of section 1.1, p.12 Let g(x) be the integral from 0 to x of t^2 cos(t). Then by the Second Fundamental Theorem of Calculus (2FT), we have g'(x)= x^2 cos(x). Exercise 9(b) of section 1.1, p.12 Let g(x) be the integral from 1 to x of exp(t^2). Then by the Second Fundamental Theorem of Calculus (2FT), we have g'(x)=exp(x^2). But the function we need to differentiate is f(x)=g(x^3), so we use the chain rule: (d/dx)f(x) = (d/dx)g(x^3) = 3 x^2 g'(x^3) = 3 x^2 exp(x^6). Exercise 11(b*) of section 1.1, p.12 Factor out 2/3 and apply the geometric sum formula to get 1/(1-1/3)=3/2 for the sum of 1/3^n from n=0 to infinity. The result is 1. Exercise 11(c) of section 1.1, p.12 Write 3/(n(n+1)) as 3*[ 1/n - 1/(n+1) ] to get a telescoping series: each term -1/(n+1) is cancelled by the 1/n term for the next n. Since 1/n tends to 0 as n tends to infinity, the only surviving term is 1/n for the first value of n, namely n=1. Thus the sum is 3*(1/1) = 3. Exercise 12(a) of section 1.1, p.13 Evaluate the first 4 derivatives of f(x) = x^(1/2) at x_0 = 1:: f'(x) = (1/2)x^(-1/2) ==> f'(1) = 1/2 f''(x) = (-1/4)x^(-3/2) ==> f''(1) = -1/4 f'''(x) = (3/8)x^(-5/2) ==> f'''(1) = 3/8 f''''(x) = (-15/16)x^(-7/2) ==> f''''(1) = -15/16 Also, f(1) = 1, so the 4th-degree Taylor polynomial of f is p(x) = 1+(1/2)(x-1)-(1/4)(x-1)^2+(3/8)(x-1)^3-(15/16)(x-1)^4+O((x-1)^5), where the O(x^5) estimate follows since f has a continuous 5th derivative at all x sufficiently close to 1.. Exercise 2(c*) of section 1.2, p.23 1111 1110 (base 2) = 128+64+32+16 +8+4+2 = 254 (base 10) Exercise 2(d) of section 1.2, p.23 10 0000 0111 (base 2) = 512 + 4+2+1 = 519 (base 10) Exercise 3(a*) of section 1.2, p.23 .11011 (base 2) = 1/2 + 1/4 + 1/16 + 1/32 = .84375 (base 10) Exercise 3(b) of section 1.2, p.23 .10101 (base 2) = 1/2 + 1/8 + 1/32 = .65625 (base 10) Exercise 1(a*) of section 1.3, p.37 Ex = |x-x^| ~ 0.00009; Rx = Ex/|x| ~ .00003; d= -log10(2*Rx) = 4 digits. Exercise 1(c) of section 1.3, p.37 Ex = |z-z^| = 0.000008; Rz = Ez/|z| ~ 0.12; d= -log10(2*Rx) ~ 0 digits. Exercise 5(c*) of Section 1.3, p.37. cos^2(x)-sin^2(x) = cos(2*x) Exercise 5(d) of Section 1.3, p.37. sqrt[(1+cos(x))/2] = sqrt[cos^2(x/2)] = |cos(x/2)| Exercise 11 of Section 1.3, p.38. Sum: cos(h) + sin(h) = 1 + h - h^2/2! - h^3/3! + h^4/4! + h^5/5! + O(h^6); Product: cos(h)*sin(h) = h - (2/3)h^3 + (2/15)h^5 + O(h^7); Algorithm 2(a) of Section 1.3, p.39. format short g; r(1)=0.994; % r0 in text n=1; while n<20, n=n+1; r(n)=(1/2)*r(n-1); end exact = (1/2).^(1:20); % exact values abserr = abs(r - exact); relerr = abs(r - exact )./exact; [(1:n)' r' exact' abserr' relerr'] 1 0.994 1 0 0 2 0.497 0.5 0.003 0.006 3 0.2485 0.25 0.0015 0.006 4 0.12425 0.125 0.00075 0.006 5 0.062125 0.0625 0.000375 0.006 6 0.031062 0.03125 0.0001875 0.006 7 0.015531 0.015625 9.375e-05 0.006 8 0.0077656 0.0078125 4.6875e-05 0.006 9 0.0038828 0.0039062 2.3438e-05 0.006 10 0.0019414 0.0019531 1.1719e-05 0.006 11 0.0009707 0.00097656 5.8594e-06 0.006 12 0.00048535 0.00048828 2.9297e-06 0.006 13 0.00024268 0.00024414 1.4648e-06 0.006 14 0.00012134 0.00012207 7.3242e-07 0.006 15 6.0669e-05 6.1035e-05 3.6621e-07 0.006 16 3.0334e-05 3.0518e-05 1.8311e-07 0.006 17 1.5167e-05 1.5259e-05 9.1553e-08 0.006 18 7.5836e-06 7.6294e-06 4.5776e-08 0.006 19 3.7918e-06 3.8147e-06 2.2888e-08 0.006 20 1.8959e-06 1.9073e-06 1.1444e-08 0.006 Algorithm 2(b) of Section 1.3, p.39. format short g; p(1)=1; % p0 in text p(2)=0.497; % p1 in text n=2; while n<20, n=n+1; p(n)=(3/2)*p(n-1)-(1/2)*p(n-2); end exact = (1/2).^(1:20); % exact values abserr = abs(p - exact); relerr = abs(p - exact )./exact; [(1:n)' p' exact' abserr' relerr'] 1 1 0.5 0.5 1 2 0.497 0.25 0.247 0.988 3 0.2455 0.125 0.1205 0.964 4 0.11975 0.0625 0.05725 0.916 5 0.056875 0.03125 0.025625 0.82 6 0.025438 0.015625 0.0098125 0.628 7 0.0097188 0.0078125 0.0019063 0.244 8 0.0018594 0.0039062 0.0020469 0.524 9 -0.0020703 0.0019531 0.0040234 2.06 10 -0.0040352 0.00097656 0.0050117 5.132 11 -0.0050176 0.00048828 0.0055059 11.276 12 -0.0055088 0.00024414 0.0057529 23.564 13 -0.0057544 0.00012207 0.0058765 48.14 14 -0.0058772 6.1035e-05 0.0059382 97.292 15 -0.0059386 3.0518e-05 0.0059691 195.6 16 -0.0059693 1.5259e-05 0.0059846 392.2 17 -0.0059846 7.6294e-06 0.0059923 785.42 18 -0.0059923 3.8147e-06 0.0059961 1571.9 19 -0.0059962 1.9073e-06 0.0059981 3144.7 20 -0.0059981 9.5367e-07 0.005999 6290.4 Algorithm 2(c) of Section 1.3, p.39. format short g; q(1)=1; % q0 in text q(2)=0.497; % q1 in text n=2; while n<20, n=n+1; q(n)=(5/2)*q(n-1)-q(n-2); end exact = (1/2).^(1:20); % exact values abserr = abs(q - exact); relerr = abs(q - exact )./exact; [(1:n)' q' exact' abserr' relerr'] 1 1 0.5 0.5 1 2 0.497 0.25 0.247 0.988 3 0.2425 0.125 0.1175 0.94 4 0.10925 0.0625 0.04675 0.748 5 0.030625 0.03125 0.000625 0.02 6 -0.032688 0.015625 0.048313 3.092 7 -0.11234 0.0078125 0.12016 15.38 8 -0.24817 0.0039062 0.25208 64.532 9 -0.50809 0.0019531 0.51004 261.14 10 -1.022 0.00097656 1.023 1047.6 11 -2.047 0.00048828 2.0475 4193.3 12 -4.0955 0.00024414 4.0958 16776 13 -8.1918 0.00012207 8.1919 67108 14 -16.384 6.1035e-05 16.384 2.6843e+05 15 -32.768 3.0518e-05 32.768 1.0737e+06 16 -65.536 1.5259e-05 65.536 4.295e+06 17 -131.07 7.6294e-06 131.07 1.718e+07 18 -262.14 3.8147e-06 262.14 6.8719e+07 19 -524.29 1.9073e-06 524.29 2.7488e+08 20 -1048.6 9.5367e-07 1048.6 1.0995e+09