Regulafalsi(f,a,b,t​ol)

version 1.0.0.0 (1.17 KB) by
REGULA-FALSI METHOD

Updated 22 Aug 2016

The convergence process in the bisection method is very slow. It depends only on the choice of end points of the interval [a,b]. The function f(x) does not have any role in finding the point c (which is just the mid-point of a and b). It is used only to decide the next smaller interval [a,c] or [c,b]. A better approximation to c can be obtained by taking the straight line L joining the points (a,f(a)) and (b,f(b)) intersecting the x-axis.
the above function has two roots in between -1 to 1 and in between -1 to -2.
for 1st root we assign a=-1 ; b=1; and for 2nd root we assign a=-1; b=-2.
lets evaluate the -ve root .
% bisection vs regula falsi method

clear all
clc
x=-3:0.001:3;
y=cos(x)-x.*exp(x);
plot(x,y)
grid on
%%
a=-1;
b=-2;
tol=0.01;
myfun=inline('cos(x)-x.*exp(x)');
z=Regulafalsi(myfun,a,b,tol);
z=bisection(myfun,a,b,tol);

output :

iter a C b fa fb fc error=abs(a-c)
-------------------------------------------------------------------------------------------
0 -1.0000 -1.8619 -2.0000 0.9082 -0.1455 0.0023 0.8619
1 -1.8619 -1.8640 -2.0000 0.0023 -0.1455 -0.0000 0.0021
root = -1.864 found in 2 itterations
with approximate tolerance of 0.01
iter a c=(a+b)/2 b fa fb fc error(a-b)
-----------------------------------------------------------------------------------
0 -1.0000 -1.5000 -2.0000 0.9082 -0.1455 0.4054 1.0000
1 -1.5000 -1.7500 -2.0000 0.4054 -0.1455 0.1259 0.5000
2 -1.7500 -1.8750 -2.0000 0.1259 -0.1455 -0.0120 0.2500
3 -1.7500 -1.8125 -1.8750 0.1259 -0.0120 0.0565 0.1250
4 -1.8125 -1.8438 -1.8750 0.0565 -0.0120 0.0221 0.0625
5 -1.8438 -1.8594 -1.8750 0.0221 -0.0120 0.0050 0.0313
6 -1.8594 -1.8672 -1.8750 0.0050 -0.0120 -0.0035 0.0156
7 -1.8594 -1.8633 -1.8672 0.0050 -0.0035 0.0008 0.0078
root = -1.8633 found in 8 itterations
with approximate tolerance of 0.01

Cite As

N Narayan rao (2022). Regulafalsi(f,a,b,tol) (https://www.mathworks.com/matlabcentral/fileexchange/58748-regulafalsi-f-a-b-tol), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux