Help:=proc(): print(` GuessRec1(L,r) `): end: #GuessRec1(L,r): inputs a sequence of numbers, L, and a pos. #integer r, and tries to guess a linear recurrence equation #of order r satisfied by it #L(n)+c1*L(n-1)+...+cr*L(n-r)=0 for all n within the range #The output would be given as a list of r numbers #[[c1,c2,...,cr],InitialConditions] #For example, the Fibonacci sequence is #[[-1,-1], [1,1]] GuessRec1:=proc(L,r) local c,i,var,eq: if nops(L)<=2*r+6 then RETURN(FAIL): fi: var:={seq(c[i],i=1..r)}: eq:={seq( L[n]+add(c[i]*L[n-i],i=1..r)=0 , n=r+1..nops(L))}: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: [[seq(subs(var, c[i]),i=1..r)], L[1..r] ] ; end: #GuessRec(L): inputs a sequence of numbers, L, # and tries to guess a linear recurrence equation #of some order, r, satisfied by it #L(n)+c1*L(n-1)+...+cr*L(n-r)=0 for all n within the range #The output would be given as a list of r numbers #[[c1,c2,...,cr],InitialConditions] #For example, the Fibonacci sequence is #[[-1,-1], [1,1]] GuessRec:=proc(L) local r,ans: for r from 1 to (nops(L)-6)/2 do ans:=GuessRec1(L,r): if ans<>FAIL then RETURN(ans): fi: od: FAIL: end: