

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Fall 2007
Description and Objectives Consider the equation e x^ x Estimate the real root of this equation in the following ways. (a) Graphically by plotting the functions e-x^ and x. (b) Graphically by plotting the function f ( x ) e x^ x (c) Using three iterations of the bisection method, with initial guesses xl = 0 and xu = 2 (d) Using three iterations of the false-position method, with initial guesses xl = 0 and xu = 2 MATLAB Code % HW 5: Root Finding Exploration % --- define functions f1 = @(x) exp(-x) - x; f2 = @(x) exp(-x); f3 = @(x) x; % --- course spacing x = linspace(0,1); y1 = f1(x); y2 = f2(x); y3 = f3(x); subplot(2,2,1) plot(x,y1), xlabel('x'), ylabel('exp(-x)-x'), grid subplot(2,2,3) plot(x,y2,x,y3), xlabel('x'), ylabel('exp(-x) and x'), grid % --- refined spacing x = linspace(0.5,0.6); y1 = f1(x); y2 = f2(x); y3 = f3(x); subplot(2,2,2) plot(x,y1), xlabel('x'), ylabel('exp(-x)-x'), grid subplot(2,2,4) plot(x,y2,x,y3), xlabel('x'), ylabel('exp(-x) and x'), grid 1
Results 0 0.5 1 1.5 2
1
2 x exp(-x) and x 0.5 0.55 0. -0. 0
x exp(-x)-x 0.5 0.55 0.
x exp(-x) and x These graphs show that the root is something like xr = 0.56 or 0. (c) Bisection Iteration xl xu = xu – xl xr 1 0 2 2 1 2 0 1 1 0. 3 0.5 1 0.5 0. After 3 iterations of the bisection method, our estimate of the root is xr = 0.75. (d) False Position Iteration xl xu xr 1 0 2 0. 2 0 0.6982 0. 3 0 0.5815 0. After 3 iterations of the false position method, our estimate of the root is xr = 0.5687. This is quite a bit more accurate than the estimate after 3 iterations using the bisection. 2