functionscilab

How can i find all roots for a function using Newton Rapshon method in Scilab?


I need to find all roots for this function f(x)=-2x^4+x^3-2x+3 in given interval [-1.5 ; 1.5] with accuracy being <0.0001. Then i have to plot the relative mistakes. So i got this code but it's not working.

deff('y=f(x)','y=-2x^4+x^3-2x+3')
a=input("Enter value of interval a:")
b=input("Enter value of interval b:")
n=input("Enter the number of iteration n:")
x0=(a+b)/2
for i=1:n
    disp([i,x0])
    x1=x0-f(x0)/z(x0)
    if abs(x1-x0)<0.00001 then
        disp("We get required accuracy")
        break;
    end
    x0=x1
end

Solution

  • There are 2 pbs in your code;