(* problem numbers are correct now *)           - Tami     7.Oct.08

Problem 7 (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = x^3 + y^3 - 6*y^2 - 3*x + 9;
ContourPlot[f[x, y], {x, -2, 2}, {y, -1, 5}, 
        ContourShading -> False, Contours -> 25];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        D[f[x, y], x], \*""   \!\(f\_xx\) = "", 
        fxx, \*""   \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        D[f[x, y], y], \*""   \!\(f\_yy\) = "", 
        fyy, \ \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, -2, 2}, {y, -1, 5}, 
        AxesLabel -> {"x", "y", None}];

Problem 19 (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = x^3 + E^(-y^2);
ContourPlot[f[x, y], {x, -0.5, 0.5}, {y, -0.5, 0.5}, 
        ContourShading -> False, Contours -> 40];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        D[f[x, y], x], \*""   \!\(f\_xx\) = "", 
        fxx, \*""   \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        D[f[x, y], y], \*""   \!\(f\_yy\) = "", 
        fyy, \ \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, -0.5, 0.5}, {y, -0.5, 0.5}, 
        AxesLabel -> {"x", "y", None}];

Problem 8 (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = (x + y)*(x*y + 1);
ContourPlot[f[x, y], {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
        ContourShading -> False, Contours -> 25];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        Factor[D[f[x, y], x]], \*""   \!\(f\_xx\) = "", 
        fxx, \*""   \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        Factor[D[f[x, y], y]], \*""   \!\(f\_yy\) = "", 
        fyy, \ \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
        AxesLabel -> {"x", "y", None}];

Problem 15 (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = Sin[x]*Sin[y];
ContourPlot[f[x, y], {x, -1, 2}, {y, -1, 2}, 
        ContourShading -> False, Contours -> 25];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        D[f[x, y], x], \*""   \!\(f\_xx\) = "", 
        fxx, \*""   \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        D[f[x, y], y], \*""   \!\(f\_yy\) = "", 
        fyy, \ \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, -1, 2}, {y, -1, 2}, 
        AxesLabel -> {"x", "y", None}];

Problem 21 (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = E^x*(1 - Cos[y]);
ContourPlot[f[x, y], {x, 0, 5*Pi}, {y, -7, 7}, 
        ContourShading -> False, Contours -> 10];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        Factor[D[f[x, y], x]], \*""   \!\(f\_xx\) = "", 
        fxx, \*""   \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        Factor[D[f[x, y], y]], \*""   \!\(f\_yy\) = "", 
        fyy, \ \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, 0, 5}, {y, -7, 7}, 
        AxesLabel -> {"x", "y", None}, AspectRatio -> 1, 
        PlotPoints -> 50, PlotRange -> {0, 300}, 
        ViewPoint -> {100, 100, 50}];

Problem 28 (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = (x^2 - y)*(x^2 + y);
ContourPlot[f[x, y], {x, -1, 1}, {y, -1, 1}, 
        ContourShading -> False, Contours -> 15];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        Factor[D[f[x, y], x]], \*""   \!\(f\_xx\) = "", 
        fxx, \*""   \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        Factor[D[f[x, y], y]], \*""   \!\(f\_yy\) = "", 
        fyy, \ \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1}, 
        AxesLabel -> {"x", "y", None}, AspectRatio -> 1, 
        PlotPoints -> 50, 
        ViewPoint -> {100, 100, 50}];

++++++++++++++++++++++++++++++++++++++++++++++++++

Other examples
(including those from class)

Problem ? (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = x^3 - 3*x + y^3 - 3*y;
ContourPlot[f[x, y], {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
        ContourShading -> False, Contours -> 25];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        D[f[x, y], x], \*""   \!\(f\_xx\) = "", 
        fxx, \*""   \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        D[f[x, y], y], \*""   \!\(f\_yy\) = "", 
        fyy, \ \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, -1.5, 1.5}, {y, -1.5, 1.5}, 
        AxesLabel -> {"x", "y", None}];

Problem ? (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = 8*x*y - 1/4*(x + y)^4;
ContourPlot[f[x, y], {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
        ContourShading -> False, Contours -> 25];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        D[f[x, y], x], \*""  \!\(f\_xx\) = "", 
        fxx, \*""  \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        D[f[x, y], y], \*""  \!\(f\_yy\) = "", 
        fyy, \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, -1.5, 1.5}, {y, -1.5, 1.5}, 
        AxesLabel -> {"x", "y", None}];

