Help:=proc(): print(`SeqToCfinite1(L,n)`): end: #Given a sequence L, tries to find a linear recurrence #equation, with constant coefficients if order n #satisfying it followed by the L initial conditions #[op(1..n,L)]; the linear reruccence #f(x)=a1*f(x-1)+ a2*f(x-2)+ ...+ an*f(x-n) is represneted #by [a1,a2, ..., an]. [rec,initila] #For example, the Fibonacci sequence #is represented by [[1,1],[1,1]]; #the Lucas sequence is represented by [[1,1],[1,3]] SeqToCfinite1:=proc(L,n) local rec,a,i,eq,var,sol: rec:=[seq(a[i],i=1..n)]: var:=convert(rec,set): eq:={seq(L[x]=add(a[i]*L[x-i],i=1..n),x=n+1..nops(L))}; sol:=solve(eq,var): if sol=NULL then RETURN(FAIL): fi: [subs(sol,rec),[op(1..n,L)]]; end: