Question: MATLAB question(do the No. 2 question) function ModRegFal = ModRegFal(a, b, n) format long; a = input('Enter a value for lower boundary a: '); b

MATLAB question(do the No. 2 question) MATLAB question(do the No. 2 question) function ModRegFal = ModRegFal(a, b, n)

format long; a = input('Enter a value for lower boundary a: ');

b = input('Enter a value for upper boundary b: '); n =

function ModRegFal = ModRegFal(a, b, n) 
format long; 
a = input('Enter a value for lower boundary a: '); b = input('Enter a value for upper boundary b: '); n = input('How small should should the error be (to what -power)? '); 
if (f(a)*f(b) > 0 ) disp ('Invalid values of a and b. Program Closing') return; end; 
F = f(a); G = f(b); w0 = a; 
while (1) wn = (G*a-F*b)/(G-F); disp([a b wn w0]) %% just checking where the values are, and it they look correct if f(a)*f(wn) > 0 disp('ranif 1')%% just checking where the values are, and it they look correct b = wn; G = f(wn); if f(w0)*f(wn) > 0 F = F/ 2; end; disp('ranif 2')%% just checking where the values are, and it they look correct disp([a b wn w0])%% just checking where the values are, and it they look correct else a = wn; F = f(wn); if f(w0)*f(wn) > 0 disp('ranif 3')%% just checking where the values are, and it they look correct disp([a b wn w0])%% just checking where the values are, and it they look correct G = G/ 2; end; end disp([a b wn w0]) if (abs((wn - w0)/wn)  

plot (error)

grid on;

title('Plot of error');

xlabel('iterations');

ylabel('Error');

Modified Regula Falsi Method Frequently, in the regula falsi method, one of the endpoints of the interval stays the same in all iterations, while the other endpoint advances toward the root (Fig.1). In the modified regula falsi method, when this situation occurs, the straight line that connects the endpoints of the interval is replaced with a line that has a smaller slope. As shown in Fig.2, this is done by dividing by 2 the value of the function at the end point that stays the same. Consequently, the line intersects the x-axis closer to the root. f(x)t Abi) NS2 Actual62 solution Ka) Figure 1: Regula Falsi method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!