#GuessRec2: A Maple PACKAGE FOR Conjecturing recurrences print(` GuessRec2: A Maple package for conjecturing recurrences `): print(` Determinant Identities by Dodgson's Condensation Method `): print(`Version of June 4, 1997`): print(`written by `): print(` Doron Zeilberger(zeilberg@math.temple.edu).`): lprint(``): print(`The most current version is always available from`): print(`http://www.math.temple.edu/~zeilberg`): print(`For a list of the procedures type ezra(), for help with`): print(`a specific procedure, type ezra(procedure_name)`): ezra:=proc() if args=NULL then print(`Contains the following procedures:`): print(` findrecs, findrec, findrecs2V11, findrec2V1, findrec2V2 `): fi: if nops([args])=1 and op(1,[args])=`Hankelf` then print(` Hankelf(h,t,n,r,N,R) or Hankelf(h,t,n,r,N,R,MAX) `): print(` Given an expression in t, h(t), variable names `): print(` n,r, and a names for the shift operator in n, N `): print(`and shift operator in r, R `): print(` and (optionaly) an integer MAX that bounds the order+degrees `): print(`of the recurrences looked for, (default=10). `): print(``): print(` Define A(n,r):=det(h(r+i+j),0<=i,j<=n-1)) and `): print(` f(n,r):=A(n+1,r)/A(n,r) looks empirically for`): print(` linear recurrence operators,ope1(n,r,N) and ope2(n,r,R) `): print(` that annihilate f(n,r) ` ): print(` The output is : ope1,ope2 `): print(``): print(` Once again: Hankelf(h,t,n,r,N,R) or Hankelf(h,t,n,r,N,R,MAX) `): fi: if nops([args])=1 and op(1,[args])=`Hankelg` then print(` Hankelg(h,t,n,r,N,R) or Hankelg(h,t,n,r,N,R,MAX) `): print(` Given an expression in t, h(t), variable names `): print(` n,r, and a names for the shift operator in n, N `): print(`and shift operator in r, R `): print(` and (optionaly) an integer MAX that bounds the order+degrees `): print(`of the recurrences looked for, (default=10). `): print(``): print(` Define A(n,r):=det(h(r+i+j),0<=i,j<=n-1)) and `): print(` g(n,r):=A(n,r+1)/A(n,r) looks empirically for`): print(` linear recurrence operators,ope1(n,r,N) and ope2(n,r,R) `): print(` that annihilate g(n,r) ` ): print(` The output is : ope1,ope2 `): print(``): print(` Once again: Hankelg(h,t,n,r,N,R) or Hankelg(h,t,n,r,N,R,MAX) `): fi: if nops([args])=1 and op(1,[args])=`Toeplitzf` then print(` Toeplitzf(h,t,n,r,N,R) or Toeplitzf(h,t,n,r,N,R,MAX) `): print(` Given an expression in t, h(t), variable names `): print(` n,r, and a names for the shift operator in n, N `): print(`and shift operator in r, R `): print(` and (optionaly) an integer MAX that bounds the order+degrees `): print(`of the recurrences looked for, (default=10). `): print(``): print(` Define A(n,r):=det(h(r+i-j),0<=i,j<=n-1)) and `): print(` f(n,r):=A(n+1,r)/A(n,r) looks empirically for`): print(` linear recurrence operators,ope1(n,r,N) and ope2(n,r,R) `): print(` that annihilate f(n,r) ` ): print(` The output is : ope1,ope2 `): print(``): print(` Once again: Toeplitzf(h,t,n,r,N,R) or Toeplitzf(h,t,n,r,N,R,MAX) `): fi: if nops([args])=1 and op(1,[args])=`Toeplitzg` then print(` Toeplitzg(h,t,n,r,N,R) or Toeplitzg(h,t,n,r,N,R,MAX) `): print(` Given an expression in t, h(t), variable names `): print(` n,r, and a names for the shift operator in n, N `): print(`and shift operator in r, R `): print(` and (optionaly) an integer MAX that bounds the order+degrees `): print(`of the recurrences looked for, (default=10). `): print(``): print(` Define A(n,r):=det(h(r+i-j),0<=i,j<=n-1)) and `): print(` g(n,r):=A(n,r+1)/A(n,r) looks empirically for`): print(` linear recurrence operators,ope1(n,r,N) and ope2(n,r,R) `): print(` that annihilate g(n,r) ` ): print(` The output is : ope1,ope2 `): print(``): print(` Once again: Toeplitzg(h,t,n,r,N,R) or Toeplitzg(h,t,n,r,N,R,MAX) `): fi: if nops([args])=1 and op(1,[args])=`HankelfB` then print(` HankelfB(h,t,n,r,R) or HankelfB(h,t,n,r,R,MAX) `): print(` Given an expression in t, h(t), variable names `): print(` n,r, and a name for the shift operator in n, N `): print(` and (optionaly) an integer MAX that bounds the order+degrees `): print(`of the recurrences looked for, (default=10). `): print(``): print(` Define A(n,r):=det(h(r+i+j),0<=i,j<=n-1)) and `): print(` f(n,r):=A(n+1,r)/A(n,r) looks empirically for`): print(` linear recurrence operators, ope2(n,r,R) `): print(` that annihilate f(n,r) ` ): fi: if nops([args])=1 and op(1,[args])=`HankelfA` then print(` HankelfA(h,t,n,r,N) or HankelfA(h,t,n,r,N,MAX) `): print(` Given an expression in t, h(t), variable names `): print(` n,r, and a name for the shift operator in n, N `): print(` and (optionaly) an integer MAX that bounds the order+degrees `): print(`of the recurrences looked for, (default=10). `): print(``): print(` Define A(n,r):=det(h(r+i+j),0<=i,j<=n-1)) and `): print(` f(n,r):=A(n+1,r)/A(n,r) looks empirically for`): print(` linear recurrence operators, ope1(n,r,N) `): print(` that annihilate f(n,r) ` ): fi: if nops([args])=1 and op(1,[args])=`findrecs2V11` then print(` findrecs2V11(a,ORD,DEG1,DEG2,n1,n2,N1): `): print(` Given a procedure a such that a(i1,i2) are `): print(` numerical or algebraic expressions for non-negative `): print(` integerss i1 and i2 `): print(` and non-negative integers ORD and DEG1 and DEG2 and `): print(` letters n1,n2 and N1 `): print(` conjectues, empirically, the recurrence operator ope(n1,n2,N1), `): print(` such that ope(n1,n2,N1)a(n)=0, where N1f(n1,n2)=f(n1+1,n2) `): fi: if nops([args])=1 and op(1,[args])=`findrec2V1` then print(` findrec2V1(a,n1,n2,N1): `): print(` Given a procedure a such that a(i1,i2) are `): print(` numerical or algebraic expressions for non-negative `): print(` integerss i1 and i2 `): print(` and letters n1,n2 and N1 `): print(` conjectues, empirically, the recurrence operator ope(n1,n2,N1), `): print(` such that ope(n1,n2,N1)a(n1,n2)=0, where N1f(n1,n2)=f(n1+1,n2) `): fi: if nops([args])=1 and op(1,[args])=`findrec2V2` then print(` findrec2V2(a,n1,n2,N2): `): print(` Given a procedure a such that a(i1,i2) are `): print(` numerical or algebraic expressions for non-negative `): print(` integerss i1 and i2 `): print(` and letters n1,n2 and N2 `): print(` conjectues, empirically, the recurrence operator ope(n1,n2,N2), `): print(` such that ope(n1,n2,N2)a(n1,n2)=0, where N2f(n1,n2)=f(n1,n2+1) `): fi: if nops([args])=1 and op(1,[args])=`findrecs` then print(`findrecs(a,ORD,DEG,n,N): Given a procedure a such that a(i) are`): print(`numerical or algebraic expressions for non-negative integers i`): print(`and non-negative integers ORD and DEG and letters n and N`): print(`conjectues, empirically, the recurrence operator ope(n,N),`): print(`such that ope(n,N)a(n)=0, where Nf(n)=f(n+1)`): fi: if nops([args])=1 and op(1,[args])=`findrec` then print(`findrec(a,n,N) or findrec(a,n,N,MAX):`): print(` Given a procedure a such that a(i) are`): print(`numerical or algebraic expressions for non-negative integers i`): print(`and symbols n and N`): print(`conjectues, empirically, a recurrence operator ope(n,N),`): print(`such that ope(n,N)a(n)=0, where Nf(n)=f(n+1)`): print(`MAX is the maximum of Degree+Order that the computer looks at.`): print(` If it is not stated, the default is taken to be 10`): fi: end: #findrecs(a,ORD,DEG,n,N): Given a procedure a such that a(i) are #numerical or algebraic expressions for non-negative integers i #and non-negative integers ORD and DEG and letters n and N #conjectues, empirically, the recurrence operator ope(n,N), #such that ope(n,N)a(n)=0, where Nf(n)=f(n+1) findrecs:=proc(a,ORD,DEG,n,N) local ope1,i,j,c,eq,var,n1,ope2,lu,c1,eq1: if not type(op(a),procedure) then ERROR(`First argument must be a procedure`): fi: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG,integer) or DEG<0 then print(`Third argument is the maximal degree of the coefficients`): ERROR(`must be a non-negative integer`): fi: if not type(n,symbol) then print(` 4th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N,symbol) then lprint(` 5th argument is the symbol for the shift in`, n): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i from 0 to DEG do for j from 0 to ORD do ope1:=ope1+c[i,j]*n^i*N^j: var:=var union {c[i,j]}: od: od: eq:={}: for n1 from 0 to (DEG+1)*(ORD+1)+5 do lu:=0: for i from 0 to ORD do lu:=lu+subs(n=n1,coeff(ope1,N,i))*a(n1+i): od: eq:=eq union {lu}: od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then print(`Order or Degree too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N,i))*N^i: od: ope2: end: #findrec(a,n,N,MAX): Given a procedure a such that a(i) are #numerical or algebraic expressions for non-negative integers i #and letters n and N #conjectues, empirically, the recurrence operator ope(n,N), #such that ope(n,N)a(n)=0, where Nf(n)=f(n+1) #MAX is the maximum of Degree+Order to try findrec1:=proc(a,n,N,MAX) local mu,ORD,DEG,gu: for DEG from 0 to 4 do gu:=findrecs(a,0,DEG,n,N): if gu<>0 then RETURN(gu): fi: od: for DEG from 0 to 8 do gu:=findrecs(a,1,DEG,n,N): if gu<>0 then RETURN(gu): fi: od: for mu from 0 to MAX do for ORD from 2 to mu do DEG:=mu-ORD: gu:=findrecs(a,ORD,DEG,n,N): if gu<>0 then RETURN(gu): fi: od: od: print(`No recurrence found whose ORDER+DEG <=`,MAX): 0: end: findrec:=proc(): if nargs=4 then findrec1(args): elif nargs=3 then findrec1(args,10): else ERROR(`findrec(a,n,N) or findrec*a,n,N,MAX)`): fi: end: #findrecs2V11(a,ORD,DEG1,DEG2,n1,n2,N1): #Given a procedure a such that a(i1,i2) are #numerical or algebraic expressions for non-negative #integerss i1 and i2 #and non-negative integers ORD and DEG1 and DEG2 and #letters n1,n2 and N1 #conjectues, empirically, the recurrence operator ope(n1,n2,N1), #such that ope(n1,n2,N1)a(n)=0, where N1f(n1,n2)=f(n1+1,n2) findrecs2V11:=proc(a,ORD,DEG1,DEG2,n1,n2,N1) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(op(a),procedure) then ERROR(`First argument must be a procedure`): fi: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N1,symbol) then lprint(` 7th argument is the symbol for the shift in`, n1): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N1^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N1,i))*a(n1a+i,n2a): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N1,i))*N1^i: od: ope2: end: #findrec2V11(a,n,m,N,MAX): Given a procedure a such that a(i,j) are #numerical or algebraic expressions for non-negative integers i,j #and letters n,m, and N #conjectues, empirically, the recurrence operator ope(n,m,N), #such that ope(n,m,N)a(n,m)=0, where Nf(n,m)=f(n+1,m) #MAX is the maximum of Sum of Degree+Order to try findrec2V11:=proc(a,n,m,N,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=findrecs2V11(a,1,DEG1,DEG2,n,m,N): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=findrecs2V11(a,ORD,DEG1,DEG2,n,m,N): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: findrec2V1:=proc(): if nargs=5 then findrec2V11(args): elif nargs=4 then findrec2V11(args,10): else ERROR(`findrec2V1(a,m,n,N) or findrec2V1(a,n,m,N,MAX)`): fi: end: #findrecs2V21(a,ORD,DEG1,DEG2,n1,n2,N2): #Given a procedure a such that a(i1,i2) are #numerical or algebraic expressions for non-negative #integerss i1 and i2 #and non-negative integers ORD and DEG1 and DEG2 and #letters n1,n2 and N2 #conjectues, empirically, the recurrence operator ope(n1,n2,N1), #such that ope(n1,n2,N2)a(n)=0, where N2f(n1,n2)=f(n1,n2+1) findrecs2V21:=proc(a,ORD,DEG1,DEG2,n1,n2,N2) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(op(a),procedure) then ERROR(`First argument must be a procedure`): fi: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N2,symbol) then lprint(` 7th argument is the symbol for the shift in`, n2): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N2^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N2,i))*a(n1a,n2a+i): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N2,i))*N2^i: od: ope2: end: #findrec2V21(a,n,m,M,MAX): Given a procedure a such that a(i,j) are #numerical or algebraic expressions for non-negative integers i,j #and letters n,m, and M #conjectues, empirically, the recurrence operator ope(n,m,N), #such that ope(n,m,M)a(n,m)=0, where Mf(n,m)=f(n,m+1) #MAX is the maximum of Sum of Degree+Order to try findrec2V21:=proc(a,n,m,M,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=findrecs2V21(a,1,DEG1,DEG2,n,m,M): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=findrecs2V21(a,ORD,DEG1,DEG2,n,m,M): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: findrec2V2:=proc(): if nargs=5 then findrec2V21(args): elif nargs=4 then findrec2V21(args,10): else ERROR(`findrec2V2(a,m,n,N) or findrec2V2(a,n,m,N,MAX)`): fi: end: #########Start Hankel AHankel:=proc(h,r,i,j) option remember: if i=0 then RETURN(1): elif i=1 then RETURN(subs(r=j,h)): else RETURN((AHankel(h,r,i-1,j+2)*AHankel(h,r,i-1,j)- AHankel(h,r,i-1,j+1)^2)/AHankel(h,r,i-2,j+2)): fi: end: fHankel:=proc(h,r,i,j): AHankel(h,r,i+1,j)/AHankel(h,r,i,j): end: gHankel:=proc(h,r,i,j): AHankel(h,r,i,j+1)/AHankel(h,r,i,j): end: #HankelfA(h,t,n,r,N) or HankelfA(h,t,n,r,N,MAX) #Given an expression in t, h(t), variable names #n,r, and a name for the shift operator in n, N #and (optionaly) an integer MAX that bounds the order+degrees of the #recurrences looked for, (default=10). #Define A(n,r):=det(h(r+i+j),0<=i,j<=n-1)) and #f(n,r):=A(n+1,r)/A(n,r) looks empirically for #linear recurrence operators, ope1(n,r,N) and ope2(n,r,R) #that annihilate f(n,r) #HankelfA1(h,n,r,N,R,MAX): Given an expression in r, h(r), #and an integer MAX that bounds the order+degrees of the #recurrences looked for, define #A(n,r):=det(h(r+i+j),0<=i,j<=n-1)) and #f(n,r):=A(n+1,r)/A(n,r) looks empirically for #linear recurrence operators, ope1(n,r,N) and ope2(n,r,R) #that annihilate f(n,r) HankelfA11:=proc(h,r,ORD,DEG1,DEG2,n1,n2,N1) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N1,symbol) then lprint(` 7th argument is the symbol for the shift in`, n1): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N1^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N1,i))*fHankel(h,r,n1a+i,n2a): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then #print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N1,i))*N1^i: od: ope2: end: HankelfA1:=proc(h,r1,n,r,N,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=HankelfA11(h,r1,1,DEG1,DEG2,n,r,N): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=HankelfA11(h,r1,ORD,DEG1,DEG2,n,r,N): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: HankelfA:=proc(): if nargs=6 then HankelfA1(args): elif nargs=5 then HankelfA1(args,10): else ERROR(`HankelfA1(h,r1,n,r,N,MAX) or HankelfA1(h,r1,n,r,N)`): fi: end: HankelfB11:=proc(h,r,ORD,DEG1,DEG2,n1,n2,N2) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N2,symbol) then lprint(` 7th argument is the symbol for the shift in`, n2): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N2^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N2,i))*fHankel(h,r,n1a,n2a+i): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then #print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N2,i))*N2^i: od: ope2: end: HankelfB1:=proc(h,r1,n,r,R,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=HankelfB11(h,r1,1,DEG1,DEG2,n,r,R): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=HankelfB11(h,r1,ORD,DEG1,DEG2,n,r,R): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: HankelfB:=proc(): if nargs=6 then HankelfB1(args): elif nargs=5 then HankelfB1(args,10): else ERROR(`HankelfB(h,r1,n,r,R,MAX) or HankelfB(h,r1,n,r,R)`): fi: end: Hankelf:=proc() local h,t,n,r,N,R,MAX: h:=args[1]: t:=args[2]: n:=args[3]: r:=args[4]: N:=args[5]: R:=args[6]: if nargs=7 then MAX:=args[7]: fi: if nargs=6 then RETURN(HankelfA(h,t,n,r,N),HankelfB(h,t,n,r,R)): elif nargs=7 then RETURN(HankelfA(h,t,n,r,N,MAX),HankelfB(h,t,n,r,R,MAX)): else ERROR(`Hankelf(h,t,n,r,N,R) or Hankelf(h,t,n,r,N,R,MAX)`): fi: end: HankelgA11:=proc(h,r,ORD,DEG1,DEG2,n1,n2,N1) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N1,symbol) then lprint(` 7th argument is the symbol for the shift in`, n1): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N1^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N1,i))*gHankel(h,r,n1a+i,n2a): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then #print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N1,i))*N1^i: od: ope2: end: HankelgA1:=proc(h,r1,n,r,N,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=HankelgA11(h,r1,1,DEG1,DEG2,n,r,N): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=HankelgA11(h,r1,ORD,DEG1,DEG2,n,r,N): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: HankelgA:=proc(): if nargs=6 then HankelgA1(args): elif nargs=5 then HankelgA1(args,10): else ERROR(`HankelgA1(h,r1,n,r,N,MAX) or HankelgA1(h,r1,n,r,N)`): fi: end: HankelgB11:=proc(h,r,ORD,DEG1,DEG2,n1,n2,N2) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N2,symbol) then lprint(` 7th argument is the symbol for the shift in`, n2): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N2^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N2,i))*gHankel(h,r,n1a,n2a+i): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then #print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N2,i))*N2^i: od: ope2: end: HankelgB1:=proc(h,r1,n,r,R,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=HankelgB11(h,r1,1,DEG1,DEG2,n,r,R): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=HankelgB11(h,r1,ORD,DEG1,DEG2,n,r,R): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: HankelgB:=proc(): if nargs=6 then HankelgB1(args): elif nargs=5 then HankelgB1(args,10): else ERROR(`HankelgB1(h,r1,n,r,R,MAX) or HankelgB1(h,r1,n,r,R)`): fi: end: Hankelg:=proc() local h,t,n,r,N,R,MAX: h:=args[1]: t:=args[2]: n:=args[3]: r:=args[4]: N:=args[5]: R:=args[6]: if nargs=7 then MAX:=args[7]: fi: if nargs=6 then RETURN(HankelgA(h,t,n,r,N),HankelgB(h,t,n,r,R)): elif nargs=7 then RETURN(HankelgA(h,t,n,r,N,MAX),HankelgB(h,t,n,r,R,MAX)): else ERROR(`Hankelg(h,t,n,r,N,R) or Hankelg(h,t,n,r,N,R,MAX)`): fi: end: ###########Start Toeplitz AToeplitz:=proc(h,r,i,j) option remember: if i=0 then RETURN(1): elif i=1 then RETURN(subs(r=j,h)): else RETURN( normal(expand((AToeplitz(h,r,i-1,j)^2- AToeplitz(h,r,i-1,j+1)*AToeplitz(h,r,i-1,j-1))/AToeplitz(h,r,i-2,j)))): fi: end: fToeplitz:=proc(h,r,i,j): AToeplitz(h,r,i+1,j)/AToeplitz(h,r,i,j): normal(%): end: gToeplitz:=proc(h,r,i,j): AToeplitz(h,r,i,j+1)/AToeplitz(h,r,i,j): normal(%): end: #ToeplitzfA(h,t,n,r,N) or ToeplitzfA(h,t,n,r,N,MAX) #Given an expression in t, h(t), variable names #n,r, and a name for the shift operator in n, N #and (optionaly) an integer MAX that bounds the order+degrees of the #recurrences looked for, (default=10). #Define A(n,r):=det(h(r+i+j),0<=i,j<=n-1)) and #f(n,r):=A(n+1,r)/A(n,r) looks empirically for #linear recurrence operators, ope1(n,r,N) and ope2(n,r,R) #that annihilate f(n,r) #ToeplitzfA1(h,n,r,N,R,MAX): Given an expression in r, h(r), #and an integer MAX that bounds the order+degrees of the #recurrences looked for, define #A(n,r):=det(h(r+i+j),0<=i,j<=n-1)) and #f(n,r):=A(n+1,r)/A(n,r) looks empirically for #linear recurrence operators, ope1(n,r,N) and ope2(n,r,R) #that annihilate f(n,r) ToeplitzfA11:=proc(h,r,ORD,DEG1,DEG2,n1,n2,N1) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N1,symbol) then lprint(` 7th argument is the symbol for the shift in`, n1): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N1^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N1,i))*fToeplitz(h,r,n1a+i,n2a): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then #print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N1,i))*N1^i: od: ope2: end: ToeplitzfA1:=proc(h,r1,n,r,N,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=ToeplitzfA11(h,r1,1,DEG1,DEG2,n,r,N): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=ToeplitzfA11(h,r1,ORD,DEG1,DEG2,n,r,N): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: ToeplitzfA:=proc(): if nargs=6 then ToeplitzfA1(args): elif nargs=5 then ToeplitzfA1(args,10): else ERROR(`ToeplitzfA1(h,r1,n,r,N,MAX) or ToeplitzfA1(h,r1,n,r,N)`): fi: end: ToeplitzfB11:=proc(h,r,ORD,DEG1,DEG2,n1,n2,N2) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N2,symbol) then lprint(` 7th argument is the symbol for the shift in`, n2): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N2^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N2,i))*fToeplitz(h,r,n1a,n2a+i): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then #print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N2,i))*N2^i: od: ope2: end: ToeplitzfB1:=proc(h,r1,n,r,R,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=ToeplitzfB11(h,r1,1,DEG1,DEG2,n,r,R): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=ToeplitzfB11(h,r1,ORD,DEG1,DEG2,n,r,R): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: ToeplitzfB:=proc(): if nargs=6 then ToeplitzfB1(args): elif nargs=5 then ToeplitzfB1(args,10): else ERROR(`ToeplitzfB(h,r1,n,r,R,MAX) or ToeplitzfB(h,r1,n,r,R)`): fi: end: Toeplitzf:=proc() local h,t,n,r,N,R,MAX: h:=args[1]: t:=args[2]: n:=args[3]: r:=args[4]: N:=args[5]: R:=args[6]: if nargs=7 then MAX:=args[7]: fi: if nargs=6 then RETURN(ToeplitzfA(h,t,n,r,N),ToeplitzfB(h,t,n,r,R)): elif nargs=7 then RETURN(ToeplitzfA(h,t,n,r,N,MAX),ToeplitzfB(h,t,n,r,R,MAX)): else ERROR(`Toeplitzf(h,t,n,r,N,R) or Toeplitzf(h,t,n,r,N,R,MAX)`): fi: end: ToeplitzgA11:=proc(h,r,ORD,DEG1,DEG2,n1,n2,N1) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficients`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N1,symbol) then lprint(` 7th argument is the symbol for the shift in`, n1): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N1^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N1,i))*gToeplitz(h,r,n1a+i,n2a): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then #print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N1,i))*N1^i: od: ope2: end: ToeplitzgA1:=proc(h,r1,n,r,N,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=ToeplitzgA11(h,r1,1,DEG1,DEG2,n,r,N): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=ToeplitzgA11(h,r1,ORD,DEG1,DEG2,n,r,N): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: ToeplitzgA:=proc(): if nargs=6 then ToeplitzgA1(args): elif nargs=5 then ToeplitzgA1(args,10): else ERROR(`ToeplitzgA1(h,r1,n,r,N,MAX) or ToeplitzgA1(h,r1,n,r,N)`): fi: end: ToeplitzgB11:=proc(h,r,ORD,DEG1,DEG2,n1,n2,N2) local ope1,i,j,c,eq,var,n1a,n2a,ope2,lu,c1,eq1,i1,i2,Godel: if not type(ORD,integer) or ORD<0 then ERROR(`Second argument, is the ORDER, must be a non-negative integer`): fi: if not type(DEG1,integer) or DEG1<0 then print(`Third argument is the maximal degree of the coefficiens`): print(` in`,n1): ERROR(`must be a non-negative integer`): fi: if not type(DEG2,integer) or DEG2<0 then print(`Fourth argument is the maximal degree of the coefficients`): print(` in`,n2): ERROR(`must be a non-negative integer`): fi: if not type(n1,symbol) then print(` 5th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(n2,symbol) then print(` 6th argument is the argument of the sequence`): ERROR(`must be a symbol`): fi: if not type(N2,symbol) then lprint(` 7th argument is the symbol for the shift in`, n2): ERROR(`must be a symbol`): fi: ope1:=0: var:={}: for i1 from 0 to DEG1 do for i2 from 0 to DEG2 do for j from 0 to ORD do ope1:=ope1+c[i1,i2,j]*n1^i1*n2^i2*N2^j: var:=var union {c[i1,i2,j]}: od: od: od: eq:={}: Godel:=trunc(evalf(sqrt((DEG1+1)*(DEG2+1)*(ORD+1))))+3: for n1a from 0 to Godel do for n2a from 0 to Godel do lu:=0: for i from 0 to ORD do lu:=lu+subs({n1=n1a,n2=n2a},coeff(ope1,N2,i))*gToeplitz(h,r,n1a,n2a+i): od: eq:=eq union {lu}: od:od: var:=solve(eq,var): if var=NULL then RETURN(0): fi: c1:={}: for i from 1 to nops(var) do eq1:=op(i,var): if op(1,eq1)=op(2,eq1) then c1:=c1 union {op(1,eq1)}: fi: od: if nops(c1)>1 then #print(`Order or Degrees too high, lower them`): RETURN(0): fi: if nops(c1)=0 then RETURN(0): fi: c1:=op(1,c1): ope1:=subs(var,ope1): ope2:=0: ope1:=normal(ope1/c1): for i from 0 to ORD do ope2:=ope2+factor(coeff(ope1,N2,i))*N2^i: od: ope2: end: ToeplitzgB1:=proc(h,r1,n,r,R,MAX) local mu,ORD,DEG1,DEG2,gu: for mu from 0 to MAX do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=ToeplitzgB11(h,r1,1,DEG1,DEG2,n,r,R): if gu<>0 then RETURN(gu): fi: od: od: for ORD from 2 to MAX do for mu from 0 to MAX-ORD do for DEG1 from 0 to mu do DEG2:=mu-DEG1: gu:=ToeplitzgB11(h,r1,ORD,DEG1,DEG2,n,r,R): if gu<>0 then RETURN(gu): fi: od: od: od: print(`No recurrence found whose ORDER+Sum of Degrees <=`,MAX): 0: end: ToeplitzgB:=proc(): if nargs=6 then ToeplitzgB1(args): elif nargs=5 then ToeplitzgB1(args,10): else ERROR(`ToeplitzgB1(h,r1,n,r,R,MAX) or ToeplitzgB1(h,r1,n,r,R)`): fi: end: Toeplitzg:=proc() local h,t,n,r,N,R,MAX: h:=args[1]: t:=args[2]: n:=args[3]: r:=args[4]: N:=args[5]: R:=args[6]: if nargs=7 then MAX:=args[7]: fi: if nargs=6 then RETURN(ToeplitzgA(h,t,n,r,N),ToeplitzgB(h,t,n,r,R)): elif nargs=7 then RETURN(ToeplitzgA(h,t,n,r,N,MAX),ToeplitzgB(h,t,n,r,R,MAX)): else ERROR(`Toeplitzg(h,t,n,r,N,R) or Toeplitzg(h,t,n,r,N,R,MAX)`): fi: end: