L3-DerivativeApps.mws

Calculus IV with Maple
Copyright 2002, Dr. Jack Wagner
j.wagner@intelligentsearch.com


Lesson 3:
Applications of Vector Derivatives: Multivariate extrema, Newton's method and Taylor series

Topics : The ideas and methods of of  the calculus of a single variable are extended to the problem of maxima and minima of a function of two variables. Degenerate critical points.  Taylor series for functions of more than one variable including truncation error estimate  Newton's method with multiple variables.  


Maple commands introduced:
Eigenvalues, Hessian, mtaylor, sphere, coeftayl

Maxima, Minima and Saddle Points

            Given F : R^3  -> R  on an open set, U.   We define the set of critical points, {X}, of   F ,  by   {x|grad F (x) = 0   } for all x in X.   A point, x[0] , is a local maximum (minimum) for F  if there exists a neighborhood, V of x[0]  , such that for every x in V , F(x) <= F(x[0]) .  If, at a point, x[0] ,   F(x) attains a local maximum  (minimum), we know from the calculus of a single variable that   Diff(F,x[k]) ( x[0] ) = 0 for every k; i.e  grad F ( x[0] ) = 0 . Consequently, every extreme point of F lies in {X} although there may be points in {X} that are not extreme points.  The hypothesis that U  be open is critical since otherwise a maximum (minimum) point might lie at an endpoint of U .

Example  3.1


Find the local maxima and minima of the function:

  z = cos(x+y)+x^2   |    x = -1..1,  y =   -3*Pi/2  .. -3*Pi/2

>    restart: with(plots):with(VectorCalculus):with(LinearAlgebra):

>    F :=  (x, y) -> cos(x + y) + x^2:

>    plot3d([x, y, F(x, y)], x = -1..1, y =
-1.5 * Pi..1.5 * Pi, axes = framed, color = blue, style = wireframe, labels = [x, y, z]);

[Maple Plot]

At a local maximum (minimum)   D[v]*F(x[0])  = 0   for every v. From the plot, however, it is apparent that there are points where   D[v]*F(x[0])   = 0, but which are neither local maxima nor minima because F increases in some directions but decreases in others. Such a point is called a saddle point.

>    dF[x] :=  diff(F(x, y), x);
                      
dF[y] :=  diff(F(x, y), y);
                        

dF[x] := -sin(x+y)+2*x

dF[y] := -sin(x+y)

By inspecting the plot we select appropriate ranges in which to look for solutions.

>    fsolve({dF[x], dF[y]}, {x = -1..1, y = -1/2 * Pi..1/2 * Pi});

{x = 0., y = 0.}

>    fsolve({dF[x], dF[y]}, {x = -1..1, y = -3/2 * Pi..-1/2 * Pi});

{x = 0., y = -3.141592654}

>    fsolve({dF[x], dF[y]}, {x = -1..1, y = 1/2 * Pi..3/2 * Pi});

{x = 0., y = 3.141592654}

These points could be visualized with pointplot3d, but they would be lost in the plot of F. In order to visualize them together with F, we need to see them as small spheres.  In the plottools package there is a sphere function.

sphere

>    with(plottools):
p1 :=  sphere([0, 0, F(0, 0)], .07):
p2 :=  sphere([0, -Pi, F(0, -Pi)], .07):
p3 :=  sphere([0, Pi, F(0, Pi)], .07):

>    P1 :=  plot3d([x, y, F(x, y)], x = -1..1, y =
-1.5 * Pi..1.5 * Pi, axes = framed, color = blue, style = wireframe, labels = [x, y, z]):

>    display(p1, p2, p3, P1);

[Maple Plot]

The spheres are seen as ellipsoidal because the scaling is not "constrained".

