f = inline('x.^3 + 4*x.^2 - 10'); fp=inline('3*x.^2 + 8.*x'); a=1; b=2; x0 =1.5; x1 = x0-(f(x0)/fp(x0)); eps=1.0e-6; iter=0; if ((f(a)*f(b))< 0) while (abs(x1-x0) > eps) x0=x1; x1 = x0-(f(x0)/fp(x0)); iter=iter+1; fprintf('For iteration =%d \t , the solution is x0=%f\n',iter,x0) end fprintf('The final solution is x0 = %f \n',x0) ; else disp('There is no solution in [a,b]') end