#C17.txt: Maple code for Lecture 17 #Version of March 26, 2021 Help17:=proc(): print(`Rseq(r,N) , RseqF(r,N), RseqFF(r,N), RseqFFF(r,N), JC(P,x,m,K),JC1(P,x,m,K), tauF(r,k) , FZ(r,N) `): end: #Rseq(r,N): The first N coefficients of q*eta(q)^r #where eta(q)=(1-q)*(1-q^2)*(1-q^3)*... Rseq:=proc(r,N) local f,i: f:=taylor(q*mul(1-q^i,i=1..N)^r,q=0,N+1): [seq(coeff(f,q,i),i=1..N)]: end: #RseqF(r,N): a Fast version of Rseq(r,N) (see above) RseqF:=proc(r,N) local f,i: f:=1: for i from 1 while (3*i+1)*i/2<=N do f:=f+(-1)^i*q^((3*i-1)*i/2) +(-1)^i*q^((3*i+1)*i/2): od: f:=taylor(q*f^r,q=0,N+1): [seq(coeff(f,q,i),i=1..N)]: end: #JC(P,x,m,K): inputs a polynomial P in the variable x, a pos. integer m #and a pos. integer K, outputs the coeff. of x^n from n=0 to n=K #In other words taylor(P^m,x=0,K+1): #P^m=a(m,0)+a(m,1)*x+a(m,2)*x^2+... #P=p[0]+p[1]*x+...+p[L]*x^L #P=3+2*x+5*x^2 #p[0]=3, p[1]=2, p[2]=5 #a(m,k)=1/(k*p0)*Sum(p[i]*((m+1)*i-k)*a(m,k-i),i=1..L): JC:=proc(P,x,m,K) local L,p0,M,ng,k: L:=degree(P,x): p0:=coeff(P,x,0): M:=[p0^m]: for k from 1 to K do #ng is a(m,k): ng:= add(coeff(P,x,i)*((m+1)*i-k)*M[k-i+1],i=1..min(L,k))/(k*p0): M:=[op(M),ng]: od: end: #added after class #JC1(P,x,m,K): same input and output as JC(P,x,m,K), for checking purposes # JC1:=proc(P,x,m,K) local f,i: f:=expand(P^m): [seq(coeff(f,x,i),i=0..K)]: end: #Added after class #RseqFF(r,N): a yet Fast version of RseqF(r,N) (see above) using the J.C.P. Miller recurrence RseqFF:=proc(r,N) local f,i,q: f:=1: for i from 1 while (3*i+1)*i/2<=N do f:=f+(-1)^i*q^((3*i-1)*i/2) +(-1)^i*q^((3*i+1)*i/2): od: JC(f,q,r,N-1): end: #FZold(r,N): The first place where the coefficient of q^i in q*eta(q)^r is zero looking at the first N coefficeints of q*eta(q)^r. #if they are all non-zero, it returns infinity FZold:=proc(r,N) local L,i: L:=RseqFF(r,N): for i from 1 to nops(L) while L[i]<>0 do od: if i=nops(L)+1 then RETURN(infinity): fi: i: end: tauF:=proc(r,k) local s,j: option remember: if k<0 then RETURN(0): fi: if k=0 then RETURN(1): fi: s:=0: for j from 1 while (3*j-1)*j/2<=k do s:=s+(-1)^j*((r+1)*(3*j-1)*j/2-k)*tauF(r,k-(3*j-1)*j/2): od: for j from 1 while (3*j+1)*j/2<=k do s:=s+(-1)^j*((r+1)*(3*j+1)*j/2-k)*tauF(r,k-(3*j+1)*j/2): od: s/k: end: #RseqFFF(r,N): a yet Fast version of RseqF(r,N) (see above) using the J.C.P. Miller recurrence but directly RseqFFF:=proc(r,N) local k: [seq(tauF(r,k),k=0..N-1)]: end: #FZ(r,N): The first place where the coefficient of q^i in q*eta(q)^r is zero looking at the first N coefficeints of q*eta(q)^r. #if they are all non-zero, it returns infinity FZ:=proc(r,N) local i: for i from 1 to N while tauF(r,i)<>0 do od: if i=N+1 then infinity: else i: fi: end: