q-expansion of modular forms: 

We can calculate certain formal power series through differential equations. Here, we give some examples. This includes the q-expansion of classical modular forms, mainly full modular forms (through the Ramanujan differential equation), modular and quasi-modular forms for triangular groups (through the Darboux-Halphen differential equation), modular-type functions attached to mirror quintic Calabi-Yau equation and also an arbitrary Calabi-Yau equation after Almkvist-Enckevort-Straten-Zudilin. We are going to use the procedures qexpansion and HalphenRamanujan from  foliation.lib     


Ramanujan differential equation between Eisenstein series:


Below we calculate the Eisenstein series E_2, E_4 and E_6 through the Ramanujan differential equations:
     LIB "foliation.lib";
help qexpansion;
example qexpansion;
We have used the following commands:
     LIB "linalg.lib"; LIB "foliation.lib";
ring r=0, (t_1,t_2,t_3,q),dp;
list vecfield=1/12*(t_1^2-t_2), 1/3*(t_1*t_2-t_3), 1/2*(t_1*t_3-t_2^2);
//This is the classical Ramanujan differential equation between Eisenstein series.
list pose=1-24*q,1+240*q,1-504*q;
list denomv=1,1,1;
intvec upto;
intvec whichpow;
int iter=500;
int n;
for (n=2; n<=iter;n=n+1)
{
upto=n,n,n; whichpow=upto;
pose=qexpansion(vecfield,denomv,pose,upto,upto,1); n;
}
list ber=-24,240,-504;
for (n=1; n<=3;n=n+1){pose[n]=pose[n]/ber[n];}
pose;
write(":w EisensteinSeriesE2.txt", pose[1]);
write(":w EisensteinSeriesE4.txt", pose[2]);
write(":w EisensteinSeriesE6.txt", pose[3]);


Halphen differential equation:

The Halphen differential equation (see my article  On Ramanujan relations between Eisenstein series )  depends on three parameters and for special values of such parameters we get three quasi-modular form t_1,t_2,t_3 for any triangle group <m_1, m_2,m_3>, where m_1,m_2,m_3 are positive integers greater than 1. If one of the angular parameters is zero, that is m_3 is infinity, then such quasi-modular forms have q-expansions whose coefficients are polynomial in m_1,m_2.  There is an ambiguity of these three series which is essentially due to the transformation q->c*q for a constant c. We have used this freedom for the choice of c in order to make all coefficients of q a polynomial in m_1 and m_i. Here is the result
                                                           HalphenSeries1m_1m_2, HalphenSeries2m_1m_2, HalphenSeries3_m_1m_2 
From these three q-expansions we can compute the Hauptmodule J=(t_2-t_1)/(t_3-t_1). We normalize this so that it starts with 1/q+*q+*q^2... and we get
                                                                 Hauptmodulem_1m_2                      
                                                   
So in order to get this you have to type:
         
     LIB "linalg.lib"; LIB "foliation.lib"; LIB "atkins.lib"; LIB "latex.lib"; 
example t1t2t3; //This shows how to compute q-expansions from the Halphen differential equation.

ring r=(0,nu,m_1,m_2), (x(1..3),q),dp; int upto=7;
list hal=t1t2t3(1/m_2,1/m_1,upto);
ideal II=q^(upto+1); II=std(II);
poly haupt=(hal[2]-hal[1])*OneOver( (hal[3]-hal[1])/q ,II,upto); //Note that we have multiplied the Hauptmodule with q.
poly jhaupt=-(2*m_1^2*m_2^2)*haupt+(m_1^2*m_2^2+m_2^2-m_1^2)*q;


write(":w HalphenSeries1m_1m_2.txt", hal[1]);
write(":w HalphenSeries2m_1m_2.txt", hal[2]);
write(":w HalphenSeries3m_1m_2.txt", hal[3]);
  write(":w Hauptmodulem_1m_2.txt", jhaupt);

