PAllen said:
Rechecking my work, I find that this is a very interesting case. The root is about .755, and g’(root) just under 1 in absolute value. However, by .8, abs(g’) is greater than 1. If the first iteration sends your guess above this, you won’t necessarily get convergence. So this is a case where the requirement of initial guess being close to the root is crucial. The iterations have to stay within the neighborhood where abs(g’) is less than 1. In this case, that means initial guess .71 is good, but .7 already send you outside the neighborhood. Also, because the derivative is close to 1 around the root, convergence is extremely slow. This method works best with g’ small in absolute value.
So the requirement of starting guess sufficiently close the root can be quantified by the requirement that iterations stay within the neighborhood where the derivative condition is met.
0 0.020000 0.999867 -0.013337 0.979867
1 0.999867 0.064367 -160.886288 0.935499
2 0.064367 0.998617 -0.043031 0.934250
3 0.998617 0.140340 -33.802368 0.858277
4 0.140340 0.993391 -0.094809 0.853052
5 0.993391 0.236176 -11.872960 0.757216
6 0.236176 0.981050 -0.163592 0.744875
7 0.981050 0.334837 -5.833554 0.646213
8 0.334837 0.961137 -0.241641 0.626300
9 0.961137 0.423981 -3.564515 0.537156
10 0.423981 0.936081 -0.322573 0.512100
11 0.936081 0.498330 -2.512975 0.437751
12 0.498330 0.909233 -0.401861 0.410903
13 0.909233 0.557522 -1.950111 0.351711
14 0.557522 0.883301 -0.476380 0.325778
15 0.883301 0.603480 -1.616932 0.279821
16 0.603480 0.859890 -0.544109 0.256410
17 0.859890 0.638732 -1.405123 0.221158
18 0.638732 0.839677 -0.603952 0.200945
19 0.839677 0.665649 -1.263369 0.174028
20 0.665649 0.822739 -0.655587 0.157089
21 0.822739 0.686193 -1.164873 0.136546
22 0.686193 0.808829 -0.699264 0.122636
23 0.808829 0.701897 -1.094509 0.106932
24 0.701897 0.797566 -0.735611 0.095670
25 0.797566 0.713931 -1.043190 0.083635
26 0.713931 0.788536 -0.765459 0.074605
27 0.788536 0.723177 -1.005173 0.065359
28 0.723177 0.781347 -0.789706 0.058170
29 0.781347 0.730300 -0.976675 0.051047
30 0.730300 0.775653 -0.809236 0.045353
31 0.775653 0.735800 -0.955118 0.039853
32 0.735800 0.771160 -0.824859 0.035360
33 0.771160 0.740054 -0.938699 0.031106
34 0.740054 0.767624 -0.837288 0.027570
35 0.767624 0.743350 -0.926126 0.024274
36 0.743350 0.764848 -0.847134 0.021497
37 0.764848 0.745908 -0.916459 0.018940
38 0.745908 0.762671 -0.854908 0.016763
39 0.762671 0.747895 -0.909002 0.014776
40 0.747895 0.760967 -0.861030 0.013072
41 0.760967 0.749439 -0.903236 0.011527
42 0.749439 0.759633 -0.865840 0.010194
43 0.759633 0.750641 -0.898769 0.008992
44 0.750641 0.758591 -0.869613 0.007950
45 0.758591 0.751576 -0.895303 0.007014
46 0.751576 0.757776 -0.872570 0.006200
47 0.757776 0.752305 -0.892611 0.005471
48 0.752305 0.757139 -0.874884 0.004835
49 0.757139 0.752872 -0.890518 0.004268
Apporximate root: 0.7528718305184433
You can see that it is converging even if the derivative is greater than 1. The columns are "Iteration #x_0# #g(x_0)# #g'(x_0)# tolerance"
Or, perhaps i made mistake in my code:
import math as mp
def g(x):
return (1-x**2)**(1/3)
def pg(x):
return (-2*x)*(1/3)*((1-x**2)**(-2/3))
x_0 =0.02
e = 0.0001
max_itr = 50
x_1 = g(x_0)
n=0
while(n<max_itr):
x_1 = g(x_0)
print("{:<10} {:<10.6f} {:<10.6f} {:<10.6f} {:<10.6f}".format(n,x_0,g(x_0), pg(x_0), abs(x_1 - x_0)))
if(abs(x_1 - x_0)< e):
print("Root found at ", x_1)
break;
x_0 = x_1
n+=1
print("Apporximate root: ", x_1)