Professional Documents
Culture Documents
Nmax=5
epsilon=0.00001
fHxL := Cos@xD
f'HxL:= - Sin@xD
In[55]:= x0 = 1;
Nmax = 5;
eps = 0.0001;
f@xD := Cos@xD;
For@ i = 1, i <= Nmax, i ++,
x1 = N@x0 - Hf@xD . x ® x0L Hf '@xD . x ® x0LD;
If @Abs@x1 - x0D < eps, Return@x1D, x0p = x0; x0 = x1D;
Print@"In ", i, "th Number of iterations the approximation to root is : ", x1D;
Print@" Estimated error is : ", Abs@x1 - x0pDDD;
Print@"the final approximation of root is : ", x1D;
Print@" Estimated error is : ", Abs@x1 - x0DD;
Plot@f@xD, 8x, - 1, 3<D
2 Untitled-3
1.0
0.5
Out[60]=
-1 1 2 3
-0.5
-1.0
f'HxL:= - Sin@x$6598D
0.5
Out[63]=
-1 1 2 3
-0.5
-1.0