Professional Documents
Culture Documents
f[x_] := x ^ 3 + 3 * x ^ 2 - 1;
x[0] = - 5;
x[1] = x[0] - f[x[0]] f '[x[0]]; Print[N[x[0]]];
x[2] = x[1] - f[x[1]] f '[x[1]]; Print[N[x[1]]];
i = 2;
e = 0.0001;
WhileAbs[x[i - 1] - x[i - 2]] > e,
x[i] = x[i - 1] - f[x[i - 1]] f '[x[i - 1]];
Print[N[x[i]]];
i ++;
- 5.
- 3.86667
- 3.22207
- 2.94225
- 2.88212
- 2.87939
- 2.87939
100
50
Out[9]=
-4 -2 2 4
-50
In[10]:= i
Out[10]= 7