from math import sqrt

def norm(t):
    return map(lambda x:x/(t[0]+t[1]),t)

def equ(a,b):
    return norm([a[0]*b[0],a[1]*b[1]])

def inv(a):
    return [a[1],a[0]]

def damp(a):
    b = a[0]*0.95
    return norm([b,1-b])

def dist(x,y):
    d = (x[0] - y[0],x[1] - y[1])
    return sqrt(d[0]*d[0] + d[1]*d[1])

if __name__ == '__main__':
    c = 0
    x,y = [0.1,0.9],[0.9,0.1]
    for i in range(1000):
        xp = x[:]
        x = damp(inv(equ(x,y)))
        print "x=%s" % x
        c += 1
        if dist(x,xp) < 1e-3:
            break
    print c