Now we need a criterion for determining whether a point is a local minimum, maximum or saddle point.  We are going to look for a generalization of what we already know from the calculus of a single variable; i.e. that the second derivative is negative (positive) at a relative maximum (minimum).  Since, at a critical point, Diff(F,x[k]) = 0 ,  for every v = { v[1] , v[2] , v[3] , ... v[n] }, D[v]*F = Sum(v[k]*Diff(F,x[k]),k = 1 .. n)  = 0 .   This alternative criterion for a critical point extends naturally to criteria for determining whether a critical point is a local maximum a local minimum or a saddle point.   We look at D[v]*D[v]*F  ; that is, the derivative in every direction of the first derivatives.  Since every vector can be represented in a basis consisting of the coordinate vectors, it suffices to consider

  D[v]*Sum(v[k]*Diff(F,x[k]),k = 1 .. n)  = Sum(Sum(v[j]*v[k]*Diff(Diff(F,x[k]),x[j]),j = 1 .. n),k = 1 .. n)

In matrix form this looks like:

  matrix([[v[1], %?, %?, v[n]]]) matrix([[Diff(F,x[1],x[1]), %?, %?, Diff(F,x[1],x[n])], [%?, %?, %?, %?], [%?, %?, %?, %?], [Diff(F,x[n],x[1]), %?, %?, Diff(F,x[n],x[n])]])   matrix([[v[1]], [%?], [%?], [v[n]]])

Notice that, when dealing with matrices, it is necessary to distinguish between horizontal and vertical vectors.  The matrix,

   matrix([[Diff(F,x[1],x[1]), %?, %?, Diff(F,x[1],x[n])], [%?, %?, %?, %?], [%?, %?, %?, %?], [Diff(F,x[n],x[1]), %?, %?, Diff(F,x[n],x[n])]])   

is known as the Hessian,   H[f] .

Evaluated at a point x, it is written H[f(x)] . The Hessian is found with the Maple functions, hessian and Hessian.

Hessian

hessian

>    h[f] :=  Hessian(F(x, y), [x, y]);

h[f] := Matrix(%id = 14878544)

We need a functional form.

>    H[f] :=  X -> subs({x = X[1], y = X[2]}, h[f]);

H[f] := proc (X) options operator, arrow; subs({x = X[1], y = X[2]},h[f]) end proc

The criteria we are looking for is this.  When, at a critical point, the second derivative is negative (positive) in every direction, then that point is a local maximum (minimum).  In other words we need to determine whether, in some sense, the Hessian is positive or negative.  What does it mean for the Hessian matrix to be negative (positive)?  The correct interpretation of this statement is that  for  any vector  v, v^T*H[f(x)]*v < 0  , (>0)     . It suffices to consider only unit vectors, u,  because, if the statement is true for a normalized vector, it will be true of the original vector. We are led therefore, to consider the following problem.  For which x will   H[f(x)]     be such that   Max{ u^T*H[f(x)]*u < 0 }, subject to the constraint that   u^T*u = 1 .
   
We apply the method of Lagrange multipliers, noting that H[f(x)]   is symmetric because of the equality of the mixed partial derivatives.

Diff(u^T,u) H[f(x)] u  = 2 u^T*H[f(x)]       Compute the derivative of the primary equation.

Diff(u^T*u,u) = 2*u^T                        Compute the derivative of the constraint.

u^T*H[f(x)]  = lambda*u^T                      Use the Lagrange multiplier principle.

     By taking transposes we obtain:   H[f(x)]*u^T  = lambda*u^T  

Lambda is thus an eigenvalue, and u  an eigenvector, of   H[f(x)] . Multiplying on the left by u^T : u^T*H[f(x)]*u  = lambda*u^T*u  = lambda   Because H[f(x)]   is symmetric, we are guaranteed that all its eigenvalues are real. We have found, therefore, that if the eigenvalues of   H[f(x)]   are all negative, x  is a local maximum, whereas if they are all positive, x  is a local minimum.  If  some are positive and others negative, then we are at a saddle point, where the value of F is increasing in some directions and decreasing in others.
Maple provides a number of functions in the linalg package for working with eigenvalues and eigenvectors.  We will require only one of these functions;
eigenvalues    or   Eigenvalues

Eigenvalues

eigenvalues

>    Eigenvalues(H[f]([0, Pi]), output = 'list');

[2+2^(1/2), 2-2^(1/2)]

>    Eigenvalues(H[f]([0, -Pi]), output = 'list');

[2+2^(1/2), 2-2^(1/2)]

>    Eigenvalues(H[f]([0, 0]), output = 'list');

[2^(1/2), -2^(1/2)]

      The two points, (0, Pi )  and (0, -Pi )   are relative minima and the point   (0, 0)   is a saddle point.
With the method now in hand we will try another example.

Example 3.2

F(x+y)   =   e^cos(x)+e^sin(x)

>    restart: with(plots):with(LinearAlgebra): with(VectorCalculus):

>    F :=  X -> exp(cos(X[1])) + exp(cos(X[2])):

>    plot3d([x, y, F([x, y])], x = -3/2 * Pi..3/2 * Pi, y = -1..1, axes = framed, color = blue, style = wireframe, labels = [x, y, z]);

[Maple Plot]

We need this plot in order to select appropriate ranges for the fsolve  function.         

>    dF[x] :=  diff(F([x, y]), x);

dF[x] := -sin(x)*exp(cos(x))

>    dF[y] :=  diff(F([x, y]), y);

dF[y] := -sin(y)*exp(cos(y))

>    fsolve({dF[x] = 0, dF[y] = 0}, {x, y});

{y = 0., x = 0.}

>    fsolve({dF[x] = 0, dF[y] = 0}, {x = 2..4, y = -1..1});

{y = 0., x = 3.141592654}

>    fsolve({dF[x] = 0, dF[y] = 0}, {x = -4..-2, y = -1..1});

{y = 0., x = -3.141592654}

>    with(plottools):

>    p1 :=  sphere([0, 0, F([0, 0])], .07):
p2 :=  sphere([3.141592654, 0, F([3.141592654, 0])], .07):
p3 :=  sphere([-3.141592654, 0, F([-3.141592654, 0])], .07):

>    P1 :=  plot3d([x, y, F([x, y])], x = -3/2 * Pi..3/2 * Pi, y = -1..1, axes = framed, color = blue, style = wireframe, labels = [x, y, z]):

>    display(p1, p2, p3, P1);

[Maple Plot]

This plot is not a necessity but it furnishes a satisfying visual confirmation that we are on target.

>    h[f] :=  Hessian(F([x, y]), [x, y]);
H[f] :=  X -> subs({x = X[1], y = X[2]}, h[f]):

h[f] := Matrix(%id = 15119324)

>    Eigenvalues(H[f]([0, Pi]), 'output' = list);

[1/2*exp(-1)-1/2*exp(1)+1/2*(exp(-1)^2+2*exp(-1)*exp(1)+exp(1)^2)^(1/2), 1/2*exp(-1)-1/2*exp(1)-1/2*(exp(-1)^2+2*exp(-1)*exp(1)+exp(1)^2)^(1/2)]

>    radsimp(%);

[exp(-1), -exp(1)]

>    Eigenvalues(H[f]([0, 0]), 'output' = list);

[-exp(1), -exp(1)]

>    Eigenvalues(H[f]([0, -Pi]), 'output' = list);

[1/2*exp(-1)-1/2*exp(1)+1/2*(exp(-1)^2+2*exp(-1)*exp(1)+exp(1)^2)^(1/2), 1/2*exp(-1)-1/2*exp(1)-1/2*(exp(-1)^2+2*exp(-1)*exp(1)+exp(1)^2)^(1/2)]

>    radsimp(%);

[exp(-1), -exp(1)]

>    evalf(F([0, 0]));

5.436563656

>    evalf(F([0, Pi]));

3.086161269

>    evalf(F([0, -Pi]));

3.086161269

The points   (0, Pi , 3.086161269 )   and   (0, -Pi , 3.086161269 )   are saddle points and the point   (0, 0, 5.436563656)   is a local maximum.
What happens if the machinery doesn't work?  

Example  3.3


Here is a perfectly innocuous looking function.

F(x,y,z) = x^4-12*x^3+54*x^2-108*x+y^4-16*y^3+96*y^2-256*y-z^4+339

We will look for extreme values of F.  

>    restart: with(plots):with(LinearAlgebra): with(VectorCalculus):

