summaryrefslogtreecommitdiff
path: root/60/DEPENDENCIES/secantm.sce
blob: fa0f84e78ea2465a5b2484f0a6fcd86c3e80682a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
function [x]=secant(a,b,f)
    N=100;             // define max. no. iterations to be performed
    PE=10^-4           // define tolerance for convergence
     for n=1:1:N       // initiating for loop
        x=a-(a-b)*f(a)/(f(a)-f(b));  
        disp(x)
        if abs(f(x))<=PE then break; //checking for the required condition
        else a=b;
            b=x;
        end     
     end
     disp(n," no. of iterations =") //
endfunction