Multi-headed Lattice Green Function (N = 5, M = 2)
	Find Minimal REC

NN=5;
MM=2;

Recall some basic definitions in the paper:

(Subscript[P, M,N])(z):=(1/(((2 π))^N))(∫_(-π)^π)...(∫_(-π)^π)(1/(1 - (z/((({{N}, {M}})))) (Subscript[σ, M])(cos (Subscript[θ, 1]), ..., cos (Subscript[θ, N]))))d(Subscript[θ, 1])...d(Subscript[θ, N])

(Subscript[R, M,N])(z):=(Subscript[P, M,N])((2^M)(({{N}, {M}}))z)   and  (Subscript[R, M,N])(z)=(∑_(n≥0))(Subscript[r, M,N])(n)(z^n)

Also, for M odd or M=N, we always have r(2n+1)=0. Hence, define
(Subscript[(OverTilde[r]), M,N])(n):=(Subscript[r, M,N])(2n)  and  (Subscript[(OverTilde[R]), M,N])(z):=(∑_(n≥0))(Subscript[(OverTilde[r]), M,N])(n)(z^n)=(∑_(n≥0))(Subscript[r, M,N])(2n)(z^n) 

Our goal is to find:

Case 1. M even and M≠N:
- minimal recurrences (REC) for r(n).

Case 2. M odd or M=N:
- minimal recurrences (REC) for (OverTilde[r])(n).

Command: UnrollRecurrence
Generate a sequence from recurrence & initial values (Koutschan’s implementation).

(* given a recurrence rec in f[n], compute the values {f[0],f[1],...,f[bound]} 
where inits are the initial values {f[0],...,f[d-1]} with d being the order of the recurrence *)
Clear[UnrollRecurrence];
UnrollRecurrence[rec1_,f_[n_],inits_,bound_]:=
Module[{i,x,vals=inits,rec=rec1},
If[Head[rec]=!=Equal,rec=(rec==0)];
rec=rec/.n->n-Max[Cases[rec,f[n+a_.]:>a,Infinity]];
Do[
AppendTo[vals,Solve[rec/.n->i/.f[i]->x/.f[a_]:>vals[[a+1]],x][[1,1,2]]];
,{i,Length[inits],bound}];
Return[vals];
];

Load RISC packages.

<<RISC`HolonomicFunctions`
<<RISC`Asymptotics`
<<RISC`Guess`

HolonomicFunctions Package version 1.7.3 (21-Mar-2017)
written by Christoph Koutschan
Copyright Research Institute for Symbolic Computation (RISC),
Johannes Kepler University, Linz, Austria

Asymptotics Package version 0.3
written by Manuel Kauers
Copyright Research Institute for Symbolic Computation (RISC),
Johannes Kepler University, Linz, Austria

Package GeneratingFunctions version 0.9 written by Christian Mallinger
Copyright Research Institute for Symbolic Computation (RISC),
Johannes Kepler University, Linz, Austria

Guess Package version 0.52
written by Manuel Kauers
Copyright Research Institute for Symbolic Computation (RISC),
Johannes Kepler University, Linz, Austria

We start by importing known ODE for R(z).
Note that the ODE in Koutschan (2013, pp. 11-12, Thm 3) is for P(z)=R(z/(({{N}, {M}}))(2^M)).

ODEDiv2=ToOrePolynomial[30*(27000000000+84037500000*z-346865625000*z^2-55567000000*z^3+187923165625*z^4+36477006875*z^5+21336230625*z^6+19123388575*z^7+6925739310*z^8+1443544710*z^9+163913184*z^10+7525440*z^11)*P[z]+10*(-189000000000+4816462500000*z-7268326875000*z^2-21210430812500*z^3+2664478321875*z^4+3711617481250*z^5-135661728250*z^6+689643286650*z^7+607021304825*z^8+209673119160*z^9+40678130502*z^10+4143853440*z^11+167064768*z^12)*Derivative[1][P][z]+5*(-3240000000000+5055750000000*z+44457862500000*z^2-133825053750000*z^3-110925736437500*z^4+13367806743750*z^5-6199228765625*z^6-8282515456375*z^7+1646226060075*z^8+2287368823475*z^9+810956145330*z^10+149186684934*z^11+13819981248*z^12+496679040*z^13)*Derivative[2][P][z]+5*z*(-13162500000000+45343125000000*z+40530375000000*z^2-190176960000000*z^3-77498059625000*z^4-3649915059375*z^5-26918293320000*z^6-13545524756500*z^7-465440555100*z^8+1350059072325*z^9+524857986060*z^10+92744995638*z^11+7892060544*z^12+255864960*z^13)*Derivative[3][P][z]+10*z^2*(-5568750000000+23905125000000*z+3393646875000*z^2-39702348750000*z^3-7716298734375*z^4-3779011321875*z^5-7801785421250*z^6-3351125770500*z^7-382134335775*z^8+148313757125*z^9+68439921540*z^10+11725276842*z^11+923795772*z^12+27279720*z^13)*Derivative[4][P][z]+8*z^3*(5+z)*(-354375000000+1774828125000*z-503550000000*z^2-1289447109375*z^3+254876515625*z^4-266627903125*z^5-304623830625*z^6-87265479875*z^7-4878146975*z^8+3939663705*z^9+1048560285*z^10+97471734*z^11+3057210*z^12)*Derivative[5][P][z]+16*(-5+z)*(-1+z)*z^4*(5+z)^2*(10+z)*(15+z)*(5+3*z)*(-675000+3465000*z-1053375*z^2+933650*z^3+449735*z^4+144776*z^5+15678*z^6)*Derivative[6][P][z]/.{Derivative[k_][P][z]->((Der[z])^k)}/.{P[z]->1}];

