Problem 5.7.
(a) Determine the roots of f(x) = -12 - 21x + 18x2 - 2.75x3 graphically. In addition determine the first root of the function with (b) bisection and (c) false position. For (b) and (c), use xl = -1 and xu = 0, and a stopping criterion of 1%.
Solution:
(a) Plot the graph using MATLAB. The commands are shown as below:
>> x = linspace(-1,8);
>> fx = -12-21*x+18*x.^2-2.75*x.^3;
>> plot(x,fx),grid,xlabel('x'),ylabel('f(x)')
(b) The root estimate using bisection method is xr = (xl + xu)/2. Begin the iteration with guesses of xl = -1 and xu = 0.
First iteration:
xl = -1 f(-1) = 29.75
xu = 0 f(0) = -12
xr = (-1+0)/2 = -0.50 f(-0.50) = 3.3438
f(-1)f(-0.50) = 99.4766 > 0. Therefore, the root lies in the upper interval, and xr becomes the lower limit for the next iteration, xl = -0.50.
Second iteration:
xl = -0.50 f(-0.50) = 3.3438
xu = 0 f(0) = -12
xr = (-0.50+0)/2 = -0.25 f(-0.25) = -5.5820
f(-0.50)f(-0.25) = -18.66496 < 0. Therefore, the root lies in the lower interval, and xr becomes the upper limit for the next iteration, xu = -0.25.
The approximate relative error is 100%.
The remainder of the iterations are displayed in the following table.
(c) The root estimate using false position method is xr = xu - f(xu)(xl - xu)/(f(xl) - f(xu)). Begin the iteration with guesses of xl = -1 and xu = 0.
First iteration:
xl = -1 f(-1) = 29.75
xu = 0 f(0) = -12
xr = -0.2874 f(-0.2874) = -4.4116
f(-1)f(-0.2874) = -131.2731 < 0. Therefore, the root lies in the lower interval, and xr becomes the upper limit for the next iteration, xu = -0.2874.
Second iteration:
xl = -1 f(-1) = 29.75
xu = -0.2874 f(-0.2874) = -4.4116
xr = -0.3795 f(-0.3795) = -1.2878
f(-1)f(-0.3795) = -38.3130 < 0. Therefore, the root lies in the lower interval, and xr becomes the upper limit for the next iteration, xu = -0.3795.
The approximate relative error is 24.3%.
The remainder of the iterations are displayed in the following table.
Hence, after 5 iterations, the approximate error finally falls below 1% and the computation can be terminated. The root estimate is -0.41402.
No comments:
Post a Comment