picking out parts of a expresssion



> I would like to go thru this expression, and pull out the
> arguments of these 2 functions.

The easiest way I can think of is a simple recursive function:

funcargs(expr,funcs):=
  if atom(expr) or constantp(expr)
     then []
  else
  if member(part(expr,0),funcs)
     then [expr]
  else
     apply(append,
           makelist(funcargs(subexpr,funcs),subexpr,args(expr)));

(C13) funcargs(a^2+f(y/3)-g(f(x)),[f]);
                            y
(D13)                    [f(-), f(x)]
                            3
(C14) funcargs(a^2+f(y/3)-g(f(x)),[f,g]);
                          y
(D14)                  [f(-), g(f(x))]
                          3

If you want to include cases where one function is called within
another:

funcargs(expr,funcs):=
  if atom(expr) or numberp(expr)
    then []
  else append(if member(part(expr,0),funcs)
                 then [expr]
                 else [],
              apply(append,
                    makelist(funcargs(subexpr,funcs),
                             subexpr,
                             args(expr) ) ) );

(C30) funcargs(f(g(x)-g(f(x))),[f,g]);
(D30)    [f(g(x) - g(f(x))), g(x), g(f(x)), f(x)]

If you want to exclude functions called within subscripts (e.g. q[f(i)],
then add the class "or subvarp(expr)" after numberp.

This function does not handle subscipted functions, e.g. bessel[i](x).