We have used m_1 and m_2 as parameters and so the calculation in Singular are slow. We may reprogram all these with m_1,m_2 as variables and compute J for higher powers of q.
        
Arithmetic triangular groups with a cusp: Here is the three quasi-modular forms for arithmetic non-compact triangle groups classified by K. Takeuchi 1976. i stands for infinity. We have used the freedom due to q->c*q in order to obtain integral coefficients.
  1.  (2,3,i)  HalphenSeries1_2_3 , HalphenSeries2_2_3HalphenSeries3_2_3
  2.  (3,3,i)  HalphenSeries1_3_3 , HalphenSeries2_,  HalphenSeries3_3_3     
  3.  (2,4,i)  HalphenSeries1-2_4 , HalphenSeries2-2_4 HalphenSeries3_2-4 
  4. (2,6,i)  HalphenSeries1 , HalphenSeries2 ,  HalphenSeries3
  5. (2,i,i)  HalphenSeries1 , HalphenSeries2 ,  HalphenSeries3  
  6.  (3,i,i)  HalphenSeries1 , HalphenSeries2 ,  HalphenSeries3 
  7. (4,4,i)  HalphenSeries1 , HalphenSeries2 ,  HalphenSeries3 
  8.  (6,6,i)  HalphenSeries1 , HalphenSeries2 ,  HalphenSeries3 
  9. (i,i,i)  HalphenSeries1 , HalphenSeries2,  HalphenSeries3   
The Singular code of all these and some others you can find here. For instance, for (2,3,i) case we have used the commands:

     
     LIB "linalg.lib"; LIB "foliation.lib"; LIB "atkins.lib"; LIB "latex.lib"; 
ring r=(0,t), (x(1..3),q),dp; int upto=7; number m_1=2; number m_2=3;
list hal=t1t2t3(1/m_2,1/m_1,upto);
ideal II=q^(upto+1); II=std(II);
poly haupt=(hal[2]-hal[1])*OneOver( (hal[3]-hal[1])/q ,II,upto); //Note that we have multiplied the Hauptmodule with q.
poly jhaupt=-(2*m_1^2*m_2^2)*haupt+(m_1^2*m_2^2+m_2^2-m_1^2)*q;
jhaupt=subst(jhaupt, q, q*2^3*3); //This is the classical j function.
    


Some non-arithmetic triangular groups: For non-aritmetic triangular groups with a cusp we can investigate the primes
which appear in the denominator of its coefficients. For this purpose I have written the procedure t1t2t3primepowers. For instance, let
us see which primes appear in the denominators of the modular forms for the triangular group (5,i,i).
     LIB "linalg.lib"; LIB "foliation.lib"; LIB "atkins.lib"; LIB "latex.lib"; 
example t1t2t3primepowers;
help t1t2t3primepowers;

ring r=(0,t), (x(1..3),q),dp; int upto=50; int pupto=70;
number v_2=0; number v_1=1/5;
t1t2t3primepowers(v_2,v_1,upto, pupto);
We get the result 0,1,1,1,0,1,1,0,1,0,0,1,0,1,1,0,0,0,0. This sequence is in one to one correspondance with the sequence of prime numbers
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67. This means for instance that in truncated modular form theory for the triangular group (5,i,i),
the prime 3 appear in the denominators and making q->3q, kills 3 from the denominators.


Here, is a collection of commands for investigating these primes for a big class of triangular groups.  We have computed solutions of Halphen differential equations t_1,t_2,t_3 with
angular parameters 2<=m_i<=m_1<=24   and m_i<=24, m_1=infty. The first collection of commands uses t1t2t3 directly and the second one uses t1t2t3primepowers.

      
LIB "linalg.lib"; LIB "foliation.lib"; LIB "atkins.lib";
ring r=(0,nu), (x(1..3),q),lp;
int pupto=200;
int iteration=182;
int i; poly pos; intvec pow; int count; number komak; intvec powempty;
int mm_1; int mm_i; number vv_1; number vv_i;
list lll;
intvec pl=primes(1,pupto);