To gain an idea of what we are working with we plot the surface   F(0)^(-1) .

>    F :=  x^4-12 * x^3 + 54 * x^2-108 * x + 339 + y^4-16 * y^3 + 96 * y^2-256 * y-z^4:

>    r :=  x = 0..10, y = 0..10, z = 0..10:

>    implicitplot3d(F, r, axes = boxed, grid=[25,25,25], lightmodel=light2, style = patchnogrid);

[Maple Plot]

>    dF[x] :=  diff(F, x);

dF[x] := 4*x^3-36*x^2+108*x-108

>    dF[y] :=  diff(F, y);

dF[y] := 4*y^3-48*y^2+192*y-256

>    dF[z] :=  diff(F, z);

dF[z] := -4*z^3

>    fsolve(dF[x], x);

3., 3., 3.

>    fsolve(dF[y], y);

4., 4., 4.

>    fsolve(dF[z], z);

0., 0., 0.

>    h :=  Hessian(F, [x, y, z]);

h := Matrix(%id = 14656604)

>    H :=  subs({x = 3, y = 4, z = 0}, h);

H := Matrix(%id = 13516828)

If the determinant of the Hessian is zero at a critical point, then that point is a degenerate critical point.  How to handle this situation in all generality is not a simple question.  It requires the use of higher order partial derivatives.  A fuller (but  not complete) explanation will appear in the section on Taylor polynomials.  The present case is not  too difficult because the Hessian is a diagonal matrix whose entries are polynomials in a single variable.  Taking third derivatives we have:

matrix([[24*x, %?, %?], [%?, 24*y-192, %?], [%?, %?, -36*z^2]])

This is still the zero matrix at (3, 4, 0).  Repeating the process

matrix([[24, %?, %?], [%?, 24, %?], [%?, %?, -72*z]])

This matrix has eigenvalues  24, 24, 0, suggesting that  the point (3, 4, 0) is a local minimum. This is easily confirmed by trying  values of the variables in a  neighborhood of (3, 4, 0).

>    f :=  unapply(F, [x, y, z]);

f := proc (x, y, z) options operator, arrow; x^4-12*x^3+54*x^2-108*x+339+y^4-16*y^3+96*y^2-256*y-z^4 end proc

>    for k from 1 to 20 do v.k :=  f(2 + .1 * k, 3 + .1 * k, -1 + .1 * k) od:

>    S :=  [seq([n, v.n], n = 1..20)]:

>    pointplot(S, connect = true, labels = ["k", "F"], title = "Variation of F(x, y, z) in a neighborhood of (3, 4, 0).");

[Maple Plot]

This plot clearly shows that F is a minimum when k = 10, i.e. at the point [3, 4, 0].    

Newton's Method

Recall from the calculus of a single variable the recursion formula for Newton's method.   x[n+1] = x[n] -f(x[n])/Diff(f,x)(x[n])  . We would like to have something similar for the multivariate problem.  We seek a solution to the equation   f ( x ) = 0, where         x  = ( x[1], x[2], x[3] , ... x[n] ). Let   x   be the exact solution and x[0]   be the initial approximation.  Then,  

x   -x[0] = Delta x

0 = f ( x ) = f ( x[0]  + Delta x) ~   f ( x[0] ) + Df ( x[0] )( x - x[0] )

         Keep in mind that   Df ( x[0] )   is the Jacobian matrix evaluated at x[0] . Our next approximation to   x ,  say   x[1]   will be found by solving    f ( x[0] ) + Df ( x[0] )( x[1] - x[0] )  = 0, thereby obtaining   x[1] = x[0] -D*f(x[0])^(-1)  * f ( x[0] );  a result completely analogous to the single variable case.  

To implement this we need an approximation to the solution.  This can be a far from trivial problem.

 

Example  3.6   

Solve:     4*x^2-y+cos(x+y)-4 = 0   

              y^2-3*x^2+ln(x+y)-3 = 0

For systems having only two variables, Maple makes it easy.

>    restart: with(plots):with(LinearAlgebra):with(VectorCalculus):

