####THIS PROGRAM RUNS IN SAGEMATH 8.1 def cantor_map(p,N): T=[(x/3).function(x),(x/3+2/3).function(x)] import itertools K=["".join(seq) for seq in itertools.product("01", repeat=N)] R=[0] W=[] mup=0 for i in range(2^N): aux0=0 aux=1 paux=1 for j in range(N): aux0=T[int(K[i][N-j-1])](aux0) aux=T[int(K[i][N-j-1])](aux) if K[i][j]=='0': paux=paux*p else: paux=paux*(1-p) mup=mup+paux R.append(mup) if i<2^N-1: R.append(mup) W.append(aux0) W.append(aux) W=uniq(W) x_coords = W y_coords = R result=list_plot(zip(x_coords, y_coords),plotjoined=True) return result cantor_map(0.7,1) cantor_map(0.5,2) cantor_map(0.5,3) cantor_map(0.5,4) cantor_map(0.5,5)