for (mm_i=2; mm_i<=24;mm_i=mm_i+1)
{
vv_i=1/number(mm_i);
for (mm_1=mm_i; mm_1<=25;mm_1=mm_1+1)
{
vv_1=1/number(mm_1); if (mm_1==25){vv_1=0;}
lll=t1t2t3(vv_1,vv_i,iteration);
vv_1, vv_i;
write("SolutionsHalphen.txt", vv_1,vv_i);
write("SolutionsHalphen.txt", "t_1");
write("SolutionsHalphen.txt", lll[1]);
write("SolutionsHalphen.txt", "t_2");
write("SolutionsHalphen.txt", lll[2]);
write("SolutionsHalphen.txt", "t_3");
write("SolutionsHalphen.txt", lll[3]);
write("SolutionsHalphen.txt", "************************************************************************");

pos=lll[1]*var(1)+lll[2]*var(2)+lll[3]*var(3);
pow=powempty;
for (i=1; i<=size(pl);i=i+1)
{
count=0;
komak=denominator(content(pos));
while (round(komak/pl[i])*pl[i]==komak)
{
pos=subst(pos,q, pl[i]*q);
komak=denominator(content(pos));
count=count+1;
}
pow=pow,count;
}
pow=pow[2..size(pow)];
write("PrimePowers.txt", vv_1,vv_i);
write("PrimePowers.txt", pow);

}
}



     LIB "linalg.lib"; LIB "foliation.lib"; LIB "atkins.lib";
ring r=(0,nu,m_1,m_i), (x(1..3),q),dp;
int pupto=300;
int iteration=182;
int i; poly pos; intvec pow; int count; number komak;
int mm_1; int mm_i; number vv_1; number vv_i;
list lll;
for (mm_1=1; mm_1<=30;mm_1=mm_1+1)
{
vv_1=1/number(mm_1); if (mm_1==30){vv_1=0;}
for (mm_i=1; mm_i<=mm_1;mm_i=mm_i+1)
{
vv_i=1/number(mm_i);
lll=t1t2t3primepowers(vv_1,vv_i,iteration, pupto);
vv_1, vv_i; lll;
write("powers", vv_1,vv_i);
write("powers", lll);


}
}






A modular differential equation attached to mirror quintic Calabi-Yau threefolds:

For the details of this differential equation see my article Modular-type functions attached to mirror quintic Calabi-Yau varieties.  We have
seven variables written in the q-expansion form
                                             t_0, t_1, t_2, t_3t_4, t_5, t_6
From this we can compute the genus zero and genus one instanton numbers (see Bershadski-Cecotti-Ooguri-Vafa 1993)
                                              genus zero instanton           genus one instanton


LIB "linalg.lib";
LIB "foliation.lib";
int numofvar=7; //number of variables in the modular differential equation
ring r=0,(t(0..numofvar-1),q,nu),dp;
int iter=20; //we calculate till q^iter
list pose0= 1/5,-25,-35,-6,0,-1, -15;
int c_2=5; //The derivation is c_2*q d/dq
int whichone=3; //which modular differential equation
list vf=HalphenRamanujan(whichone,list(t(0..6))); list vecfield=vf[1]; list den=vf[2];
list pose=qexpansion(vecfield,den,pose0,intvec(1,1,1,1,1,1,1), intvec(1,1,1,1,1,1,1),c_2);
for (int n=1; n<=size(pose);n=n+1){pose[n]=subst(pose[n],t(6),4675);}
//-----------------for all----------------------------
int di=size(vecfield); int i;
list lvar; for (i=1; i<=di;i=i+1){lvar=insert(lvar, var(i), size(lvar));}
matrix Vm=derivatives(vecfield, lvar);
matrix diago[di][di]; for (i=1; i<=di;i=i+1){diago[i,i]=den[i];}
for (i=1; i<=di;i=i+1){Vm=subst(Vm,var(i),pose0[i]); diago=subst(diago, var(i),pose0[i]);} print(Vm); print(diago);
matrix speed[di][di]=adjoint(Vm-c_2*nu*diago);
poly detspeed=det(Vm-c_2*nu*diago);
matrix speed1[di][di];
intvec upto; intvec whichpow=upto;


int zaman=rtimer;
for (n=2; n<=iter;n=n+1)
{
n;
upto=n,n,n,n,n,n,n;
speed1=subst(speed,nu,n)/number(subst(detspeed, nu,n));
pose=qexpansion(vecfield,den,pose,upto,upto,5,0,speed1);
//for (i=1; i<=7;i=i+1){denominator(number(subst(pose[i][1],q,1)));}
}
//These integrakity of the coefficients still holds after
//list cof=1/24,-1/750,-1/50,-1/5,-1,1/125,1/25;
//for (i=1; i<=size(pose);i=i+1){pose[i]=pose[i]*cof[i];}
rtimer-zaman;



//Let us calculate the first 30, genus zero and genus one instanton numbers.
int k; int N=20;
poly s(0..6); for (k=0;k<=6; k=k+1){s(k)=pose[k+1];}
ideal II=std(ideal(q^(N+1)));
poly Yu=-5^11*(s(4)-s(0)^5)^2*OneOver(s(5)^3, II ,N);
Yu=reduce(Yu, II);
list ins0=LambertSeries(Yu,q,N);
for (k=2;k<=size(ins0); k=k+1){ ins0[k]=ins0[k]/(k-1)^3; }
poly Yu1=(-1/5)*(3750*s(0)^5*s(6)-353125*s(0)^4*s(5)-112*s(3)*s(5)-3750*s(4)*s(6))*OneOver(12*s(5)^2, II,N);
list ins1=LambertSeries(Yu1,q,N);
for (k=2;k<=N+1;k=k+1){ ins1[k]=ins1[k]+(1/12)*ins0[k]*(k-1);}
for (k=4;k<=N+1;k=k+1){ ins1[k]=-ins1[k]/(k-1);}
poly XX; for (k=0;k<=N;k=k+1){ XX=XX+ins1[k+1]*q^k;}
LambertSeries(XX,q,N);


 

write(":w MirrorQuinticCY-t_0.txt", pose[1]);
write(":w MirrorQuinticCY-t_1.txt", pose[2]);
write(":w MirrorQuinticCY-t_2.txt", pose[3]);
write(":w MirrorQuinticCY-t_3.txt", pose[4]);
write(":w MirrorQuinticCY-t_4.txt", pose[5]);
write(":w MirrorQuinticCY-t_5.txt", pose[6]);
write(":w MirrorQuinticCY-t_6.txt", pose[7]);


write(":w MirrorQuinticCY-instanton0.txt", ins0);
write(":w MirrorQuinticCY-instanton1.txt", ins1);






LIB "linalg.lib";
LIB "foliation.lib";
ring r=(real, 20),(t(0..6),q,nu),dp;
list pose; string st; poly PP;
st="PP="+read("MirrorQuinticCY-t_0.txt")+";"; execute(st); pose=insert(pose,PP, size(pose));

int i=1; int n;
for (n=1; n<=350;n=n+1){pose[i][n+1]*q/pose[i][n];}

 


//-------Calculating the j Calabi-Yau function----------


poly nompoly=(pose[1])^5;
poly denpoly=pose[5]/q;
poly denpoly0=subst(denpoly, q,0);
denpoly=-(denpoly-denpoly0)/denpoly0;
poly jfun;

ideal II=q^(iter+1); II=std(II);
for (i=0; i<=iter;i=i+1){jfun=jfun+denpoly^i; jfun=reduce(jfun, II); i;}
jfun=jfun*(-3125*(24^5))*(1/denpoly0)*nompoly; jfun=reduce(jfun,II);









A modular differential equation attached to Calabi-Yau equations:

 

