(* Applying the special product rule for α*)
Multiply[p_,c_]:=
Module[{i,j,m,b},
	FixedPoint[
		Expand[#]
		/.{
			Power[c[i_,m_],b_]:>(c[i,m])^Mod[b,2]*(2+c[2i,m])^Floor[b/2]/;b>=2,
			c[i_,m_]*c[j_,m_]:>c[i+j,m]+c[i-j,m]}&,
		p]
	]

(* Reducing by symmetries *)
SymReduce[p_,c_]:=
Module[{i,m},
	p/.c[i_,m_]:>c[-i,m]/;i<0
	//.c[i_,m_]:>c[i-2m,m]/;i>2m
	/.c[i_,m_]:>c[2m-i,m]/;i>m
	/.c[i_,m_]:>-c[m-i,m]/;2i>m
	/.{c[i_,m_]:>0/;2i==m,c[i_,m_]:>1/;3i==m,c[i_,m_]:>-1/;3i==2m,c[m_,m_]->-2,c[0,_]->2}
]

RemoveCos[p_,Y_,c_,acc_]:=
Module[{i,j,x},
	p/.c[i_,j_]:>N[2*Cos[i Pi/j],acc]/.x_Real:>Round[x]
]

TakeProduct[polys_,e_,Y_,c_,z_,acc_]:=
Module[{a,b,prod},
	prod=Fold[SymReduce[Multiply[#1*#2,c],c]&,1,polys];
	Cancel[b^e*(RemoveCos[prod,Y,c,acc])/.Y->a^2/b]/.{a->(1+z^2),b->z(1-z^2)}
]

U[K_]=FullSimplify[Coth[2K](1+2/Pi EllipticK[z^2](2*Tanh[2K]^2-1))/.z->2*Sinh[2K]/Cosh[2K]^2,Element[K,Reals]];

(************ Input *************)

n=8

(*************** I **************)

p=n/2;
acc=Floor[N[p^2*Log[10,2]]];
U[Y_,t_]=SymReduce[Multiply[ChebyshevU[p-1,(Y-a[t,n])/2],a],a];
T[Y_,t_]=SymReduce[Multiply[2*ChebyshevT[p,(Y-a[t,n])/2],a],a];

A1polys=Table[SymReduce[U[Y,2i],a],{i,0,p}]/.a[i_,j_]:>a^i;
A2polys=Table[SymReduce[T[Y,2i],a],{i,0,p}]/.a[i_,j_]:>a^i;
A4polys=Table[SymReduce[T[Y,2i+1],a],{i,0,p-1}]/.a[i_,j_]:>a^i;

(************** 6a) *************)

A1prod=TakeProduct[Table[SymReduce[U[Y,2i],a],{i,0,p}],p^2-1,Y,a,z,acc];
A1=Expand[(1+z^2)^2(-1-2z+z^2)(-1+2z+z^2)*A1prod^2];
Z=A1;

(************** 6b) *************)

A2prod=TakeProduct[Table[SymReduce[T[Y,2i],a],{i,1,p-1}],p^2-p,Y,a,z,acc];
A2pre=TakeProduct[{SymReduce[T[Y,n],a],SymReduce[T[Y,0],a]},n,Y,a,z,acc];
A2=Expand[A2pre*A2prod^2];
Z=Z+2*A2;

(*************** 6d) ************)

A4prod=TakeProduct[Table[SymReduce[T[Y,2i+1],a],{i,0,p-1}],p^2,Y,a,z,acc];
A4=Expand[A4prod^2];
Z=Expand[(Z+A4)/2];

(************** Check *************)

s1=Simplify/@Integrate[Series[U[K],{K,0,n-1}],K];
s2=Simplify/@Series[Exp[n^2*s1],{K,0,n-1}];
s3=Simplify/@Series[Z/(2z)^(n^2)/.z->Exp[K]^2,{K,0,n-1}];

s2-s3==O[K]^n