Numerical Sheet#1 – Regula-Falsi Method


function [ x ] = findRootRegulaFalsi(f,a,b,epson,iter)

    fa = feval(f,a);
    fb = feval(f,b);

    for i=1:iter

        m  = (fb-fa)/(b-a);
        c = b - (fb/m);
        fc = feval(f,c);

        if(abs(fc) <epson || abs(a-b) <eps )
            break;
        elseif(fa*fc > 0)
            a =c;
            fa =fc;
        else 
            b =c;
            fb =fc;
        end
    end
    x = c;
end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: