:

## A question on procedures that return procedures

Maple
I'm trying to do symbiolic manipulations to define new procedures but I have trouble figuring out how to achieve my goal. The context is as follows: We have a set of ODEs df/dt = R(f(t)) where f(0) = x. Here f and x are n-dimensional vectors with components f[i], x[i], and R is a vector valued function with components R[i]; t is time. Example: R := proc (x::Vector) x end proc; R := proc (x::Vector) -x*(1+x^2) end proc; R := proc (x::Vector) x end proc; R := proc (x::Vector) -x*(1+x^2) end proc; Now, the Liouville operator is defined as L := proc(F::algebraic,a::list(algebraic)) sum('a[k] * diff(F,x[k])','k'=1..nops(a)); end proc: Here is how it works. If I define a function f as: f := proc (x::Vector) -x*(1+x^2) end proc then after defining a vector x and applying L to f(x) x := Vector(4, [u, u, u, u]) L(f(x), [R(x), R(x), R(x), R(x)]); gives u (-1 - u^2 ) - 2 u u u as it should. My problem is this: How to apply L to a function/procedure f(x) and return another function/procedure of a vector x? I do not want to copy this output and use it to define a new function because I want to apply L within a loop to a sequence of functions. To get the picture, think about generating a function basis in the 4 dimensional vector space which is made of products of Hermite polynomials of different orders acting on different coordinates of x. I need to be able to automatically apply L to this function base, like this L(H(p,x)*H(q,x)*H(r,x)*H(s,x),[R(x), R(x), R(x), R(x)]); and to extract a function/procedure of x from the output of L. My attempt at using the Maple description of how to generate a procedure that returns another procedure has failed. By the way, if there is a better way to define ODes and implement a Liouville operator, I'll be more than delighted to find out. The ODE example is from "Optimal prediction with memory" by Chorin et al, Physica D, 166, pp 239-257 (2002). If you read this interesting paper, you'll find out exactly what I'm trying to solve. ﻿