# this program test stability of computing power of golden mean # phi**n, phi =(sqrt(5.)-1.0)/2.0 # # Since default setting for float in Python is double precision, # we must work harder to show this instability (i.e. run upto i = 59). # import math p0 = 0.5*(math.sqrt(5.0)-1.0) p = 1.0 f0 = 1.0 f1 = p0 for i in range(0,60): print("i=",i, "phi**i by mul=", p, "by **=", p0**i, "by sub=", f0) p = p*p0 f2 = f0-f1 f0 = f1 f1 = f2 print("the end")