Composition of functions

There are different ways to define a function of more than one variable in Mathematica.

f[x_,y_,z_,t_]:=(x y z Sin[2π t])/(x^2 + y^2 + z^2)

g[x_,y_]:={y,x^2}

h[t_]:={Sin[t],Cos[t],t,2t}

Taking the composition of two functions is relatively easy (don't forget to evaluate the functions above first):

h[f[x, y, z, t]]

{Sin[(x y z Sin[2 π t])/(x^2 + y^2 + z^2)], Cos[(x y z Sin[2 π t])/(x^2 + y^2 + z^2)], (x y z Sin[2 π t])/(x^2 + y^2 + z^2), (2 x y z Sin[2 π t])/(x^2 + y^2 + z^2)}

However, try:

g[g[x, y]]

g[{y, x^2}]

This doesn't work.  It SHOULD work, but it doesn't. To get around this problem, we will often define functions of more than one variable in the following way:

g[{x_, y_}] := {y, x^2}

Now:

g[g[x, y]]

{x^2, y^2}

Problem

Will f[h[t]] work with the above definitions?  Should it?  If so, modify the definitions so it does.


Created by Mathematica  (February 28, 2007) Valid XHTML 1.1!