![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhisL11iHdH7IVwHUukv2SZUcjSob4Y2JYoE-slojQFvoFrXE44tgOQdAg2noA3kN6dXOBlkvq6HaqFxjYwGn5smOY5kgKc-Ulke5gTvjwNC68DLGxFm7xC-IXhdjBQUwIerGY6ETqx0oI/s200/fntpackcover.png)
By this method if we choose a root
x0 = x0
then the closer root will be
x1 = x0 - f(x0) / f '(x0) and so on...
Now we directly write the following code in mathematica.
Clear["`*"]; f[x_] := x^3 + x^2 - 1; Plot[f[x],{x,-5,5}]; x0 = Input["Enter x0"]; tol = Input["Enter tolerance"]; n = Input["Enter total iteration"]; x1 = x0; Do[ x2 = x1 - f[x1]/f'[x1] //N; Print[i,PaddedForm[x2,{15,8}]]; If[Abs[x1-x2]<tol, {Print["The root is: ",x2], Exit[]}]; x1 = x2 ,{i,1,n}]; Print["Maximum iteration failed"];
When we will run it by hitting SHIFT + ENTER we will see the following graph.
Here we can see the root is near 1.
So we will input
x0 = 1
tol = .001
n = 25
Thus the method is done.