Mathematica code for the illustrations of the paper
Oliver Knill and Folkert Tangerman
Selfsimilarity and growth in Birkhoff sums for the golden rotation

Figure 1

M=14;a=(Sqrt[5]-1)/2;q[m_]:=Denominator[Last[Convergents[a,m]]];g[x_]:=N[Log[2-2 Cos[2*Pi*x]]];
T[{k_,x_}]:={k+1,x+g[k*a]};b=NestList[T,{1,0},q[M]];R[s_]:=Table[s[[k,2]],{k,Length[s]}];
P=Table[l=q[k];{{RGBColor[1,0,0],Point[{l,b[[l,2]]}]},{RGBColor[0,0,1],Point[{l+1,b[[l+1,2]]}]}},{k,M}];
Show[{ListPlot[R[b],Joined->True],Graphics[{PointSize[0.01],P}]}]

Figure 2

M=20;a=(Sqrt[5]-1)/2;r=Last[Convergents[a,M]];q=Denominator[r];g[x_]:=N[Log[2-2 Cos[2*Pi*x]]];
T[{k_,x_}]:={k+1,x+g[k*a]};b=NestList[T,{1,0},q];bb=Table[b[[k,2]]/Log[k]/2,{k,2,Length[b]}];
L=200;ss=Table[0,{L}];Do[tt=Floor[bb[[k]]*L+1];If[0<tt≤L,ss[[tt]]++],{k,Length[bb]}];
ListPlot[ss,Joined->True]

Figure 3 (showing f)

M=18;a=(Sqrt[5]-1)/2;
r1=Last[Convergents[a,M]];q1=Denominator[r1];
r2=Last[Convergents[a,M+1]];q2=Denominator[r2];
g[x_]:=N[Log[2-2 Cos[2*Pi*x]]];
T[{k_,x_}]:={k+1,x+g[k*r2]};
S[{k_,x_}]:={k+1,x+g[k*r1]};
b1=NestList[T,{1,0},q1];b2=NestList[S,{1,0},q2];
R[s_]:=Table[s[[k,2]],{k,Length[s]}];
f1[x_]:=b1[[Floor[x*q1+1],2]];beta1[x_]:=f1[a*x]+a^2 f1[x];
f2[x_]:=b2[[Floor[x*q1+1],2]];beta2[x_]:=f2[a*x]+a^2 f2[x];
S1=Plot[f1[x]-f2[x],{x,1/q1,(q1-1)/q1},PlotRange->All];S2=Plot[beta1[x]-beta2[x],{x,1/q1,(q1-1)/q1},PlotRange->All];
GraphicsArray[{S1,S2}]

Figure 3 (showing h)

M=18;a=(Sqrt[5]-1)/2;r=Last[Convergents[a,M]];q=Denominator[r];
g[x_]:=N[Log[2-2 Cos[2*Pi*x]]];T[{k_,x_}]:={k+1,x+g[k*a]};S[{k_,x_}]:={k+1,x+g[k*r]};
b1=NestList[T,{1,0},q];b2=NestList[S,{1,0},q];R[s_]:=Table[s[[k,2]],{k,Length[s]}];b=b1-b2;
f[x_]:=b[[Floor[x*q+1],2]];beta[x_]:=f[a*x]+a^2 f[x];
S1=Plot[f[x],{x,0,(q-1)/q},PlotRange->All];S2=Plot[beta[x],{x,1/q,(q-1)/q},PlotRange->All];
GraphicsArray[{S1,S2}]

Figure 4

M=20;a=(Sqrt[5]-1)/2;r=Last[Convergents[a,M]];q=Denominator[r];e=0.5/q;
g[x_]:=N[Log[2-2 Cos[2*Pi*x]]];T[{k_,x_}]:={k+1,x+g[k*a]};S[{k_,x_}]:={k+1,x+g[k*r]};
b1=NestList[T,{1,0},q];b2=NestList[S,{1,0},q];R[s_]:=Table[s[[k,2]],{k,Length[s]}];b=b1-b2;
f[x_]:=b[[Floor[x*q+1],2]];beta[x_]:=f[a*x]+a^2 f[x];
gamma1[x_]:=beta[a*x]+a^2 beta[x];U=gamma1[1-e]/beta[1-e];V=beta[a+e];
gamma2[x_]:=beta[a+x(1-a)]-V;W=gamma2[1-e]/beta[1-e];
S1=Plot[gamma1[x]-U beta[x],{x,0,1}];S2=Plot[gamma2[x]/W-beta[x],{x,0,1}];
Show[GraphicsArray[{S1,S2}]]

Figure 5

F[m_]:=Module[{},a=Sqrt[41]-6;r=Last[Convergents[a,m]];q=Denominator[r];
g[x_]:=N[Log[2-2 Cos[2*Pi*x]]];T[{k_,x_}]:={k+1,x+g[k*a]};S[{k_,x_}]:={k+1,x+g[k*r]};
b1=NestList[T,{1,0},q];b2=NestList[S,{1,0},q];R[s_]:=Table[s[[k,2]],{k,Length[s]}];
ListPlot[R[b1-b2],Joined->True,Ticks->None]];GraphicsArray[{F[6],F[7],F[8]}]

Figure 6

a=(Sqrt[5]-1)/2;M=23;r=Last[Convergents[a,M]];q=Denominator[r];g[x_]:=N[Mod[x,2Pi]-Pi];
T[{k_,x_}]:={k+1,x+g[2*Pi*k*a]};S[{k_,x_}]:={k+1,x+g[2*Pi*k*r]};
b1=NestList[T,{1,0},q-1];b2=NestList[S,{1,0},q-1];R[s_]:=Table[s[[k,2]],{k,Length[s]}];
S1=ListPlot[R[b1]];S2=ListPlot[R[b1-b2]];GraphicsArray[{S1,S2}]

Figure 7

a=(Sqrt[5]-1)/2;Clear[r,q];r[m_]:=Last[Convergents[a,m]];q[m_]:=Denominator[r[m]];c[z_]:={Re[z],Im[z]};
S[n_,c_]:=Product[N[(Exp[I*2*Pi*k*c]-1)],{k,n}];F[n_,m_]:=S[n,r[m+1]]/S[n,r[m]];
B[k_,m_]:=F[Round[a*k],m]*F[k,m]^(a^2);s=Circle[{0,0},1,{-Pi/2,Pi/2}];
S1={s,Line[Table[c[F[k,14]],{k,q[14]-1}]],Line[Table[c[F[k,15]],{k,q[15]-1}]]};
S2={s,Line[Table[c[B[k,14]],{k,q[14]-1}]],Line[Table[c[B[k,15]],{k,q[15]-1}]]};
Show[GraphicsArray[{Graphics[S1],Graphics[S2]}]]

Figure 8

Manipulate[M=7;a=(Sqrt[5]-1)/2;q[m_]:=Denominator[Last[Convergents[a,m]]];Clear[e];
e[k_,n_]:={Cos[2*Pi*k*q[n-1]/q[n]],Sin[2*Pi*k*q[n-1]/q[n]]};o={0,0};p={1,0};P=Point;L=Line;
Show[Graphics[{Circle[o],Table[{P[e[k,M]],P[e[k,M+1]],L[{e[k,M],p}],L[{e[k,M+1],p}]},{k,Floor[x0 q[M]]}]}]],{x0,0,1}]

May 28, 2010, OK