gfun[proctorec] - Compute a recurrence by guessing, using more and more terms of a sequence - given as a procedure.
Calling Sequence
proctorec( procu, u, n, <nmin>,<nmax>, <homogeneous=bool>, <operator=name>)
Parameters
procu - pocedure for computing u(n)
u,n - name and index of recurrence,
nmin - (optional) minimal number of terms to guess with,
nmax - (optional) maximal number of terms to guess with.
homogeneous - (optional) boolean selecting homogeneous or inhomogeneous guessing; the default is true.
operator - (optional) name used verbatim as the shift operator
Description
- The procedure outputs a list made of a recurrence and a number k :
- - the linear recurrence defines u(0), ..., u(k) - and we have nmin <= k <= nmax (with k=nmin if nmin>nmax). The recurrence is looked for on initial values. The values u(0), ..., u(j) are used for guessing, where j goes exponentially from nmin to nmax :
- If
nmaxis infinite, then nmin, 2*nmin, 4*nmin,... initial values are used for guessing, until a recurrence can be guessed. - Otherwise, nmin, nmax/2^i, 2*nmax/2^i, ..., up to nmax/4, nmax/2, and finally nmax terms are used for guessing, with i minimal s.t. the sequence is strictly increasing.
- The option
homogeneous=boolis passed to the recurrence guesser. Its default istrue, preserving the historical behavior ofproctorec. - With
operator=name, the first component of the returned list is an operator polynomial (orL(name)=-qfor inhomogeneous guessing), and initial conditions are not computed. The second component remains the number of terms used.
Examples
Use nmin to guarantee that enough terms are taken into account.
> L:=[1$9,seq(i,i=1..20)];
> procu:=proc(i) L[i+1] end;
> gfun:-proctorec(procu,u,n);
> gfun:-proctorec(procu,u,n,20);
Conversely, set a finite nmax to restrict the domain of the procedure, and prevent from failure.
> L:=L[1..7]; procu:=proc(i) L[i+1] end:
> gfun:-proctorec(procu,u,n,7,7);
Setting nmin < nmax will result in a FAIL recurrence, even if guessing with nmin terms may succeed.
> gfun:-proctorec(procu,u,n,8,7);