Scilab Program - newton raphson method for loop - IProgramX

Program

function[]=nf(x,n,f)
    for i=1:n
        if(derivative(f,x)<>0)
            x=x-f(x)/derivative(f,x)
end

end
printf('root by newton raphson method=%f',x)
endfunction

Output:

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

-->nf(2,50,f)
root by newton raphson method=0.852606

Post a Comment

0 Comments