Math 04A - Homework Due 6/0 Section. -, 7a, 7d, Section. - 6, 8, 0 Section. - 5, 8, 4 Section. - 5,..a Use three-digit chopping arithmetic to compute the sum 0 i= first by i + + +, and then by + + +. Which method is more 4 00 00 8 accurate, and why? Using three-digit chopping arithmetic, + 4 + 9 + + 00 while 00 + 8 + 64 + + = ( ((.00 + 0.50) + 0.) + ) + 0.000) =.5, = ( ((0.000+0.0)+0.056)+ )+.00) =.54. The actual value is.5498. The first sum is less accurate because the smaller numbers are added last, resulting in significant round-off error...b Write an algorithm (pseudocode) to sum the finite series N i= x i in reverse order. (Here, the input is N, x,..., x N, and the output is the sum). INPUT: N, x,..., x N OUTPUT: N i= x i Step : Set i = N, s = 0. Step : While i > 0 do Steps -4 Step : Set s = s + /i. Step 4: Set i = i. Step 5: OUTPUT s...7a Find the rate of convergence of lim h 0 sin h h = (Hint: use Taylor series). sin(h) h = h h 6 cos(ξ) h = h 6 sin(ξ) = O(h )...7b Find the rate of convergence of lim h 0 e h h =. e h h + = h h eξ h + = h eξ = O(h).
.. Construct an algorithm (pseudocode) that has as input an integer n, numbers x 0, x,..., x n, and a number x that produces as output the product (x x 0 )(x x ) (x x n ). INPUT: n, x 0,..., x n, x. OUTPUT: n i=0 (x x i). Step : Set i = 0, p =. Step : While i n do Steps -4 Step : Set p = p (x x i ). Step 4: Set i = i +. Step 5: OUTPUT p...6 Use the Bisection method to find solutions accurate to within 0 5 for the following problems: a x e x = 0, x [, ]. >> bisection_method( *x-exp(x),,,000,0^-5).58666999 b x + cos x e x = 0, x [0, ]. >> bisection_method( x+*cos(x)-exp(x),0,,000,0^-5) 0.976768496544 c x 4x + 4 ln x = 0, x [, ] and x [, 4]. >> bisection_method( x^-4*x+4-log(x),,,000,0^-5).4966597656 >> bisection_method( x^-4*x+4-log(x),,4,000,0^-5).0570608066406 d x + sin(πx) = 0, x [0, 0.5] and x [0.5, ]. >> bisection_method( x+-*sin(pi*x),0,0.5,000,0^-5) 0.0607996406 >> bisection_method( x+-*sin(pi*x),0.5,,000,0^-5) 0.68968688964844
..8a Sketch the graphs of y = x and y = tan x. 0 8 6 4 0 x tan(x) 0 4 6 8 0..8b Use the bisection method to find an approximation to within 0 5 to the first positive value of x with x = tan x. From the sketch, we see that the first positive fixed-point occurs somewhere between 4 and 5. >> bisection_method( x-tan(x),4,5,000,0^-5) 4.49458595..0 A particle starts at rest on a smooth inclined plane whose angle θ is changing at a constant rate dθ = ω < 0. At the of t seconds, the position of the dt object is given by x(t) = g ( ) e ωt e ωt sin(ωt). ω Suppose the particle has moved.7 ft in s. Find, to within 0 5, the rate ω at which θ changes. Assume that g =.7 ft/s. Substituting the appropriate values, we find ω by finding the root of f(x) =.7 ( ) e x e x sin(x).7. x >> bisection_method( -.7/(*x^)*((exp(x)-exp(-x))/... -sin(x))-.7,-,-0.,000,0^-5) -0.70555474609
..5 Use a fixed-point iteration method to determine a solution accurate to within 0 for x 4 x = 0 on [, ]. Use p 0 =. After first rearranging the equation to get (x + ) /4 = x, we use attached code (fixed_point_method.m) to get >> fixed_point_method( (*x^+)^(/4),,000,0^-) Took 6 iterations..94699898677..8 Use theorem. to show that g(x) = x has a unique fixed point on [, ]. Use fixed-point iteration to find an approximation to the fixed point accurate to within 0 4. Use corollary.4 to estimate the number of iterations required to achieve 0 4 accuracy, and compare this theoretical estimate to the number actually needed. Since g is decreasing, we know that max g(x) = g( ) 0.7970056 <, min g(x) = g() = 0.5 >, and so g(x) [, ]. Since g (x) = x ln() is negative and increasing, we know that g (x) g ( ) 0.55058 = k <. Then g satisfies the conditions of theorem., and so g has a unique fixed point on the interval [, ]. Using the attached code (fixed_point_method.m), we get >> p = 0.6485744504985984; >> abs(p-fixed_point_method( ^(-x),/,7)).95777565947e-04 >> abs(p-fixed_point_method( ^(-x),/,8)) 8.67877988e-05 so 8 iterations are necessary to be within 0 4 of the true fixed point p = 0.6485744504986. By corollary.4, p n p kn, and so k n 0 4 ln(k n ) ln( 0 4 ) n ln( 0 4 ) ln(k).5747058. 4
..4 Use a fixed-point iteration method to determine a solution accurate to within 0 4 for x = tan x, for x [4, 5]. + x and using the at- Rearranging the equation so that g(x) = tan(x) x tached code (fixed_point_method.m), we get >> fixed_point_method( /tan(x)-/x+x,4.5,000,0^-4) Took iterations. 4.49409457997..5 Use Newton s method to find solutions accurate to within 0 4 for the following problems: a x x 5 = 0, x [, 4]. Using the attached code (newtons_method.m), we get >> newtons_method( x^-*x^-5, *x^-4*x,.5,000,0^-4) Took 4 iterations.6906474480865 b x + x = 0, x [, ]. Using the attached code (newtons_method.m), we get >> newtons_method( x^+*x^-, *x^+6*x,-.5,000,0^-4) Took 5 iterations -.879854578 c x cos x = 0, x [0, π/]. Using the attached code (newtons_method.m), we get >> newtons_method( x-cos(x), +sin(x),pi/4,000,0^-4) Took iterations 0.7908556 d x 0.8 0. sin x = 0, x [0, π/]. Using the attached code (newtons_method.m), we get >> newtons_method( x-0.8-0.*sin(x), -0.*cos(x),pi/4,000,0^-4) Took iterations 0.9648876957 5
.. Player A will shut out (win by a score of -0) player B in a game of raquetball with probability P = + p ( p ), p + p where p is the probability that A will win any specific rally (indepent of the server). Determine, to within 0, the minimal value of p that will ensure that A will shut out B in at least half the matches they play. From a sketch of the graph, we see that p is close to 0.8, so we use the bisection method (bisection_method.m) with an initial interval [0.7, 0.9] ( ) with function f(x) = +x x x+x 0.5: >> bisection_method( (+x)/*(x/(-x+x^))^-0.5,... 0.7,0.9,000,0^-4) 0.84968750000000 6
Code %%% bisection_method.m %%% function p = bisection_method(fstring,a,b,n,tol) i=; f = inline(fstring); FA = f(a); while ( i <= N ) p = (a+b)/; FP = f(p); if( FP == 0 (b-a)/ < TOL ) return; if( FA*FP > 0 ) a = p; FA = FP; else b = p; i = i+; %%% of bisection_method.m %%% %%% fixed_point_method.m %%% function p = fixed_point_method(fstring,p0,n,tol) i = ; f = inline(fstring); while i < N p = f(p0); if( nargin == 4 && abs(p-p0) < TOL ) 7
fprintf( Took %i iterations.,i); return; p0 = p; i = i+; %%% of fixed_point_method.m %%% %%% newtons_method.m %%% function p = newtons_method(fstring,fpstring,p0,n,tol) i = ; f = inline(fstring); fp = inline(fpstring); while( i <= N ) p = p0-f(p0)/fp(p0); if( abs(p-p0) < TOL ) fprintf( Took %i iterations,i); return; i = i+; p0=p; %%% newtons_method.m %%% 8