(* 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[ 14103, 405] NotebookOptionsPosition[ 12656, 359] NotebookOutlinePosition[ 13058, 376] CellTagsIndexPosition[ 13015, 373] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Lecture 11", "Section", CellChangeTimes->{{3.426947592244849*^9, 3.4269475961628494`*^9}, { 3.4315423019150314`*^9, 3.4315423352420316`*^9}, {3.4327427093176003`*^9, 3.4327427098915997`*^9}, {3.432826830388052*^9, 3.432826830967052*^9}, { 3.4333500665675044`*^9, 3.4333500670195045`*^9}, {3.4340534150565147`*^9, 3.4340534158645144`*^9}, {3.4345732876377974`*^9, 3.4345732888757973`*^9}, { 3.434897875502897*^9, 3.434897876013897*^9}, {3.435244640455*^9, 3.43524464071*^9}}], Cell["\<\ In this Lecture we discuss the issue of partial derivatives. Mathematica \ handles multiple independent variables quite easily. Consider the (Taylor \ series) expansion of Eq. (11.7) where we have\ \>", "Text", CellChangeTimes->{{3.4269476003598495`*^9, 3.4269476357228494`*^9}, 3.4315423175140314`*^9, {3.431542352626032*^9, 3.431542424331032*^9}, { 3.4327427140746*^9, 3.4327429812265997`*^9}, 3.4327511315046*^9, 3.4327511653416*^9, {3.432826858714052*^9, 3.432827111073052*^9}, { 3.432827229514052*^9, 3.4328272577850523`*^9}, {3.432827310610052*^9, 3.432827312426052*^9}, 3.432827345393052*^9, {3.4328274568730516`*^9, 3.432827466097052*^9}, {3.4328340733070517`*^9, 3.432834109282052*^9}, { 3.4333500834845047`*^9, 3.4333502558835044`*^9}, {3.4333503504285045`*^9, 3.4333503966995044`*^9}, {3.4333514295795045`*^9, 3.4333514323355045`*^9}, {3.4340534436005144`*^9, 3.434053562807514*^9}, { 3.4341070329600143`*^9, 3.434107035436014*^9}, {3.4345732986842976`*^9, 3.4345733013132973`*^9}, {3.4345734090392976`*^9, 3.4345734322927976`*^9}, {3.4345735243652973`*^9, 3.434573548324298*^9}, { 3.4345735826372976`*^9, 3.4345736734922976`*^9}, 3.434653478878298*^9, { 3.4348978938068967`*^9, 3.4348980800508966`*^9}, {3.43524493002*^9, 3.435244961439*^9}, {3.435244994219*^9, 3.4352450194449997`*^9}, { 3.4352450722475*^9, 3.435245135726*^9}, 3.4352472363545*^9}], Cell[BoxData[ RowBox[{"Series", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"1", "+", "x", "-", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", "0", ",", "3"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.434898084994897*^9, 3.434898159278897*^9}, { 3.435245140344*^9, 3.435245170473*^9}, {3.4352452011825*^9, 3.4352452174725*^9}}], Cell["or the other way", "Text", CellChangeTimes->{{3.4348981824918966`*^9, 3.434898192619897*^9}, { 3.4352452786625*^9, 3.435245291766*^9}}], Cell[BoxData[ RowBox[{"Series", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"1", "+", "x", "-", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"y", ",", "0", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "3"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.434898084994897*^9, 3.434898159278897*^9}, { 3.435245140344*^9, 3.435245170473*^9}, {3.4352452011825*^9, 3.4352452174725*^9}, {3.4352453054*^9, 3.4352453100810003`*^9}}], Cell["We can eliminate the O[] terms with the Normal[] command ", "Text", CellChangeTimes->{{3.43524961105*^9, 3.435249644598*^9}}], Cell[BoxData[ RowBox[{"Normal", "[", RowBox[{"Series", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"1", "+", "x", "-", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"y", ",", "0", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "3"}], "}"}]}], "]"}], "]"}]], "Input", CellChangeTimes->{{3.435249572185*^9, 3.435249584019*^9}}], Cell["\<\ Now consider partial derivatives that can be performed with the D{} command.\ \>", "Text", CellChangeTimes->{{3.435245422201*^9, 3.4352454301575003`*^9}, { 3.435245654113*^9, 3.435245656541*^9}, {3.435245803158*^9, 3.4352458141015*^9}}], Cell[BoxData[ RowBox[{"D", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"1", "+", "x", "-", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "1"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.4348982005318966`*^9, 3.4348982085718966`*^9}, { 3.435245675725*^9, 3.4352457136085*^9}, {3.435245751975*^9, 3.4352457521025*^9}}], Cell[BoxData[ RowBox[{"D", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"1", "+", "x", "-", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"y", ",", "1"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.4348982005318966`*^9, 3.4348982085718966`*^9}, { 3.435245675725*^9, 3.4352457136085*^9}, {3.435245751975*^9, 3.4352457667375*^9}}], Cell[BoxData[ RowBox[{"D", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"1", "+", "x", "-", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", "1"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.4348982005318966`*^9, 3.4348982085718966`*^9}, { 3.435245675725*^9, 3.4352457136085*^9}, {3.435245751975*^9, 3.4352457521025*^9}, {3.4352457822574997`*^9, 3.4352457886625*^9}}], Cell["Or instead use", "Text", CellChangeTimes->{{3.4352460133094997`*^9, 3.43524601735*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", RowBox[{"Log", "[", RowBox[{"1", "+", "x", "-", "y"}], "]"}]}]], "Input", CellChangeTimes->{{3.435246186939*^9, 3.4352461983765*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"Derivative", "[", RowBox[{"1", ",", "1"}], "]"}], "[", "f", "]"}], "[", RowBox[{"x", ",", "y"}], "]"}]], "Input", CellChangeTimes->{{3.4348982005318966`*^9, 3.4348982237868967`*^9}, { 3.4352460205445004`*^9, 3.4352460515365*^9}, {3.435246093881*^9, 3.4352460959379997`*^9}, {3.43524613577*^9, 3.4352461630030003`*^9}, { 3.435246206354*^9, 3.435246223304*^9}}], Cell["Or at the explicit point (the coefficient of xy above)", "Text", CellChangeTimes->{{3.43524623329*^9, 3.435246250894*^9}, { 3.4352472711914997`*^9, 3.4352473028645*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"Derivative", "[", RowBox[{"1", ",", "1"}], "]"}], "[", "f", "]"}], "[", RowBox[{"0", ",", "0"}], "]"}]], "Input", CellChangeTimes->{{3.4348982005318966`*^9, 3.4348982237868967`*^9}, { 3.4352460205445004`*^9, 3.4352460515365*^9}, {3.435246093881*^9, 3.4352460959379997`*^9}, {3.43524613577*^9, 3.4352461630030003`*^9}, { 3.435246206354*^9, 3.435246223304*^9}, {3.435246266881*^9, 3.4352462696235*^9}}], Cell["\<\ Now consider the problem of minimizing a distance with a constraint -\ \>", "Text", CellChangeTimes->{{3.4352470323145*^9, 3.4352470578059998`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"d2", "[", RowBox[{"x_", ",", "y_", ",", "z_"}], "]"}], ":=", RowBox[{ RowBox[{"x", "^", "2"}], "+", RowBox[{"y", "^", "2"}], "+", RowBox[{"z", "^", "2"}]}]}]], "Input", CellChangeTimes->{{3.4352464216219997`*^9, 3.4352464520085*^9}}], Cell[BoxData[ RowBox[{"D", "[", RowBox[{ RowBox[{"d2", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "1"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.4352464959165*^9, 3.4352465350810003`*^9}}], Cell["Try it directly", "Text", CellChangeTimes->{{3.4352470753455*^9, 3.4352470802535*^9}}], Cell[BoxData[ RowBox[{"Solve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"d2", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "1"}], "}"}]}], "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"d2", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], ",", RowBox[{"{", RowBox[{"y", ",", "1"}], "}"}]}], "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"d2", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], ",", RowBox[{"{", RowBox[{"z", ",", "1"}], "}"}]}], "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"x", "-", RowBox[{"2", " ", "y"}], " ", "-", RowBox[{"2", " ", "z"}]}], "==", "3"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "y", ",", "z"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.4352465476675*^9, 3.4352466595085*^9}}], Cell["\<\ No surprise - this problem is over constrained with no solution. Now try \ with a Lagrange multiplier as in the Lecture\ \>", "Text", CellChangeTimes->{{3.435247085475*^9, 3.4352471223970003`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"F", "[", RowBox[{"x_", ",", "y_", ",", "z_", ",", "\[Lambda]_"}], "]"}], ":=", RowBox[{ RowBox[{"d2", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], "+", RowBox[{"\[Lambda]", RowBox[{"(", RowBox[{"x", "-", RowBox[{"2", " ", "y"}], " ", "-", RowBox[{"2", " ", "z"}]}], ")"}]}]}]}]], "Input", CellChangeTimes->{{3.435246839731*^9, 3.435246884507*^9}}], Cell[BoxData[ RowBox[{"sol", "=", RowBox[{"Solve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y", ",", "z", ",", "\[Lambda]"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "1"}], "}"}]}], "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y", ",", "z", ",", "\[Lambda]"}], "]"}], ",", RowBox[{"{", RowBox[{"y", ",", "1"}], "}"}]}], "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"D", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y", ",", "z", ",", "\[Lambda]"}], "]"}], ",", RowBox[{"{", RowBox[{"z", ",", "1"}], "}"}]}], "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"x", "-", RowBox[{"2", " ", "y"}], " ", "-", RowBox[{"2", " ", "z"}]}], "==", "3"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "y", ",", "z", ",", "\[Lambda]"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.4352465476675*^9, 3.4352466595085*^9}, { 3.4352469034925003`*^9, 3.4352469399695*^9}, {3.4352469737895*^9, 3.4352469755765*^9}}], Cell["\<\ So now we easily get the result we want and the corresponding distance is \ \>", "Text", CellChangeTimes->{{3.4352471303710003`*^9, 3.43524716455*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Sqrt", "[", RowBox[{"d2", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], "]"}], "/.", RowBox[{"sol", "[", RowBox[{"[", "1", "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.435246985567*^9, 3.4352470043754997`*^9}, { 3.435259067289*^9, 3.435259071953*^9}}], Cell["\<\ Mathematica also has commands to find global (and local) extrema (maxima and \ minima) with constraints. In the current case we have\ \>", "Text", CellChangeTimes->{{3.435258910558*^9, 3.4352589722135*^9}}], Cell[BoxData[ RowBox[{"Minimize", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"d2", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], ",", RowBox[{ RowBox[{"x", "-", RowBox[{"2", " ", "y"}], " ", "-", RowBox[{"2", " ", "z"}]}], "==", "3"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "y", ",", "z"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.4352589751285*^9, 3.4352590401775*^9}}], Cell["\<\ In this expression the first term is the value of d2. So we could also do \ the following to get the distance directly.\ \>", "Text", CellChangeTimes->{{3.4352590894545*^9, 3.435259143526*^9}}], Cell[BoxData[ RowBox[{"Minimize", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Sqrt", "[", RowBox[{"d2", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], "]"}], ",", RowBox[{ RowBox[{"x", "-", RowBox[{"2", " ", "y"}], " ", "-", RowBox[{"2", " ", "z"}]}], "==", "3"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "y", ",", "z"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.4352589751285*^9, 3.4352590401775*^9}, { 3.4352591229385*^9, 3.4352591269779997`*^9}}] }, Open ]] }, WindowSize->{1509, 684}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic}, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (June 19, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 496, 7, 71, "Section"], Cell[1089, 32, 1432, 21, 29, "Text"], Cell[2524, 55, 430, 11, 31, "Input"], Cell[2957, 68, 144, 2, 29, "Text"], Cell[3104, 72, 473, 11, 31, "Input"], Cell[3580, 85, 132, 1, 29, "Text"], Cell[3715, 88, 376, 10, 31, "Input"], Cell[4094, 100, 252, 5, 29, "Text"], Cell[4349, 107, 350, 9, 31, "Input"], Cell[4702, 118, 350, 9, 31, "Input"], Cell[5055, 129, 455, 11, 31, "Input"], Cell[5513, 142, 94, 1, 29, "Text"], Cell[5610, 145, 229, 6, 31, "Input"], Cell[5842, 153, 422, 9, 31, "Input"], Cell[6267, 164, 178, 2, 29, "Text"], Cell[6448, 168, 466, 10, 31, "Input"], Cell[6917, 180, 159, 3, 29, "Text"], Cell[7079, 185, 287, 8, 31, "Input"], Cell[7369, 195, 257, 7, 31, "Input"], Cell[7629, 204, 93, 1, 29, "Text"], Cell[7725, 207, 1077, 32, 31, "Input"], Cell[8805, 241, 209, 4, 29, "Text"], Cell[9017, 247, 429, 12, 31, "Input"], Cell[9449, 261, 1299, 36, 31, "Input"], Cell[10751, 299, 162, 3, 29, "Text"], Cell[10916, 304, 308, 8, 31, "Input"], Cell[11227, 314, 218, 4, 29, "Text"], Cell[11448, 320, 448, 13, 31, "Input"], Cell[11899, 335, 205, 4, 29, "Text"], Cell[12107, 341, 533, 15, 31, "Input"] }, Open ]] } ] *) (* End of internal cache information *)