Process the data.

Write the ODE in terms of the operators D and θ.

ODENormalizedinD=NormalizeCoefficients[DFiniteSubstitute[{ODEDiv2},{z->w*(2^MM)*Binomial[NN,MM]},Algebra->OreAlgebra[Der[w]]][[1]]];

ODENormalizedinTheta=NormalizeCoefficients[ChangeOreAlgebra[w**ODENormalizedinD,OreAlgebra[Euler[w]]]];

Then transform the above to a REC for r(n) and write it explicitly.

RECNormalizedinS=NormalizeCoefficients[DFiniteDE2RE[{ODENormalizedinD},{w},{α}][[1]]];

RECNormalizedinSOrder=OrePolynomialDegree[RECNormalizedinS,S[α]]

ClearAll[Seq];
SeqNormalized=ApplyOreOperator[RECNormalizedinS,Seq[α]];

Compute the initial values of r(n).

MAX=RECNormalizedinSOrder;
ClearAll[a];

SeriesIni=ApplyOreOperator[ODENormalizedinTheta,Sum[a[n](w^n),{n,0,MAX}]];

SeriesIniSol=Solve[Join[Table[Coefficient[SeriesIni,w,i]==0,{i,1,MAX}],{a[0]==1},{a[1]==0}],Table[a[i],{i,0,MAX}]]

SeqListIni=Table[SeriesIniSol[[1,k,2]],{k,1,Length@SeriesIniSol[[1]]}]

seq[n_]:=SeqListIni[[n+1]];

Generate a list of r(n).

Bound=200;

SeqList=UnrollRecurrence[SeqNormalized,Seq[α],SeqListIni,Bound];

seq[n_]:=SeqList[[n+1]];

Guess a Minimal REC for r(n).
SeqfromRECGuess gives the REC in Theorem 6.2!  (To be displayed at the end of this notebook)
REC: Order 7
ODE: Order 19, Degree 7

ClearAll[Seq];
RECGuess=GuessMinRE[Take[SeqList,200],Seq[α]];
RECGuessinS=NormalizeCoefficients[ToOrePolynomial[RECGuess/.{Seq[k_]->((S[α])^(k-α))}]];

RECGuessinSOrder=OrePolynomialDegree[RECGuessinS,S[α]]

ODEfromRECGuessinD=NormalizeCoefficients[DFiniteRE2DE[{RECGuessinS},{α},{z}][[1]]];

ODEfromRECGuessinTheta=NormalizeCoefficients[ChangeOreAlgebra[z**ODEfromRECGuessinD,OreAlgebra[Euler[z]]]];

ODEfromRECGuessinThetaOrder=OrePolynomialDegree[ODEfromRECGuessinTheta,Euler[z]]

ODEfromRECGuessinThetaDegree=Max[Exponent[OrePolynomialListCoefficients[ODEfromRECGuessinTheta],z]]

We may also write this REC explicitly.

ClearAll[Seq];
SeqfromRECGuess=ApplyOreOperator[RECGuessinS,Seq[α]];

SeqfromRECGuessList=UnrollRecurrence[SeqfromRECGuess,Seq[α],Take[SeqList,RECGuessinSOrder],200];

Prove the minimal REC for r(n).

RECCompare=DFinitePlus[{RECNormalizedinS},{RECGuessinS}][[1]];

Compute the largest positive integral root of the leading coefficient in the recurrence RECCompare.

LeadCoeff=RECCompare[[1,1,1]];
LeadCoeffRoot=Solve[LeadCoeff==0,α][[All,1,2]]

There are no positive integral roots in our case.

Select[Select[LeadCoeffRoot,IntegerQ],#>0&]

RECCompareOrder=OrePolynomialDegree[RECCompare,S[α]]

CheckNum=RECCompareOrder+20;
Take[SeqList,CheckNum]-Take[SeqfromRECGuessList,CheckNum]

Display the REC in Theorem 6.2

Collect[Expand[SeqfromRECGuess],Seq[_]]