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

Examples

Use nmin to guarantee that enough terms are taken into account.

> L:=[1$9,seq(i,i=1..20)];
\[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\]
> procu:=proc(i) L[i+1] end;
\[\textbf{proc} (i) \\ \mapleIndent{1} L[i + 1]\\ \textbf{end\ proc};\]
> gfun:-proctorec(procu,u,n);
\[[\{-u \! \left(n \right)+u \! \left(n +1\right), u \! \left(0\right) = 1\}, 8]\]
> gfun:-proctorec(procu,u,n,20);
\[[\{\left(n -8\right) u \! \left(n \right)+\left(-2 n +16\right) u \! \left(n +1\right)+\left(n -8\right) u \! \left(n +2\right), u \! \left(0\right) = 1, u \! \left(1\right) = 1, u \! \left(2\right) = 1, u \! \left(3\right) = 1, u \! \left(4\right) = 1, u \! \left(5\right) = 1, u \! \left(6\right) = 1, u \! \left(7\right) = 1, u \! \left(8\right) = 1, u \! \left(9\right) = 1, u \! \left(10\right) = 2\}, 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);
\[[\{-u \! \left(n \right)+u \! \left(n +1\right), u \! \left(0\right) = 1\}, 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);
\[[\mathit{FAIL}, 7]\]

See Also

gfun, reducerecorder