>    g1 :=  4 * x^2-y + cos(x + y)-4:  g2 :=  y^2-3 * x^2 + log(x + y)-3:

>    implicitplot({g1, g2}, x = 0..4, y = 0..4);

[Maple Plot]

By pointing and clicking we find the graphical estimate (1.35, 2.69)

>    a :=  <1.35, 2.69>;

a := Vector(%id = 18852728)

Define a vector valued function.

>    F :=  X -> subs({x = X[1], y = X[2]}, <g1, g2>):
F(X);

Vector(%id = 2412156)

Now compute the Jacobian.

>    dF :=  Jacobian(<g1, g2>, [x, y]);

dF := Matrix(%id = 2715396)

Define another vector valued function that is the inverse of dF.

>    invdF := MatrixInverse(dF);

>   

invdF := Matrix(%id = 17274792)
invdF := Matrix(%id = 17274792)
invdF := Matrix(%id = 17274792)
invdF := Matrix(%id = 17274792)
invdF := Matrix(%id = 17274792)

>    invdF2 :=  X -> subs({x = X[1], y = X[2]}, invdF ):
invdF2(X);

Matrix(%id = 3268588)
Matrix(%id = 3268588)
Matrix(%id = 3268588)
Matrix(%id = 3268588)

The Newton recurrence relationship is simple.

>    Delta :=  <1.0|1.0>: while(Norm(Delta, 2)>10^(-7)) do
 Delta :=  invdF(a).F(a): a :=  a-Delta: od:  print(a);

Vector(%id = 17650284)

We check the answer.

>    print(evalf(F(a)));

Vector(%id = 19761740)

Beyond two unknowns, the problem of getting an initial estimate becomes more complex; there may not be a solution.  In the case of three variables a 3d plot may give a satisfactory estimate.

Example  3.4  

Solve the following system of equations.

x+sin(y)-5 = 0

y^2+ln(x)-10 = 0

x-y-z+5 = 0

>    restart: with(plots):with(LinearAlgebra): with(VectorCalculus):

>    f1 :=  x + sin(y)-5:   f2 :=  y^2 + log(x)-10: f3 :=  x-y-z + 5:

>    p1 := implicitplot3d(f1, x = 0..8, y = 0..8, z=-5..10, color = red):
p2 := implicitplot3d(f2, x = 0..8, y = 0..8, z=-5..10, color = blue, axes = framed):
p3 := implicitplot3d(f3, x = 0..8, y = 0..8, z=-5..10, color = green, axes = framed):
display(p1,p2,p3, axes = framed, style=patchnogrid);

[Maple Plot]

The intersection of the three surfaces approximates the solution to the system of equations.. Call the estimated answer a .

>    a :=  <5.0, 2.5, 7.5>;

a := Vector(%id = 17581976)

With the method of the previous example in hand we make a few obvious changes for three dimensions.

>    F :=  X -> subs({x = X[1], y = X[2], z = X[3]}, <f1, f2, f3>):
F(X);

Vector(%id = 17582856)

>    dF :=  Jacobian(<f1, f2, f3>, [x, y, z]);

dF := Matrix(%id = 2840116)

>    invdF := MatrixInverse(dF);

invdF := Matrix(%id = 19294912)

>    invdF2 :=  X -> subs({x = X[1], y = X[2], z = X[3]}, invdF):
invdF2(X);

Matrix(%id = 19274608)

>    Delta :=  <1.0, 1.0, 1.0>: while(Norm(Delta, 2)>10^(-7)) do  a :=  evalf(a-invdF(a).F(a)): Delta :=  evalf(invdF(a).F(a)): od: print(a);  print(evalf(F(a)));

Vector(%id = 4345636)

Vector(%id = 4502848)

In addition to the answer, we have computed the value of F at that point as a check.

Taylor Series

