LREtools[REtoproc] - convert a recurrence into a procedure
|
Calling Sequence
|
|
REtoproc(problem, options)
|
|
Parameters
|
|
problem
|
-
|
problem
|
options
|
-
|
optional arguments described below
|
|
|
|
|
Description
|
|
•
|
This procedure returns a Maple procedure that, given a non-negative integer n as input, gives the nth term of the linear recurrence.
|
•
|
If the argument 'remember' or 'remember'=true is specified, then the procedure will compute the sequence via a recursive procedure using option remember. By default, 'remember'=false and the sequence is computed iteratively.
|
•
|
The argument 'remember' should be given when one needs a large number of values of the sequence.
|
•
|
When 'remember'=false and the coefficients of the recurrence are nonconstant polynomials, the returned procedure will run in a straight loop, using a linear number of arithmetic operations and without wasting extra space.
|
•
|
When 'remember'=false and the coefficients are constant, the procedure will employ a binary-based optimization strategy (for large index values only), and runs with a logarithmic number of arithmetic operations. This optimization can be disabled by specifying constantoptimize=false.
|
•
|
When 'remember'=false, by default the initial terms of the recurrence are embedded in the code. This can be changed to put the initial terms of the recurrence in the remember table by specifying initialremember=true.
|
•
|
When the first terms of the recurrence are not explicitly supplied, they are represented symbolically.
|
•
|
The command with(LREtools,REtoproc) allows the use of the abbreviated form of this command.
|
|
|
Examples
|
|
>
|
|
>
|
fib := REtoproc(f(i)=f(i-1)+f(i-2),f(i),{f(0)=0,f(1)=1});
|
| (1) |
>
|
|
| (2) |
>
|
fib2 := REtoproc(f(i)=f(i-1)+f(i-2),f(i),{f(0)=0,f(1)=1},'remember');
|
| (3) |
>
|
|
| (4) |
>
|
rec := REtoproc(f(i)=i^2*f(i-1)+f(i-2),f(i),{},'remember');
|
| (5) |
>
|
|
| (6) |
>
|
|
|
|
Download Help Document
Was this information helpful?