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

版本 1.0.0.0 (1.2 KB) 作者: N Narayan rao
REGULA-FALSI METHOD
117.0 次下载
更新时间 2016/8/22

查看许可证

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 .
for bisection method please refer previous uploaded bisection method
% 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

reference :
https://mat.iitm.ac.in/home/sryedida/public_html/caimna/transcendental/bracketing%20methods/regula-falsi/regula-falsi.html

引用格式

N Narayan rao (2024). Regulafalsi(f,a,b,tol) (https://www.mathworks.com/matlabcentral/fileexchange/58748-regulafalsi-f-a-b-tol), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2013a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0

image