Regular Falsi (Main) .M
Regular Falsi (Main) .M
clc;
% Input Section
y = input('Enter non-linear equations: ');
a = input('Enter first initial guess: ');
b = input('Enter second initial guess: ');
e = input('Enter tolerable error: ');
N = input('Enter maximum number of steps: ');
if fa * fb > 0
disp('Error! Function has the same sign at both endpoints.');
return;
end
if tol < e
fprintf('Root is %f\n', c);
break;
end
if step > N
disp('Maximum number of steps exceeded.');
end
% Plotting error
figure(1);
plot(iterationData(:,1), iterationData(:,2), 'r-o');
xlabel('Number of iteration');
ylabel('Error');
title('Regula-Falsi Method');
legend('Error evolution');