Scilab Program - newton raphson method while loop - IProgramX

Program

function[]=nf(x,d,z)
    while(abs(z(x))>d)
        if(derivative(z,x)<>0)
            x=x-z(x)/derivative(z,x)
        end
    end
    printf('Root by newton raphson method=%f',x)
    endfunction

Output:

-->deff('z=f(x)','z=x*exp(x)-2')

-->nf(2,50,f)
Root by newton raphson method=2.000000 

Post a Comment

0 Comments