# check: sum_{w in W(A2)} w( prod_{g>0} (1 - t e^g)/(1 - e^g) ) = (1+t)(1+t+t^2), constant
import cmath, random
def s1(p): x,y=p; return (1/x, x*y)
def s6(p): x,y=p; return (x*y, 1/y)
def orbit(p):
    seen=[p]; fr=[p]
    while fr:
        nf=[]
        for q in fr:
            for f in (s1,s6):
                r=f(q)
                if all(abs(r[0]-u[0])+abs(r[1]-u[1])>1e-9 for u in seen): seen.append(r); nf.append(r)
        fr=nf
    return seen
random.seed(1)
for trial in range(3):
    x=cmath.exp(complex(random.random(),random.random())); y=cmath.exp(complex(random.random(),random.random()))
    t=random.random()
    tot=0
    for (u,v) in orbit((x,y)):
        val=1
        for g in (u,v,u*v): val*= (1-t*g)/(1-g)
        tot+=val
    print(len(orbit((x,y))), tot, (1+t)*(1+t+t*t))
# beta ratio check: beta(chi)/beta(s1 chi) = -x (1 - t/x)/(1 - t x)
x=1.3+0.2j; y=0.7-0.4j; t=0.37
beta=lambda x,y: ((1-x)*(1-y)*(1-x*y))/((1-t*x)*(1-t*y)*(1-t*x*y))
X,Y=s1((x,y)); print(beta(x,y)/beta(X,Y), -x*(1-t/x)/(1-t*x))