The Taylor series and Taylor remainder formula for functions of a single variable generalize to the multivariate case.  Because we can only plot functions in three dimensions we will examine the case of two variables, but the same ideas and principles apply equally to higher dimensions.  We will denote differentiation with respect to x by   D[1]  and differentiation with respect to y by D[2] .  Higher order derivatives will be designated by D[1,2]*f = Diff(f,x,y)    etc. For two variables, x and y, expanded around x = a and y = b the Taylor formula reads,  

  f(x,y) = f(a,b)  + Sum(Sum(D[1]^k*D[2]^(n-k)*(x-a)^k*(y-b)^(n-k)/(k!*(n-k)!),k = 0 .. n),n = 1 .. p)  + R[p]

To  third degree  the Taylor series for a function of two variables is,

f(x,y) = f(a,b)+D[1]*f*(a, b)*(x-a)+D[2]*f*(a, b)*(y-b)+(D[1,1]*f*(a, b)*(x-a)^2+2*D[1,2]*f*(a, b)*(x-a)*(y-b)+D[2,2]*f*(a, b)*(y-b)^2)/2!  +

(D[1,1,1]*f*(a, b)*(x-a)^3+D[1,1,2]*f*(a, b)*(x-a)^2*(y-b)+D[1,2,2]*f*(a, b)*(x-a)*(y-b)^2+D[2,2,2]*f*(a, b)*(y-b)^3)/3!   +  R

R is the error introduced by truncating the series at this point.  
Maple provides the mtaylor function in the standard library (readlib).

mtaylor

Example 3.5

>    restart:

As an illustration, up to terms of the fourth degree, the series for sin(x + y) expanded around the point (1, -2) is:

>    f :=  sin(x + y):

>    `sin(x + y)`[4] :=  mtaylor(f, {x = 1, y = -2}, 5);

`sin(x+y)`[4] := -sin(1)+cos(1)*(x-1)+cos(1)*(y+2)+1/2*sin(1)*(x-1)^2+sin(1)*(y+2)*(x-1)+1/2*sin(1)*(y+2)^2-1/6*cos(1)*(x-1)^3-1/2*cos(1)*(y+2)*(x-1)^2-1/2*cos(1)*(y+2)^2*(x-1)-1/6*cos(1)*(y+2)^3-1/24*...
`sin(x+y)`[4] := -sin(1)+cos(1)*(x-1)+cos(1)*(y+2)+1/2*sin(1)*(x-1)^2+sin(1)*(y+2)*(x-1)+1/2*sin(1)*(y+2)^2-1/6*cos(1)*(x-1)^3-1/2*cos(1)*(y+2)*(x-1)^2-1/2*cos(1)*(y+2)^2*(x-1)-1/6*cos(1)*(y+2)^3-1/24*...
`sin(x+y)`[4] := -sin(1)+cos(1)*(x-1)+cos(1)*(y+2)+1/2*sin(1)*(x-1)^2+sin(1)*(y+2)*(x-1)+1/2*sin(1)*(y+2)^2-1/6*cos(1)*(x-1)^3-1/2*cos(1)*(y+2)*(x-1)^2-1/2*cos(1)*(y+2)^2*(x-1)-1/6*cos(1)*(y+2)^3-1/24*...

       When a function is expanded around a point, the expansion is likely to be most accurate near that point.  It is of interest to know how accurate.  That is, we need an upper bound for the truncation error, R. The upper bound for R in an expansion to fourth degree terms, can be estimated as follows.   If the function is expanded around  ( a, b ) and evaluated at a point  ( p[1], p[2] )  then let    h  = ( p[1], p[2] ) - ( a, b ),   h[1] = abs(p[1]-a)   , h[2] = abs(p[2]-b)   .  Let M be the maximum value of all the mixed fifth order derivatives of sin(x + y) evaluated on the interval ( p[1]-h[1], p[2]-h[2] )..( p[1]+h[1], p[2]+h[2] )   Then the truncation error is bounded by M*(h[1]+h[2])^5   . We will illustrate the idea with the slightly simpler example of expansion around (0, 0).

Example 3.6

Compute the upper bound on the truncation error, after third degree terms, of the Taylor expansion for the function sin(x + y) expanded around (0, 0) and evaluated at (0.1, 0.05); approximately x = 5 degrees , y = 3 degrees.

>    restart: with(plots):

Warning, the name changecoords has been redefined

>    f :=  sin(x + y):

