In this lab we will get more comfortable using some of the symbolic power of Mathematica. In the process we will explore the Chain Rule applied to functions of many variables.
A function is a rule that assigns a single value to every point in space, e.g. w=f(x,y) assigns the value w to each point (x,y) in two dimensional space. If we define a parametric path x=g(t), y=h(t), then the function w(t) = f(g(t),h(t)) is univariate along the path. The derivative can be found by either substitution and differentiation,
or by the Chain Rule,
Let's pick a reasonably grotesque function,
First, define the function for later usage:
f[x_,y_] := Cos[ x^2 y - Log[ (y^2 +2)/(x^2+1) ] ]Now, let's find the derivative of f along the elliptical path , . First, by direct substitution. Find w(t);
woft = f[ 4 Cos[t], 9 Sin[t] ]The derivative can then be found using
dwdt1 = D[ woft, t]How would you have liked to do that by hand?
Now let's try using the Chain Rule. First, define the path variables:
xx = 4 Cos[t]; yy = 9 Sin[t];and now let's do the Chain Rule:
crule = D[f[x,y],x] D[xx,t] + D[f[x,y],y] D[yy,t]Notice that this has variables x,y and t. That is because we have not substituted the path in for x and y. To do this, we will use the substitution operation in Mathematica, `/. ->'. Try this to find the final form of :
dwdt2 = crule/.{x->4 Cos[t], y->9 Sin[t]}To see that the two methods yield the same answer, try subtracting them and simplifying:
Simplify[dwdt1 - dwdt2]If you did everything correctly, the result should be `0.'
Essentially the same procedures work for the multi-variate version of the Chain Rule. Try finding and where r and are polar coordinates, that is and . First, take derivatives after direct substitution for ,
wrtheta = f[ r Cos[theta], r Sin[theta] ]Then try using the Chain Rule directly,
and then substituting, which in Mathematica can be accomplished using the substitution
/.{x -> r Cos[theta], y -> r Sin[theta]}
Try a couple of homework problems. In particular, you may want to give some of the implicit differentiation problems a whirl.