Multivariable Chain Rule

This is a simple demonstration of using Mathematica for computing derivatives using the chain rule in a multivariable setting.
    
Author:  Lt Col Steve Hadfield, US Air Force Academy, CO
Location:  ChainRule.nb

Chain Rule

Mathematica uses the D[-] command to compute derivatives and with version 3.0 and higher there is a fancier "nabla" notation available via the BasicInput palette (shown via File|Palette|BasicInput).
    Below is some information on the D[-] command followed by some examples of using the chain rule in a multivariable setting.

?? D

Example 1:

In this example we have a simple function T(x,y) where both x and y are defined parametrically using the parameter t.
              Line 1 - Clears the symbols we'll be using.
              Line 2 - Defines T(x,y).
              Lines 3 & 4 - Define x(t) and y(t) respectively.
              Line 5 - Computes the derivative.
              Line 6 - Evaluates the derivative using the substitution operator ("/.") setting t =2.

Clear[T, x, y, t]
T[x_, y_] = x - y^2;
x[t_] = t^3;
y[t_] = 5 - t;
D[T[x[t], y[t]], t]
D[T[x[t], y[t]], t] /. t -> 2

Example 2:

In this example, we have h(m,n) where m and n are functions of s and t.  We follow a very similar formulation as was done in Example 1, but compute both the possible partials of h with respect to s and t.  We also evalute both partials at the point (1,2).

Clear[h, m, n, s, t]
h[m_, n_] = Exp[m*n] - Cos[m*n];
m[s_, t_] = s^2 *t;
n[s_, t_] = t - s;
D[h[m[s, t], n[s, t]], s]
D[h[m[s, t], n[s, t]], t]
D[h[m[s, t], n[s, t]], s] /. {s -> 1, 
        t -> 2}
D[h[m[s, t], n[s, t]], t] /. {s -> 1, t -> 2}