You are on page 1of 1

In[1]:= Array[x, 50];

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;
WhileAbs[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

In[9]:= Plot[{x ^ 3 + 3 * x ^ 2 - 1}, {x, - 5, 5}]

100

50
Out[9]=

-4 -2 2 4

-50

In[10]:= i
Out[10]= 7

You might also like