Problem ? (section 15.1)

Clear[f, x, y, fxx, fyy, fxy, disc];
f[x_, y_] = 400 - 3*x^2 - 4*x + 2*x*y - 5*y^2 + 48*y;
ContourPlot[f[x, y], {x, -7, 7}, {y, -7, 7}, 
        ContourShading -> False, Contours -> 25];
fxx = D[D[f[x, y], x], x];
fyy = D[D[f[x, y], y], y];
fxy = D[D[f[x, y], x], y];
disc[x_, y_] = fxx*fyy - fxy^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        D[f[x, y], x], \*""  \!\(f\_xx\) = "", 
        fxx, \*""  \!\(f\_xy\) = "", fxy];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        D[f[x, y], y], \*""  \!\(f\_yy\) = "", 
        fyy, \*""  \!\(f\_yx\) = "", fxy];\)\)
Print["Discriminant = ",  disc[x, y]];
Plot3D[f[x, y], {x, -7, 7}, {y, -7, 7}, 
        AxesLabel -> {"x", "y", None}];

USE THE REMAINING CELLS TO CHECK YOUR ANSWER TO QUESTION 23.
You need to enter your values for "A", "B", and "C" as "a", "b", and "c" below.

Clear[f, x, y, fx, fy, fxx, fyy, fxy, disc, a, b, 
        c];
a = 1;   
b = 1;   
c = 1;   
f[x_, y_] = 
        a - (x^2 + b*x + y^2 + c*y);
fx[x_, y_] = D[f[x, y], x];
fy[x_, y_] = D[f[x, y], y];
fxx[x_, y_] = D[D[f[x, y], x], x];
fyy[x_, y_] = D[D[f[x, y], y], y];
fxy[x_, y_] = D[D[f[x, y], x], y];
disc[x_, y_] = 
        fxx[x, y]*fyy[x, y] - fxy[x, y]^2;
Print["f(x,y) = ", f[x, y]];
\(\(Print[\*""\!\(f\_x\) = "", 
        D[f[x, y], x], \*""  \!\(f\_xx\) = "", 
        fxx[x, y], \*""  \!\(f\_xy\) = "", fxy[x, y]];\)\)
\(\(Print[\*""\!\(f\_y\) = "", 
        D[f[x, y], y], \*""  \!\(f\_yy\) = "", 
        fyy[x, y], \*""  \!\(f\_yx\) = "", fxy[x, y]];\)\)
Print["Discriminant = ",  
        disc[x, y]];
Clear[temp];
temp = FindMinimum[-1*f[x, y], {x, -1}, {y, 0}];
Print["The local maximum of f[x,y] is ", -1*
          temp[[1]]];
Print["    and it occurs when ", temp[[2]]];

If[f[-2, 1] == 15, Print["GOOD: f(-2,1)=15"], 
        Print["NO: f(-2,1) is not 15"]];
\(\(If[fx[\(-2\), 1] == 0, 
        Print[\*""GOOD: \!\(f\_x\)=0 at (-2,1)""], 
        Print[\*""NO: \!\(f\_x\) is not zero at (-2,1)""]];\)\)
\(\(If[fy[\(-2\), 1] == 0, 
        Print[\*""GOOD: \!\(f\_y\)=0 at (-2,1)""], 
        Print[\*""NO: \!\(f\_y\) is not zero at (-2,1)""]];\)\)
If[disc[-2, 1] > 0, 
        Print["GOOD: The dicriminant is positive at (-2,1)"],   ];
If[disc[-2, 1] < 0, 
        Print["BAD: The discriminant is negative at (-2,1)"],   ];
\(\(\(If[disc[\(-2\), 1] > 0, 
        If[fxx[\(-2\), 1] < 0, 
          Print[\*""GOOD: (Subscript[f, xx])<0""], \ \ ], \ \ ];\)\(
\)
    \)\)

ContourPlot[f[x, y], {x, -4, 0}, {y, -1, 3}, 
        ContourShading -> False, Contours -> 25];
Plot3D[f[x, y], {x, -4, 0}, {y, -1, 3}, 
        AxesLabel -> {"x", "y", None}];