Question
SUBJECT: MODIFIED FALSE POSITION METHOD. Please RESET: il and iu . it looks like I have an error under ELSE IF section (iu). % Modified
SUBJECT: MODIFIED FALSE POSITION METHOD. Please RESET: il and iu. it looks like I have an error under ELSE IF section (iu).
% Modified False Position
xl = 0; % xl = 1; xu = 5; % xu = 4; precision = 10^-5;% precision = 10^-5; f = @ (x) 3*(x^2)-5; % ea = approximate error
iteration_count = 0; fxl = f(xl); fxu = f(xu); xr = xu - (f(xu)*(xl-xu))/(fxl-f(xu)); ea = abs((xl-xu)/(xl+xu))*100; % ea = approximate error
il = 0; iu = 0;
while ea > precision xr = xu - (f(xu)*(xl-xu))/(fxl-f(xu)); ea = abs((xl-xu)/(xl+xu))*100; % ea = approximate error iteration_count = iteration_count + 1; if fxl * f(xr) < 0 xu = xr; iu = 0; il = il + 1; if il >= 2 fl = fl/2; il = 0; end elseif fxl * f(xr) > 0 xl = xr; il = 0; iu = iu + 1; if iu >= 2 fl = fl/2; iu = 0; end end end bisect = xr; fprintf(['Using the Modified False Position Method, the root is located at ' ... num2str(bisect) ' after ' num2str(iteration_count) ' iterations.']);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started