summaryrefslogtreecommitdiff
path: root/75/DEPENDENCIES/newton.sce
blob: 6f7557e3816f67ddd4a1ec84a71749c14217d404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function x=newton(x,f,fp)
    R=100;
    PE=10^-8;
    maxval=10^4;
        
    for n=1:1:R
        x=x-f(x)/fp(x); 
        if abs(f(x))<=PE then break
        end
        if (abs(f(x))>maxval) then error('Solution diverges');
            abort
            break
        end
    end
    disp(n," no. of iterations =")
endfunction