Contour Plots and Critical Points

Load the plotting package:

<< Graphics`

Part 1. Exploration of a Sample Surface

Enter the definition of the function f.

f[x_, y_] = 
      Cos[x - y] (1 - x^2 + y) Exp[x y^2 /(1 + x^2 y^2)]

ContourPlot[f[x, y], {x, -3, 3}, {y, -5, 5}, Contours -> 15, 
      PlotPoints -> 25]

Use the following commands to zoom in on smaller portions of the contour plot.  The plotted rectangle is [a,b] x [c,d].  Change the values of a, b, c, and d to get the rectangles of your choice.

\(a = 0; \ b = 1; \ c = 0; \ d = 1; 

    ContourPlot[f[x, y], {x, a, b}, {y, c, d}]\)

Enter your answers for Steps 2-4 here.

The following commands define the partial derivatives (Subscript[f, x]) and (Subscript[f, y]) as functions.

fx = Derivative[1, 0][f];  fx[x, y]fy = Derivative[0, 1][f];  fy[x, y]

Answer Steps 5 and 6 here.

Part 2. First- and Second-Degree Taylor Approximations

Define the second partial derivatives.  (We use semicolons here, so that we do not waste time and space displaying the long formulas.)

\(fxx = \(Derivative[2, 0]\)[f]; 
fxy = \(Derivative[1, 1]\)[f]; 

    fyy = \(Derivative[0, 2]\)[f]; \)

Enter a point ((Subscript[x, 0]), (Subscript[y, 0])) with -3 < (Subscript[x, 0]) < 3 and -5 < (Subscript[y, 0]) < 5.

\(x0 = \(?? ;

        y0 = \(?? ;\)\)\)

Finish the following expression for the first-degree Taylor approximation to f at ((Subscript[x, 0]), (Subscript[y, 0])).

L[x_, y_] := 
      f[x0, y0] + fx[x0, y0] (x - x0) + fy[x0, y0] (y - y0); 
    L[x, y]

Compare the contour plots of f and L near ((Subscript[x, 0]), (Subscript[y, 0])). (Here f is in red and L is in blue.)

\(delta = 0.5; 

    plot1 = ContourPlot[
        f[x, y], {x, x0 - delta, x0 + delta}, {y, y0 - delta, y0 + delta}, 
        ContourShading -> False, DisplayFunction -> Identity, 
        ContourStyle -> RGBColor[1, 0, 0]]; 

    plot2 = ContourPlot[
        L[x, y], {x, x0 - delta, x0 + delta}, {y, y0 - delta, y0 + delta}, 
        ContourShading -> False, DisplayFunction -> Identity, 
        ContourStyle -> RGBColor[0, 0, 1]]; 

    Show[plot1, plot2, DisplayFunction -> $DisplayFunction]\)

Extend L to the quadratic approximation Q at ((Subscript[x, 0]), (Subscript[y, 0])).

Q[x_, y_] := 
      L[x, y] + 
        (1/2) 
          (fxx[x0, y0] (((x - x0))^2) + 
              2 fxy[x0, y0] (x - x0) (y - y0) + 
              fyy[x0, y0] (((y - y0))^2));  Q[x, y]

Make a contour plot of the quadratic approximation.

plot3 = 
      ContourPlot[
        Q[x, y], {x, x0 - delta, x0 + delta}, {y, y0 - delta, y0 + delta}, 
        ContourShading -> False, ContourStyle -> RGBColor[0, 1, 0]];

Show all three contour plots together.

Show[plot1, plot2, plot3, DisplayFunction -> $DisplayFunction]

Finish answering the questions in Part 2 here.

Part 3: Locating the Critical Points

Your functions f, (Subscript[f, x]), (Subscript[f, y]), (Subscript[f, xx]), (Subscript[f, yy]), L,  and Q are all defined as functions, using values of the derivatives at ((Subscript[x, 0]), (Subscript[y, 0])) as coefficients in the definitions of L and Q.  Thus, when you change the values of (Subscript[x, 0]) and (Subscript[y, 0]), all of the function definitions get updated automatically.

Choose one of your approximate critical values, and enter its coordinates as (Subscript[x, 1]) and (Subscript[y, 1]).  The reason for this choice of names will appear very soon.  In particular, the next thing that happens is that these values get assigned to (Subscript[x, 0]) and (Subscript[y, 0]).

\(x1 = \(?? ;

        y1 = \(?? ;\)\)\)

(*) This step is where you return when you start each new iteration.  Transfer the values of (Subscript[x, 1]) and (Subscript[y, 1]) to (Subscript[x, 0]) and (Subscript[y, 0]).

x0 = x1y0 = y1

Solve for the critical point of Q.

solns = NSolve[{D[Q[x, y], x] == 0, D[Q[x, y], y] == 0}, {x, y}]

x1 = x /. solns[[1]]y1 = y /. solns[[1]]

Check the function value and the values of the two partial derivatives for the new point.

f[x1, y1]fx[x1, y1]fy[x1, y1]

Plot the contours of f (red) and Q (blue) near ((Subscript[x, 0]), (Subscript[y, 0])).

\(\(delta = 0.1; 

    plot4 = ContourPlot[
        f[x, y], {x, x0 - delta, x0 + delta}, {y, y0 - delta, y0 + delta}, 
        ContourShading -> False, DisplayFunction -> Identity, 
        ContourStyle -> RGBColor[1, 0, 0]]; 

    plot5 = ContourPlot[
        Q[x, y], {x, x0 - delta, x0 + delta}, {y, y0 - delta, y0 + delta}, 
        ContourShading -> False, DisplayFunction -> Identity, 
        ContourStyle -> RGBColor[0, 0, 1]]; 

    Show[plot4, plot5, DisplayFunction -> $DisplayFunction]
\)\)

Go back to (*), and iterate these steps until you are sure you have the coordinates of the critical pont correct to five significant digits.

Check to see what sort of critical point you have.

fxx[x1, y1]fxx[x1, y1] fyy[x1, y1] - fxy[x1, y1]^2

Part 4: Summary

Answer the summary questions here.