//------------------q-expansion around z=0 for arbitrary CY equation----------------
LIB "linalg.lib";
LIB "foliation.lib";
ring r=0,(u(0..6),q),dp;
list al=120*u(4), 1250*u(4), 4375*u(4), 6250*u(4), 3125*u(4);
//for (int i=1; i<=5;i=i+1){al[i]=al[i]*1/3125;}
//list al=16*u(4), 128*u(4), 384*u(4), 512*u(4), 256*u(4);
poly A=(-1/2)*al[4]*(1-al[5]);
poly B=(1/4)*al[4]^2+al[3]*(1-al[5])-(1/2)*u(4)*(diff(al[4],u(4))*(1-al[5])-diff(1-al[5], u(4))*al[4]);
list vecfield=u(0)^2*u(1), u(0)^2*u(2), u(0)^2*u(3), u(0)^2*(al[1]*u(0)+al[2]*u(1)+al[3]*u(2)+al[4]*u(3)), u(0)^2*u(4), u(0)^2*u(6), 2*u(0)*(u(1)*u(6)-u(2)*u(5))*(1-al[5])^2-u(0)^2*A*u(6)+u(0)^2*B*u(5) ;
list den= u(5), u(5), u(5), u(5)*(1-al[5]), u(5), u(5), u(5)*(1-al[5])^2;
int n=1;
list pose=1,0,0,0,0,1,0;
intvec upto=n,n,n,n,n,n,n;
intvec whichpow=upto;
pose=qexpansion(vecfield,den,pose,upto,whichpow,1);
for (n=1; n<=size(pose);n=n+1){pose[n]=subst(pose[n],u(6),1010);}

int iter=5; int i;
for (n=2; n<=iter;n=n+1)
{
n;
upto=n,n,n,n,n,n,n;
pose=qexpansion(vecfield,den,pose,upto,upto,1);
for (i=1; i<=7;i=i+1){denominator(number(subst(pose[i][1],q,1)));}
}
list cof=1/24,-1/750,-1/50,-1/5,-1,1/125,1/25;
for (i=1; i<=size(pose);i=i+1){pose[i]=pose[i]*cof[i];}


 

A modular differential equation attached to mirror quintic Calabi-Yau threefolds (in 10 dimension):

LIB "linalg.lib"; LIB "foliation.lib";
ring r=(0,nu),(t(0..9),q),dp;
list vf=HalphenRamanujan(4,list(t(0..9)));
list vecfield=vf[1];
list den=vf[2];
int di=size(vecfield);
int n=1; int i;
list pose= 1/5,-25,-35,-6,0,-1, -15,-25, -1/5,-1;
matrix Vm=derivatives(vecfield, list(t(0..9)));
for (i=1; i<=di;i=i+1){Vm=subst(Vm,var(i),pose[i]);}
print(Vm);
matrix diago[di][di];
for (i=1; i<=di;i=i+1){diago[i,i]=1;} diago[9,9]=pose[6]; diago[10,10]=pose[6];
print(diago);
matrix speed[di][di]=inverse(Vm-5*nu*diago);
matrix speed1[di][di];


intvec upto=n,n,n,n,n,n,n,n,n,n;
intvec whichpow=upto;
pose=qexpansion(vecfield,den,pose,upto,whichpow,5);
for (n=1; n<=size(pose);n=n+1){pose[n]=subst(pose[n],t(9),170); pose[n]=subst(pose[n],t(4),1);}

int iter=10;

int tim=rtimer;
for (n=2; n<=iter;n=n+1)
{
n;
upto=n,n,n,n,n,n,n,n,n,n;
speed1=substpar(speed,nu,n);
pose=qexpansion(vecfield,den,pose,upto,upto,5,1, speed1);
//for (i=1; i<=7;i=i+1){denominator(number(subst(pose[i][1],q,1)));}
}
list cof=1/24,-1/750,-1/50,-1/5,-1,1/125,1/25,1/125,1/10,1/10;
for (i=1; i<=size(pose);i=i+1){pose[i]=pose[i]*cof[i];}
rtimer-tim;