Composition of functions

There are different ways to define a function of more than one variable in Mathematica. For each of the following, give the dimension of the domain space and the dimension of the range space:

Problem
In[11]:=

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

Problem
In[12]:=

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

Problem
In[13]:=

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):

In[14]:=

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

Out[14]=

{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:

In[15]:=

g[g[x, y]]

Out[15]=

g[{y, x^2}]

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

In[16]:=

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

Now:

In[17]:=

g[g[x, y]]

Out[17]=

{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  (September 14, 2004)