As far as I understood,
sub
stands for sub-index; If so, sqrt((a0+b0/2)*b0)
doesn't equal to sqrt(a sub (i+1) + b sub i)
in the formula. So, you have coded another formula than that written above.from math import sqrt, log def applog(n,x): a0=(1+x)/2 b0=sqrt(x) for i in range(n): a0=(a0+b0)/2 b0 = sqrt(a0 + b0) # This line was changed... return (x-1)/a0 for j in range(2, 45): error=(abs( applog(j,4)- (log(4)))) print(f"{j}:{error}")
Output:2:0.0053156365995163934
3:0.039090279331435385
4:0.061621145018602386
5:0.07728516949056563
6:0.08826319537752325
7:0.09595463102864743
8:0.10133370381925122
9:0.10508932614514
10:0.10770813826749515
11:0.10953258138230271
12:0.11080279652612712
13:0.11168674981804516
14:0.1123017079623232
15:0.11272943559557191
16:0.11302689201201455
17:0.11323373160573724
18:0.11337754927182253
19:0.11347754206638672
20:0.11354706207495191
21:0.11359539468519486
....
So, iterative process doesn't converge to the expected solution... The iterative formula seems to be wrong...