Iterating a command in Maple

70 Views Asked by At

I am trying to implement a Maple code which calculates the $n$-th iterate of a differential operator. For example I have the operator

L:= f-> diff(f,t$2) + diff(f,t);

Now e.g. the second iterate of this operator can be calculated by writing L(L(f(t))); However this quickly gets out of hand if I want to calculate higher order iterates of $L$, and sometimes I would even like to have variable order (e.g. in sums).

Is there a command in Maple which would allow me to specify the order of iteration $n$, the operator $L$, and the function $f(t)$, and which would return the expression for $L^n(f)$?

I tried to write a procedure for this using a for loop but this didn't work out for me since it says I have "too many levels of recursion". Here's the code:

Ln := proc (n, f) 
   local g, i; 
   g := t -> L(f(t));
   for i from 1 to n do: 
       g := t -> L(g(t))
   end do: 
   g(t);
end proc;