summaryrefslogtreecommitdiff
path: root/50/DEPENDENCIES/secant65.sce
blob: 5d7d4e52c9c154804f66038f64e051ad58305eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
function [x]=secant65(a,b,f)
    deff('[y]=g(x)','y=-f(x)^2/(f(x-f(x))-f(x))'); 
    N=4;             // define max. no. iterations to be performed
    PE=10^-15           // define tolerance for convergence
     for n=1:1:N       // initiating for loop
        x=a-(b-a)*g(a)/(g(b)-g(a));  
        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