Monday, 9 July 2012

Ragula Falsi Method


Regula-Falsi Method
The Regula-Falsi Method (sometimes called the False Position Method) is a method used to find a numerical estimate of an equation. This method attempts to solve an equation of the form f(x) = 0. (This is very common in most numerical analysis applications.) Any equation can be written in this form. This algorithm requires a function f(x) and two points a and b for which f(x) is positive for one of the values and negative for the other. We can write this condition as f(a)×f(b)<0. Starting criteria is same as bisection method does, it takes two values to get it started.


If the function f(x) is continuous on the interval [a,b] with f(a)×f(b)<0, the algorithm will eventually converge to a solution.
This algorithm cannot be implemented to find a tangential root. This situation occurs when the graph is parallel to x-axis. That is a root that is tangent to the x-axis and either positive or negative on both side of the root. For example f(x) = (x-3)2, has a tangential root at x=3. In this situation this methods get fail and does not converges towards root.
Stopping Conditions
Aside from lucking out and actually hitting the root, the stopping condition is usually fixed to be a certain number of iterations or for the Standard Cauchy Error in computing the Regula-Falsi Point (xrfp) to not change more than a prescribed amount (usually denoted e).

Matlab Code
function [c,err,yc]=regula(f,a,b,delta,epsilon,max1)
ya=feval(f,a);
yb=feval(f,b);
if ya*yb>0
    disp('Note: f(a)*f(b) >0'),
    break,
end
for k=1:max1
    dx=yb*(b-a)/(yb-ya);
    c=b-dx;
    ac=c-a;
    yc=feval(f,c);
    if yc==0,break;
    elseif yb*yc>0
        b=c;
        yb=yc;
    else
        a=c;
        ya=yc;
    end
    dx=min(abs(dx),ac);
    if abs(dx)<delta,break,end
    if abs(yc)<epsilon, break,end
end

c;
err=abs(b-a)/2;
yc=feval(f,c);

No comments:

Post a Comment