summaryrefslogtreecommitdiff
path: root/50/DEPENDENCIES/regulafalsi.sce
blob: 1b93787bfff2fb7e12c9ec2be1f04a0bc51fcd83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
function [x]=regulafalsi(a,b,f)
    N=100;
    PE=10^-5;
    for n=2:1:N
        x=a-(a-b)*f(a)/(f(a)-f(b));
        if abs(f(x))<=PE then break;
        elseif (f(a)*f(x)<0) then b=x;
            else a=x;
        end
    end
    disp(n," no. of iterations =")
endfunction