|
|
Regula Falsi Method
Hello Guys,
I've been trying to generate code for the Regula Falsi Method to find the roots of a function. Below is the code but i keep the following error message:
""" ??? Undefined function or method 'Regula_Falsi' for input arguments of type 'inline'. """""
function [c,k] = Regula_Falsi(f, a, b, tol,Kmax)
if nargin < 4, tol = 1e-4;end
Kmax =1+fix((log(b-a)-log(tol))/log(2));
if f(a)*f(b)>0
c = 'failure';
return
end
for k=1:Kmax
c=(b-((f(b)*(b-a))/(f(b)-f(a))));
if f(c)==0
return
end
if f(b)*f(c)>0
b=c;
else a=c;
end
if b-a<tol,return
end
end
c = 'failure';
Please Help.
Thank you!
|
|
0
|
|
|
|
Reply
|
Green
|
2/24/2011 5:51:04 AM |
|
You haven't shown your calling syntax, which is what the error is related to.
I assume that it is because you are not correctly declaring the function handle f.
Try the following
f = @(x) x.^2-1; % roots at +/- 1
a = 0;
b = 2;
[c,k] = Regula_Falsi(f,a,b)
Now this should stop your error, but you have another problem.
This test on the value at the root
if f(c)==0
return
end
will never succeed due to floating-point computation. You should replace it with something like
if abs(f(c)) < tol
return
end
Hth
Darren
|
|
0
|
|
|
|
Reply
|
Darren
|
2/24/2011 8:26:20 AM
|
|
|
1 Replies
615 Views
(page loaded in 1.795 seconds)
Similiar Articles: Regula Falsi Method - comp.soft-sys.matlabHello Guys, I've been trying to generate code for the Regula Falsi Method to find the roots of a function. Below is the code but i keep the followi... Regula Falsi Method. - comp.soft-sys.matlabHello, I am using the code below to find the zeros for a function f using Regula Falsi method. However, my code is not consistent. For example: ... bisection method - comp.soft-sys.matlabWhat is the syntax for this atan2 formula ? - comp.soft-sys.matlab ... Regula Falsi Method - comp.soft-sys.matlab You haven't shown your calling syntax ... bisection, newton, secant method. - comp.soft-sys.matlab ...Regula Falsi Method - comp.soft-sys.matlab bisection, newton, secant method. - comp.soft-sys.matlab ... Regula Falsi Method. - comp.soft-sys.matlab bisection, newton ... Matlab acker(A,B,p) method - comp.soft-sys.matlabRegula Falsi Method - comp.soft-sys.matlab Matlab acker(A,B,p) method - comp.soft-sys.matlab Regula Falsi Method. - comp.soft-sys.matlab Matlab acker(A,B,p) method - comp ... Roots - Bisection method - comp.soft-sys.matlabNewton's interpolation formula - comp.soft-sys.matlab Regula Falsi Method. - comp.soft-sys.matlab Newton's interpolation formula - comp.soft-sys.matlab ... matlab program for Newmark's Method - comp.soft-sys.matlab ...Regula Falsi Method - comp.soft-sys.matlab Regula Falsi Method. - comp.soft-sys.matlab Hello, I am using the code below to find the zeros for a function f using Regula ... Undefined function or method 'atan2' for input arguments of type ...Undefined function or method 'gt' for input arguments of type ... The old Google Groups will be going away soon, but ... Re: ??? Undefined function or method 'gt' for ... root finding routine - comp.soft-sys.math.mathematicaRegula Falsi Method. - comp.soft-sys.matlab Hello, I am using the code below to find the zeros for a function f using Regula Falsi ... root finding routine - comp.soft-sys ... What is the syntax for this atan2 formula ? - comp.soft-sys.matlab ...bisection method - comp.soft-sys.matlab What is the syntax for this atan2 formula ? - comp.soft-sys.matlab ... Regula Falsi Method - comp.soft-sys.matlab You haven't shown ... False position method - Wikipedia, the free encyclopediaThe false position method or regula falsi method is a term for problem-solving methods in arithmetic, algebra, and calculus. In simple terms, these methods begin by ... Regula Falsi Method - Cal State Fullerton WebModule. for. The Regula Falsi Method . Background. The Regula Falsi method is one of the bracketing methods for finding roots of equations. Implementation. 7/24/2012 9:58:37 PM
|
|
|
|
|
|
|
|
|