(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 16602, 575] NotebookOptionsPosition[ 14190, 503] NotebookOutlinePosition[ 14556, 519] CellTagsIndexPosition[ 14513, 516] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell["Extreme Values and Saddle Points", "Title"], Cell["", "Subsubtitle", CellChangeTimes->{{3.45536418275*^9, 3.45536418346875*^9}}], Cell["Stuff you should know", "Subsubsection"], Cell[TextData[{ "Recall:\n1.) f(a,b) is a ", StyleBox["local maximum ", FontWeight->"Bold"], "value of f if f(a,b) >= f(x,y) for all ", StyleBox["domain", FontSlant->"Italic"], " points (x,y) in an open disk centered at (a,b).\n2", ".) f(a,b) is a ", StyleBox["local minimum ", FontWeight->"Bold"], "value of f if f(a,b) <= f(x,y) for all ", StyleBox["domain", FontSlant->"Italic"], " points (x,y) in an open disk centered at (a,b).", "\n3.) An interior point of the domain of a function where f_x and f_y are \ both zero ( \[Del]f=0 ), or where one or both of f_x and f_y do not exist is \ called a ", StyleBox["critical point", FontWeight->"Bold"] }], "Text"], Cell["Example: Finding Local Extrema", "Subsubsection"], Cell["\<\ Consider the function below, on the domain 0 \[LessEqual] x \[LessEqual] 2 , \ -1 \[LessEqual] y \[LessEqual] 1\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{ RowBox[{"6", "x"}], "-", RowBox[{"2", RowBox[{"x", "^", "2"}]}], "-", RowBox[{"3", "x", "*", RowBox[{"y", "^", "3"}]}], "+", RowBox[{ RowBox[{"x", "^", "2"}], RowBox[{"y", "^", "3"}]}], "+", RowBox[{"4.5", "*", "x", "*", RowBox[{"y", "^", "4"}]}], "-", RowBox[{"1.5", "*", RowBox[{"x", "^", "2"}], "*", RowBox[{"y", "^", "4"}]}], "+", RowBox[{"12", "x", "*", RowBox[{"Sin", "[", RowBox[{"Pi", "*", "y"}], "]"}]}], "-", RowBox[{"4", RowBox[{"x", "^", "2"}], "*", RowBox[{"Sin", "[", RowBox[{"Pi", "*", "y"}], "]"}]}], "+", RowBox[{"4", "x", "*", "y"}]}]}]], "Input"], Cell[TextData[{ "Our task is to find the ", StyleBox["local extrema ", FontWeight->"Bold"], "of this function, that is, find and classify all interior critical points \ on the domain" }], "Text"], Cell["Let's make a plot!", "Text"], Cell[BoxData[{ RowBox[{"p", "=", RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}], ",", RowBox[{"PlotPoints", "\[Rule]", "30"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]}], "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"p", ",", RowBox[{"ViewPoint", "\[Rule]", RowBox[{"{", RowBox[{"2", ",", RowBox[{"-", "0.6"}], ",", "0.5"}], "}"}]}]}], "]"}]}], "Input"], Cell["Lets also make a contour plot", "Text"], Cell[BoxData[{ RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"Contours", "\[Rule]", "30"}], ",", RowBox[{"PlotPoints", "\[Rule]", "75"}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}], "\[IndentingNewLine]", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"Contours", "\[Rule]", "100"}], ",", RowBox[{"PlotPoints", "\[Rule]", "100"}], ",", RowBox[{"ContourLines", "\[Rule]", "False"}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]}], "Input"], Cell["\<\ We have critical points where \[Del] f = 0, so lets make a function for the \ gradient...\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"gradf", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{"{", RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", "x"}], "]"}], " ", ",", " ", RowBox[{"D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", "y"}], "]"}]}], "}"}]}]], "Input"], Cell["\<\ ...but the command Solve[] will not work...(try it if you don't believe me)\ \>", "Text"], Cell["\<\ So, lets try something different. We are going to use FindRoot[ ] but, it \ needs an initial guess near the critical point. Lets make plots in the x-y \ plane where df/dx=0, and where df/dy=0. Where these curves intersect, we \ have critical points!\ \>", "Text"], Cell[BoxData[ RowBox[{"p1", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"gradf", "[", RowBox[{"x", ",", "y"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], "\[Equal]", "0"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"ColorFunction", "\[Rule]", RowBox[{"Function", "[", RowBox[{"Hue", "[", "1", "]"}], "]"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.454520231921875*^9, 3.454520240390625*^9}, { 3.455364209921875*^9, 3.455364236234375*^9}, {3.4553643690625*^9, 3.45536440015625*^9}}], Cell[BoxData[ RowBox[{"p2", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"gradf", "[", RowBox[{"x", ",", "y"}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], "\[Equal]", "0"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.455364241546875*^9, 3.455364242359375*^9}, { 3.455364407015625*^9, 3.455364408109375*^9}}], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"p1", ",", "p2"}], "]"}]], "Input"], Cell["\<\ Looks like somewhere around ( 1.6 , 0.6 ) we have a critical points. We also \ could have guessed this from the contour plot! Since the blue and red lines don't intersect anywhere else in the domain, \ that is the only critical point!\ \>", "Text", CellChangeTimes->{{3.455364418015625*^9, 3.455364419109375*^9}}], Cell[BoxData[ RowBox[{"sol", "=", RowBox[{"FindRoot", "[", RowBox[{ RowBox[{ RowBox[{"gradf", "[", RowBox[{"x", ",", "y"}], "]"}], "\[Equal]", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ",", RowBox[{"{", RowBox[{"x", ",", "1.6"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", "0.6"}], "}"}]}], "]"}]}]], "Input"], Cell["\<\ We can use the command \"/.\" to assign the values found above to a handle.\ \>", "Text", CellChangeTimes->{{3.454520328109375*^9, 3.454520384140625*^9}, { 3.454520497875*^9, 3.45452050459375*^9}}], Cell[BoxData[{ RowBox[{"x1", "=", RowBox[{"x", "/.", RowBox[{"sol", "[", RowBox[{"[", "1", "]"}], "]"}]}]}], "\[IndentingNewLine]", RowBox[{"y1", "=", RowBox[{"y", "/.", RowBox[{"sol", "[", RowBox[{"[", "2", "]"}], "]"}]}]}]}], "Input"], Cell["Lets check what this is using the 2nd derivative test", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"fxx", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{"D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "2"}], "}"}]}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"fyy", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{"D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"y", ",", "2"}], "}"}]}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"fxy", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{"D", "[", RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", "x"}], "]"}], ",", "y"}], "]"}]}]}], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"M", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"fxx", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"fxy", "[", RowBox[{"x", ",", "y"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"fxy", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"fyy", "[", RowBox[{"x", ",", "y"}], "]"}]}], "}"}]}], "}"}]}]], "Input"], Cell[BoxData[ RowBox[{"%", "//", "MatrixForm"}]], "Input"], Cell[BoxData[ RowBox[{"fxx", "[", RowBox[{"x1", ",", "y1"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Det", "[", RowBox[{"M", "[", RowBox[{"x1", ",", "y1"}], "]"}], "]"}]], "Input"], Cell["\<\ fxx < 0 and Det[ M ] = fxx*fyy - fxy^2 > 0 --> We have a local max, the value \ of the function here is\ \>", "Text"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"x1", ",", "y1"}], "]"}]], "Input"], Cell["\<\ Let's plot f(x,y) around this critical point...it sure does look like a max! \ yay!\ \>", "Text"], Cell[BoxData[ RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"x1", "-", "0.2"}], ",", RowBox[{"x1", "+", "0.2"}]}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"y1", "-", "0.1"}], ",", RowBox[{"y1", "+", "0.1"}]}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]], "Input"], Cell["\<\ Example: Finding Global Extrema and the Boundary of the Domain\ \>", "Subsubsection"], Cell["\<\ Since our domain is a rectangle, we have 4 sides to consider. Any of the 4 \ sides could have the global max / global min.\ \>", "Text"], Cell["\<\ Consider first the 'right' side of the domain, where x=2. On this edge, our \ function f(x,y) is really only a function of ONE variable, g( y ) = f ( 2 , y \ )\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"g", "[", "y_", "]"}], "=", RowBox[{"f", "[", RowBox[{"2", ",", "y"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"g", "[", "y", "]"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}]}], "]"}]], "Input"], Cell["\<\ Looks like this function has a max and a min! Let's use calc I to find them\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"gy", "[", "y_", "]"}], "=", RowBox[{"D", "[", RowBox[{ RowBox[{"g", "[", "y", "]"}], ",", "y"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"sol", "=", RowBox[{"FindRoot", "[", RowBox[{ RowBox[{ RowBox[{"gy", "[", "y", "]"}], "\[Equal]", "0"}], ",", RowBox[{"{", RowBox[{"y", ",", "0.5"}], "}"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"y2", "=", RowBox[{"y", "/.", "sol"}]}]], "Input"], Cell[BoxData[ RowBox[{"x2", "=", "2"}]], "Input"], Cell[BoxData[ RowBox[{"sol", "=", RowBox[{"FindRoot", "[", RowBox[{ RowBox[{ RowBox[{"gy", "[", "y", "]"}], "\[Equal]", "0"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "0.5"}]}], "}"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"y3", "=", RowBox[{"y", "/.", "sol"}]}]], "Input"], Cell[BoxData[ RowBox[{"x3", "=", "2"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"x2", ",", "y2"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"x3", ",", "y3"}], "]"}]], "Input"], Cell[CellGroupData[{ Cell["The point ( 0.609 , 2 )", "Section"], Cell["\<\ Lets look at the full 3D function around these two points. Be careful not to \ plot anything outside of the domain!\ \>", "Text"], Cell[BoxData[ RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"x2", "-", "0.2"}], ",", "x2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"y2", "-", "0.1"}], ",", RowBox[{"y2", "+", "0.1"}]}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["The point ( -0.55 , 2 )", "Section"], Cell[BoxData[ RowBox[{"p3", "=", RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"x3", "-", "0.3"}], ",", "x3"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"y3", "-", "0.1"}], ",", RowBox[{"y3", "+", "0.1"}]}], "}"}], ",", RowBox[{"AxesLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"p3", ",", RowBox[{"ViewPoint", "->", RowBox[{"{", RowBox[{"1.924", ",", " ", RowBox[{"-", "2.112"}], ",", " ", "0.726"}], "}"}]}]}], "]"}]], "Input"], Cell["\<\ You should examine the other three edges of the boundary!!! Determine all \ local and absolute max's and min's. Are there any saddles? Rotate the image \ to gain more insight.\ \>", "Text", CellChangeTimes->{{3.4545205539375*^9, 3.454520607515625*^9}}] }, Open ]] }, WindowSize->{1272, 877}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, ShowSelection->True, FrontEndVersion->"7.0 for Microsoft Windows (32-bit) (February 18, 2009)", StyleDefinitions->"DemoText.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[545, 20, 49, 0, 56, "Title"], Cell[597, 22, 84, 1, 56, "Subsubtitle"], Cell[684, 25, 46, 0, 44, "Subsubsection"], Cell[733, 27, 683, 20, 115, "Text"], Cell[1419, 49, 55, 0, 44, "Subsubsection"], Cell[1477, 51, 135, 3, 25, "Text"], Cell[1615, 56, 760, 25, 38, "Input"], Cell[2378, 83, 200, 6, 25, "Text"], Cell[2581, 91, 34, 0, 25, "Text"], Cell[2618, 93, 774, 22, 59, "Input"], Cell[3395, 117, 45, 0, 25, "Text"], Cell[3443, 119, 1071, 30, 59, "Input"], Cell[4517, 151, 114, 3, 25, "Text"], Cell[4634, 156, 396, 13, 38, "Input"], Cell[5033, 171, 99, 2, 25, "Text"], Cell[5135, 175, 276, 5, 43, "Text"], Cell[5414, 182, 706, 19, 38, "Input"], Cell[6123, 203, 535, 15, 38, "Input"], Cell[6661, 220, 82, 2, 38, "Input"], Cell[6746, 224, 325, 6, 55, "Text"], Cell[7074, 232, 373, 12, 38, "Input"], Cell[7450, 246, 210, 4, 25, "Text"], Cell[7663, 252, 263, 8, 59, "Input"], Cell[7929, 262, 69, 0, 25, "Text"], Cell[8001, 264, 809, 28, 79, "Input"], Cell[8813, 294, 500, 17, 38, "Input"], Cell[9316, 313, 59, 1, 38, "Input"], Cell[9378, 316, 81, 2, 38, "Input"], Cell[9462, 320, 110, 3, 38, "Input"], Cell[9575, 325, 127, 3, 25, "Text"], Cell[9705, 330, 79, 2, 38, "Input"], Cell[9787, 334, 107, 3, 25, "Text"], Cell[9897, 339, 524, 16, 38, "Input"], Cell[10424, 357, 96, 2, 44, "Subsubsection"], Cell[10523, 361, 147, 3, 25, "Text"], Cell[10673, 366, 184, 4, 25, "Text"], Cell[10860, 372, 130, 4, 38, "Input"], Cell[10993, 378, 189, 6, 38, "Input"], Cell[11185, 386, 100, 2, 25, "Text"], Cell[11288, 390, 161, 5, 38, "Input"], Cell[11452, 397, 227, 7, 38, "Input"], Cell[11682, 406, 76, 2, 38, "Input"], Cell[11761, 410, 50, 1, 38, "Input"], Cell[11814, 413, 249, 8, 38, "Input"], Cell[12066, 423, 76, 2, 38, "Input"], Cell[12145, 427, 50, 1, 38, "Input"], Cell[12198, 430, 79, 2, 38, "Input"], Cell[12280, 434, 79, 2, 38, "Input"], Cell[CellGroupData[{ Cell[12384, 440, 42, 0, 52, "Section"], Cell[12429, 442, 140, 3, 25, "Text"], Cell[12572, 447, 496, 15, 38, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[13105, 467, 42, 0, 52, "Section"], Cell[13150, 469, 534, 16, 38, "Input"], Cell[13687, 487, 219, 6, 38, "Input"], Cell[13909, 495, 265, 5, 25, "Text"] }, Open ]] } ] *) (* End of internal cache information *)