summaryrefslogtreecommitdiff
path: root/50/DEPENDENCIES/modified_newton.sce
blob: 29d60f47be37aa7c692f8b0454cf4a7709f7a1f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

function x=modified_newton(x,f,fp)
    R=100;
    PE=10^-8;
    maxval=10^4;
        
    for n=1:1:R
        x=x-m*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