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) = f(1)/0! + f'(1)(x-1)/1! + f''(1)(x-1)^2/2! + + f'''(1)(x-1)^3/3! + f''''(1)(x-1)^4/4! + O((x-1)^5) = 1+(1/2)(x-1)-(1/8)(x-1)^2+(1/16)(x-1)^3-(5/128)(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= 1-log10(2*Rx) ~ 5.2 ==> 5 digits. Exercise 1(c) of section 1.3, p.37 Ex = |z-z^| = 0.000008; Rz = Ez/|z| ~ 0.12; d= 1-log10(2*Rx) ~ 1.6 ==> 1 digit. 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).^(0:19); % exact values abserr = abs(p - exact); relerr = abs(p - exact )./exact; [(1:n)' p' exact' abserr' relerr'] 1 1 1 0 0 2 0.497 0.5 0.003 0.006 3 0.2455 0.25 0.0045 0.018 4 0.11975 0.125 0.00525 0.042 5 0.056875 0.0625 0.005625 0.09 6 0.025438 0.03125 0.0058125 0.186 7 0.0097188 0.015625 0.0059062 0.378 8 0.0018594 0.0078125 0.0059531 0.762 9 -0.0020703 0.0039062 0.0059766 1.53 10 -0.0040352 0.0019531 0.0059883 3.066 11 -0.0050176 0.00097656 0.0059941 6.138 12 -0.0055088 0.00048828 0.0059971 12.282 13 -0.0057544 0.00024414 0.0059985 24.57 14 -0.0058772 0.00012207 0.0059993 49.146 15 -0.0059386 6.1035e-05 0.0059996 98.298 16 -0.0059693 3.0518e-05 0.0059998 196.6 17 -0.0059846 1.5259e-05 0.0059999 393.21 18 -0.0059923 7.6294e-06 0.006 786.43 19 -0.0059962 3.8147e-06 0.006 1572.9 20 -0.0059981 1.9073e-06 0.006 3145.7 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).^(0:19); % exact values abserr = abs(q - exact); relerr = abs(q - exact )./exact; [(1:n)' q' exact' abserr' relerr'] 1 1 1 0 0 2 0.497 0.5 0.003 0.006 3 0.2425 0.25 0.0075 0.03 4 0.10925 0.125 0.01575 0.126 5 0.030625 0.0625 0.031875 0.51 6 -0.032688 0.03125 0.063938 2.046 7 -0.11234 0.015625 0.12797 8.19 8 -0.24817 0.0078125 0.25598 32.766 9 -0.50809 0.0039062 0.51199 131.07 10 -1.022 0.0019531 1.024 524.29 11 -2.047 0.00097656 2.048 2097.2 12 -4.0955 0.00048828 4.096 8388.6 13 -8.1918 0.00024414 8.192 33554 14 -16.384 0.00012207 16.384 1.3422e+05 15 -32.768 6.1035e-05 32.768 5.3687e+05 16 -65.536 3.0518e-05 65.536 2.1475e+06 17 -131.07 1.5259e-05 131.07 8.5899e+06 18 -262.14 7.6294e-06 262.14 3.436e+07 19 -524.29 3.8147e-06 524.29 1.3744e+08 20 -1048.6 1.9073e-06 1048.6 5.4976e+08