On 9/3/08, sahutoglu sonmez <sahutsonmez at yahoo.com> wrote:
> I am trying to generate recursive functions. That is, let say I have a recursion
> $X_n=A_nX_{n-1}+F_n$ where X_n and F_n are vector functions and A_n is a
> matrix. Furthermore, let say I know $X_04 and $F_n$ for all n. How do use
> Maxima to write a loop or a procedure to find $X_n$ for all n?
Well, one way to do this in Maxima is to make X a so-called memoizing
function, which remembers values which have been generated already.
A and F are also functions of n, but not recursive, so they can be
ordinary functions. E.g.
X0 : 4; /* unclear above */
X [n] := if n > 0 then A (n) . X [n - 1] + F (n) else X0;
A (n) := <whatever>;
F (n) := <whatever>;
Writing X[n] := ... shows that X is a memoizing function; X(n) := ... is
an ordinary function.
I'm assuming that A and F depend only on n. If they depend on some
global variable also, then the value of X[n] depends on it too;
in that case X should be an ordinary function (a memoizing function
yields an incorrect result in that case).
HTH
Robert Dodier