Application Center - Maplesoft

App Preview:

Visualizing the multivariable chain rule

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

chainrule.mws

> restart;

Calculus and Analytic Geometry III, Kawski, Spring 1996

The chain rule:

1. Lifting a curve to the graph of a function:

2. In general, matrix multiplication

>

1111111111111111111111111111111111111111111111111111111111111111

1. Lifting a curve to the graph of a function:

The following example may help clarify the various derivatives involved.

Composing a function z=f(x,y) with a parameterixed curve (x,y)=(g(t),h(t))

yields a function z=F(t).

We use pure function notation.

One commonly uses x=t, which often leads to confusion. In the picture it

helps as we only have three axes to view!

> g:=t->t;

g := proc (t) options operator, arrow; t end proc

> h:=t->1-t^2;

h := proc (t) options operator, arrow; 1-t^2 end pr...

> r:=[g,h];

r := [g, h]

> f:=(x,y)->1+3/(1+x^2+y^2);

f := proc (x, y) options operator, arrow; 1+3/(1+x^...

> F:=t->f(g(t),h(t));

F := proc (t) options operator, arrow; f(g(t),h(t))...

The individual plots of the four functions:

> with(plots):

Warning, the name changecoords has been redefined

> plot(g,-2..2,labels=[t,x]);

[Maple Plot]

> plot(h,-2..2,labels=[t,y]);

[Maple Plot]

> plot3d(f,-2..2,-3..2,labels=[`t=x`,y,z],shading=Z);

[Maple Plot]

> plot(F,-2..2,labels=[t,z]);

[Maple Plot]

A natural way to look at all plots combined:

For better visibility we "drop" the xy-plane to a lower level.

> surf:=plot3d(f,-2..2,-3..2):

> drop:=plot3d(0,-2..2,-3..2,color=green,grid=[5,6]):

> base:=spacecurve([g,h,.01],-2..2,color=blue,thickness=2):

> lift:=spacecurve([g,h,F*1.01],-2..2,color=magenta,thickness=2):

> display({drop,surf,base,lift},axes=frame,labels=[`t=x`,y,z],

> orientation=[56,69],shading=Z);

[Maple Plot]

Go back to the last combination plot.

Change the style to WIREFRAME and rotate into the side views, and top view.

Make sure you understand what you see -- the same simple graphs as earlier!

>

Once more go back to same plot, change the style to PATCHCONTOUR and

look at the view from above -- where do the local maxima and minima of

z as a function of t occur -- describe the characteristic feature of these

locations in concise mathematical language -- this will be the base for the

class on Friday on Lagrange multipliers.

> display({drop,surf,base,lift},view=[-1..1,0..1.2,0..4],

> axes=frame,labels=[`t=x`,y,z],

> style=patchcontour,orientation=[-90,0],shading=Z);

[Maple Plot]

Briefly, the derivatives of all functions -- note that Df has to be evaluated

at g in DF = Df@g . Dg

> recall:=x=g(t),y=h(t),z=f(x,y),z=F(t);

recall := x = t, y = 1-t^2, z = 1+3/(1+x^2+y^2), z ...

> veloc:=[diff(g(t),t),diff(h(t),t)];

veloc := [1, -2*t]

> gradf:=[diff(f(x,y),x),diff(f(x,y),y)];

gradf := [-6/(1+x^2+y^2)^2*x, -6/(1+x^2+y^2)^2*y]

> gradft:=subs(x=g(t),y=h(t),gradf);

gradft := [-6/(1+t^2+(1-t^2)^2)^2*t, -6/(1+t^2+(1-t...

> oneway:=linalg[dotprod](gradft,veloc);

oneway := -6*t/(2-t^2+t^4)^2-12*(-1+t^2)/(2-t^2+t^4...

> otherway:=diff(F(t),t);

otherway := -3/(1+t^2+(1-t^2)^2)^2*(2*t-4*(1-t^2)*t...

> simplify(oneway-otherway);

-12*(t-conjugate(t)+conjugate(t)*t^2-t^3)/(2-t^2+t^...

The location of the extrema along the curve z=F(t) -- it is very easy to solve

the equation F ' (t) = 0. Make sure that you know where each number in

the sequel fits into the picture!

> critpts:=solve(oneway,t);

critpts := RootOf(2*conjugate(_Z)*_Z^2-2*conjugate(...

> for i from 1 to 3 do

> t||i:=critpts[i]:

> [x||i,y||i,z||i]=[g(t||i),h(t||i),F(t||i)];

> od;

t1 := RootOf(2*conjugate(_Z)*_Z^2-2*conjugate(_Z)+_...

[x1, y1, z1] = [RootOf(2*conjugate(_Z)*_Z^2-2*conju...
[x1, y1, z1] = [RootOf(2*conjugate(_Z)*_Z^2-2*conju...

t2 := RootOf(2*conjugate(_Z)*_Z^2-2*conjugate(_Z)+_...

[x2, y2, z2] = [RootOf(2*conjugate(_Z)*_Z^2-2*conju...
[x2, y2, z2] = [RootOf(2*conjugate(_Z)*_Z^2-2*conju...

t3 := RootOf(2*conjugate(_Z)*_Z^2-2*conjugate(_Z)+_...

[x3, y3, z3] = [RootOf(2*conjugate(_Z)*_Z^2-2*conju...
[x3, y3, z3] = [RootOf(2*conjugate(_Z)*_Z^2-2*conju...

>

2222222222222222222222222222222222222222222222222222222222222222

2. In general, matrix multiplication

In general, when composing functions of several variables, the total

derivatives are matrices of various dimensions. Practically speaking,

the chain-rule then boils down to matrix multiplication.

Note, that the sizes of the matrices are automatically of the right

sizes for multiplication.

>

Example: Consider a parameterized curve (u,v)=g(t), and a parameterized

surface (x,y,z)=f(u,v). Composing these two, we obtain a parameterized

curve in 3-space (x,y,z)=F(t)=f(g(t)).

In this case the various matrices have the following sizes:

> restart;

> with(linalg):

Warning, the protected names norm and trace have been redefined and unprotected

> Df:=jacobian([x(u,v),y(u,v),z(u,v)],[u,v]);

Df := matrix([[diff(x(u,v),u), diff(x(u,v),v)], [di...

> Dg:=jacobian([u(t),v(t)],[t]);

Dg := matrix([[diff(u(t),t)], [diff(v(t),t)]])

This is the velocity vector in the (u,v)-parameter plane.

> DfDg:=multiply(Df,Dg);

DfDg := matrix([[diff(x(u,v),u)*diff(u(t),t)+diff(x...

> DF:=jacobian([x(t),y(t),z(t)],[t]);

DF := matrix([[diff(x(t),t)], [diff(y(t),t)], [diff...

This is the velocity vector in 3space!

In this case the chain rule says: DF (t) = (Df)(g(t)) . (Dg)(t), or using functions

D(f@g) = (Df)@g . (Dg)

Writing out the components the rules look as follows:

> for i to 3 do DF[i,1]=DfDg[i,1] od;

diff(x(t),t) = diff(x(u,v),u)*diff(u(t),t)+diff(x(u...

diff(y(t),t) = diff(y(u,v),u)*diff(u(t),t)+diff(y(u...

diff(z(t),t) = diff(z(u,v),u)*diff(u(t),t)+diff(z(u...

Feel free to take a look what the matrices look like in other cases.

Simply edit the following statements, e.g. replace t -> (u,v) -> (x,y,z)

by t -> (u,v,w) -> (x,y,z) -> (theta, phi, rho).

To make it a better learning experience, FIRST predict what size matrices

you will get (and what the components will be). THEN execute the commands,

and compare!

> restart;

> with(linalg):

Warning, the protected names norm and trace have been redefined and unprotected

> Df:=jacobian([r(x,y,z),theta(x,y,z),z],[x,y,z]);

Df := matrix([[diff(r(x,y,z),x), diff(r(x,y,z),y), ...

> Dg:=jacobian([x(u,v,w),y(u,v,w),z(u,v,w)],[u,v,w]);

Dg := matrix([[diff(x(u,v,w),u), diff(x(u,v,w),v), ...

> DfDg:=multiply(Df,Dg);

DfDg := matrix([[diff(r(x,y,z),x)*diff(x(u,v,w),u)+...
DfDg := matrix([[diff(r(x,y,z),x)*diff(x(u,v,w),u)+...
DfDg := matrix([[diff(r(x,y,z),x)*diff(x(u,v,w),u)+...
DfDg := matrix([[diff(r(x,y,z),x)*diff(x(u,v,w),u)+...
DfDg := matrix([[diff(r(x,y,z),x)*diff(x(u,v,w),u)+...
DfDg := matrix([[diff(r(x,y,z),x)*diff(x(u,v,w),u)+...
DfDg := matrix([[diff(r(x,y,z),x)*diff(x(u,v,w),u)+...
DfDg := matrix([[diff(r(x,y,z),x)*diff(x(u,v,w),u)+...

> DF:=jacobian([r(u,v,w),theta(u,v,w),z(u,v,w)],[u,v,w]);

DF := matrix([[diff(r(u,v,w),u), diff(r(u,v,w),v), ...

The following is a fancy shorthand notation to print out all single

equations corresponding to the matrix chain-rule for this case:

> for alpha in indices(DF) do DF[op(alpha)]=DfDg[op(alpha)] od;

diff(z(u,v,w),v) = diff(z(u,v,w),v)

diff(r(u,v,w),w) = diff(r(x,y,z),x)*diff(x(u,v,w),w...

diff(r(u,v,w),v) = diff(r(x,y,z),x)*diff(x(u,v,w),v...

diff(z(u,v,w),w) = diff(z(u,v,w),w)

diff(theta(u,v,w),v) = diff(theta(x,y,z),x)*diff(x(...

diff(theta(u,v,w),w) = diff(theta(x,y,z),x)*diff(x(...

diff(z(u,v,w),u) = diff(z(u,v,w),u)

diff(r(u,v,w),u) = diff(r(x,y,z),x)*diff(x(u,v,w),u...

diff(theta(u,v,w),u) = diff(theta(x,y,z),x)*diff(x(...

>

>

>