>    `sin(x + y)`[4] :=  mtaylor(f, {x, y}, 5);

`sin(x+y)`[4] := x+y-1/6*x^3-1/2*y*x^2-1/2*y^2*x-1/6*y^3

All the fourth degree coefficients are zero so we need to look at the fifth degree coefficients using the coeftayl function.

coeftayl

This is a tricky syntax.  Coeftayl must be informed by the use of an equation, the names of the variables (left side) and the points around which they are to be evaluated (right side).  Then you must insert, as a list, the powers to which each of the variables are to be raised in the term whose coefficient is being calculated.  In the present case, with two variables the fifth order term has the following possibilities for the powers of x and y; [5, 0], [4, 1], [3, 2], [2, 3], [1.4], [0, 5].  Because we want to see all the coefficients of fifth order terms we create a sequence using coeftayl. First we must call up coeftayl from the standard library.

>    C :=  [seq(coeftayl(f, [x, y] = [0, 0], [a, 5-a] ), a = 0..5)];
             

C := [1/120, 1/24, 1/12, 1/12, 1/24, 1/120]

The largest coefficients belong to the terms containing variables raised to the [3, 2] or [2, 3] powers.

>    for k from 3 to 4 do f||k :=  C[k] * x^(k-1) * y^(6-k)od;

f3 := 1/12*x^2*y^3

f4 := 1/12*x^3*y^2

The easiest way to look for the maximum of these terms on the interval ([0, 0], [0.1, 0.05]) is to plot them each in turn.

>    plot3d(f||3, x = 0..1, y = 0..1, axes = framed);

[Maple Plot]

>    plot3d(f||4, x = 0..1, y = 0..1, axes = framed);

[Maple Plot]

We rapidly determine that .08 is the maximum value attained by either of these terms on this interval.  Now put the pieces together.

>    R :=  .08 * (.1 + .05)^5;

R := .6075000e-5

This is the maximum error introduced by truncating the series at third order terms.  To check on the accuracy of the method we calculate.

>    s[1] :=  subs({x = .1, y = .05}, `sin(x + y)`[4]);

s[1] := .1494375000

>    s[2] :=  sin(.1 + .05);

s[2] := .1494381325

>    s[2]-s[1];

.6325e-6

The importance of the Taylor series is not limited to calculation.  It finds application  in theoretical considerations.

The second degree terms in the Taylor series are,

(D[1,1]*f*(a, b)*(x-a)^2+2*D[1,2]*f*(a, b)*(x-a)*(y-b)+D[2,2]*f*(a, b)*(y-b)^2)/2!

which can be rewritten as:

       1/2 [ x-a, y-b ] matrix([[D[1,1]*f*(a, b), D[1,2]*f*(a, b)], [D[2,1]*f*(a, b), D[2,2]*f*(a, b)]])   matrix([[x-a], [y-b]])   =   1/2 [ x-a, y-b ] H[f(a,b)] matrix([[x-a], [y-b]])

          By shifting the origin, f(a, b) can always be made zero. At a critical point, all the first derivatives are zero, so in a  neighborhood of a critical point the function is approximated by the terms containing second derivatives. If H[f(a,b)]  = 0, then the function will be approximated by terms containing third derivatives, etc. This is the reason why the nature of a critical point must sometimes be determined by higher derivatives.

Problems

1. For   f = cos(theta)^2*sin(theta)^2-phi*sin(theta)-theta*cos(phi)   find the critical points on the interval    theta = 0 .. 2*Pi, phi = 0 .. 2*Pi   and determine their nature.

2.   Solve the following systems of  equations.

        a. y = ln(x^2+y^2)

                         x^2+2*y^2 = 3

                     b.   z = ln(x+y)

                         (x-3)^2+(y-3)^2 = 3

                          z = x+y-3

                     c.   z = sin(x*y/3)

                         2*(x-2)^2+(y-2)^2 = 3

                          z = x/2+y-2

3.    Find the Taylor series for   ln(sin(x*y))   and find the maximum truncation error after terms of fourth degree over the range  x = {.5..1.5}, y = {.5..1.5}