(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 45870, 1276] NotebookOptionsPosition[ 45487, 1260] NotebookOutlinePosition[ 45827, 1275] CellTagsIndexPosition[ 45784, 1272] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ StyleBox[ RowBox[{"(*", RowBox[{ "Notebook", " ", "created", " ", "in", " ", "2010", " ", "by", " ", "Richards"}], "*)"}], FontSize->10]], "Input", CellChangeTimes->{{3.476460726553525*^9, 3.4764609225855618`*^9}, { 3.476461085910136*^9, 3.476461091557209*^9}, {3.476529160126828*^9, 3.4765292425998096`*^9}, {3.476529284287507*^9, 3.476529351328939*^9}, { 3.476529387738759*^9, 3.476529521952941*^9}, {3.4765307730131397`*^9, 3.4765308248028517`*^9}, {3.476530859708929*^9, 3.476531048426136*^9}, { 3.476531093198719*^9, 3.476531136363636*^9}, {3.476531180323299*^9, 3.476531310396146*^9}, {3.47653144962078*^9, 3.47653145763032*^9}, { 3.476531582829681*^9, 3.476531695198145*^9}, {3.476531735770521*^9, 3.476531931625484*^9}, {3.476531964787898*^9, 3.476532097400134*^9}, 3.476532137952367*^9, {3.476532198760453*^9, 3.476532211518087*^9}, { 3.476532278409204*^9, 3.476532283484378*^9}, {3.476533403152781*^9, 3.476533433971381*^9}, {3.47653346468853*^9, 3.476533674482564*^9}, { 3.476533760774273*^9, 3.476533978775939*^9}, {3.4765340535822697`*^9, 3.476534206172014*^9}, {3.4765342496782503`*^9, 3.476534294142187*^9}, { 3.476534330309328*^9, 3.4765345471785307`*^9}, {3.476534701212491*^9, 3.476534713497504*^9}, 3.476535327198307*^9, {3.476535408300788*^9, 3.476535502302401*^9}, {3.476535580598795*^9, 3.4765355864975357`*^9}, { 3.476535622093699*^9, 3.476535642556548*^9}, {3.4765356795744677`*^9, 3.476535746125102*^9}, {3.476535887411604*^9, 3.476535953720374*^9}, { 3.4765359897156076`*^9, 3.4765359922830067`*^9}, {3.4765360642374973`*^9, 3.476536089013588*^9}, {3.476536119971971*^9, 3.476536122516109*^9}, { 3.4765361563450623`*^9, 3.4765361575608053`*^9}, 3.4766157619584217`*^9, 3.4766159061620092`*^9, {3.476616155243684*^9, 3.47661624208315*^9}, { 3.47661909965844*^9, 3.4766190999661407`*^9}, {3.47661916556921*^9, 3.4766191753099613`*^9}, 3.476619534418762*^9, {3.476630611153516*^9, 3.476630667934643*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", RowBox[{ StyleBox["Modified", FontSize->18, FontVariations->{"Underline"->True}, FontColor->RGBColor[1, 0.5, 0]], StyleBox[" ", FontSize->18, FontVariations->{"Underline"->True}, FontColor->RGBColor[1, 0.5, 0]], StyleBox["Gradient", FontSize->18, FontVariations->{"Underline"->True}, FontColor->RGBColor[1, 0.5, 0]], StyleBox[" ", FontSize->18, FontVariations->{"Underline"->True}, FontColor->RGBColor[1, 0.5, 0]], StyleBox["Method", FontSize->18, FontVariations->{"Underline"->True}, FontColor->RGBColor[1, 0.5, 0]], StyleBox[" ", FontSize->18, FontVariations->{"Underline"->True}, FontColor->RGBColor[1, 0.5, 0]], RowBox[{ StyleBox["I", FontSize->18, FontVariations->{"Underline"->True}, FontColor->RGBColor[1, 0.5, 0]], ":", " ", RowBox[{ RowBox[{"Step", " ", "size"}], " ", "|", "\[Lambda]", "|", " ", RowBox[{"is", " ", "fixed", " ", RowBox[{"(", RowBox[{"Normalize", " ", "the", " ", "Gradient"}], ")"}]}]}]}]}], " ", "*)"}], RowBox[{"(*", " ", StyleBox[ RowBox[{ RowBox[{ "This", " ", "routine", " ", "is", " ", "designed", " ", "to", " ", "use", " ", "the", " ", "gradient", " ", "to", " ", "search", " ", "for", " ", "candidates", " ", "for", " ", "local", " ", "extrema", " ", "for", " ", "a", " ", "real"}], "-", RowBox[{ "valued", " ", "function", " ", "of", " ", "two", " ", "variables"}]}], FontWeight->"Plain", FontSlant->"Italic"], StyleBox[" ", FontWeight->"Plain", FontSlant->"Italic"], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Clear", "[", RowBox[{"F", ",", "Fx", ",", "Fy", ",", "X", ",", "Y"}], "]"}], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", StyleBox[ RowBox[{ "Input", " ", "function", " ", "F", " ", "to", " ", "be", " ", "examined", " ", "and", " ", "its", " ", "1", "st", " ", "order", " ", "partials"}], FontWeight->"Plain", FontSlant->"Italic"], " ", "*)"}], FontColor->RGBColor[0, 0, 1]], "\[IndentingNewLine]", StyleBox[ RowBox[{ RowBox[{"F", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", " ", RowBox[{ SuperscriptBox["x", "4"], "+", SuperscriptBox["y", "6"], "-", SuperscriptBox["x", "2"], "-", RowBox[{"4", SuperscriptBox["y", "2"]}], "-", RowBox[{ SuperscriptBox["x", "2"], SuperscriptBox["y", "2"]}]}]}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{ RowBox[{"Fx", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", RowBox[{ RowBox[{"4", SuperscriptBox["x", "3"]}], "-", RowBox[{"2", "x"}], "-", RowBox[{"2", "x", "*", SuperscriptBox["y", "2"]}]}]}], ";"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{ RowBox[{"Fy", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", RowBox[{ RowBox[{"6", SuperscriptBox["y", "5"]}], "-", RowBox[{"8", "y"}], "-", RowBox[{"2", SuperscriptBox["x", "2"], "y"}]}]}], ";"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", RowBox[{"Intial", " ", "guess"}], "*)"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{ RowBox[{"X", "[", "0", "]"}], "=", ".2"}], ";"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{ RowBox[{"Y", "[", "0", "]"}], "=", ".2"}], ";"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", RowBox[{"|", "\[Lambda]", "|", " ", RowBox[{"=", " ", "Stepsize"}]}], " ", "*)"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", RowBox[{ RowBox[{"set", " ", "\[Lambda]"}], ">", RowBox[{"0", " ", "for", " ", "local", " ", "max", " ", "search"}]}], "*)"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{"(*", RowBox[{ RowBox[{"set", " ", "\[Lambda]"}], "<", RowBox[{"0", " ", "for", " ", "local", " ", "min", " ", "search"}]}], "*)"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{"\[Lambda]", "=", RowBox[{"-", ".1"}]}], ";"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], RowBox[{"(*", RowBox[{ "Set", " ", "Maximum", " ", "iterations", " ", "and", " ", "tolerance"}], "*)"}], "\[IndentingNewLine]", StyleBox[ RowBox[{ RowBox[{"MaxIteration", "=", "25"}], ";"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{"tol", "=", ".0001"}], ";"}], FontColor->RGBColor[0, 0, 1]], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"First", " ", "Iterate"}], "*)"}], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], RowBox[{ RowBox[{ RowBox[{"X", "[", "1", "]"}], "=", " ", RowBox[{ RowBox[{"X", "[", "0", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}], "/", SqrtBox[ RowBox[{ SuperscriptBox[ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}], "2"], "+", SuperscriptBox[ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}], "2"]}]]}]}]}]}], ";", RowBox[{ RowBox[{"Y", "[", "1", "]"}], "=", " ", RowBox[{ RowBox[{"Y", "[", "0", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}], "/", SqrtBox[ RowBox[{ SuperscriptBox[ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}], "2"], "+", SuperscriptBox[ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}], "2"]}]]}]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{ SqrtBox[ RowBox[{ SuperscriptBox[ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"], "+", SuperscriptBox[ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"]}]], ">", "tol"}], "&&", RowBox[{"n", "\[LessEqual]", StyleBox["MaxIteration", FontColor->RGBColor[0, 0, 1]]}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"X", "[", RowBox[{"n", "+", "1"}], "]"}], "=", " ", RowBox[{ RowBox[{"X", "[", "n", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "/", SqrtBox[ RowBox[{ SuperscriptBox[ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"], "+", SuperscriptBox[ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"]}]]}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"Y", "[", RowBox[{"n", "+", "1"}], "]"}], "=", " ", RowBox[{ RowBox[{"Y", "[", "n", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "/", SqrtBox[ RowBox[{ SuperscriptBox[ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"], "+", SuperscriptBox[ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"]}]]}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"n", "=", RowBox[{"n", "+", "1"}]}], ";"}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"n", "-", "1"}]}], ";", " ", RowBox[{"(*", RowBox[{"adjust", " ", "n"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "]"}], "*)"}], "\[IndentingNewLine]", RowBox[{"q1", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"Contours", "\[Rule]", "100"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"t1", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"X", "[", "j", "]"}], ",", RowBox[{"Y", "[", "j", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "0", ",", "n"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"q2", "=", RowBox[{"ListPlot", "[", RowBox[{"t1", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0", ",", "0"}], "]"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "1"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"zoom1", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{ RowBox[{"X", "[", "0", "]"}], "-", RowBox[{"3", "\[Lambda]"}]}], ",", RowBox[{ RowBox[{"X", "[", "0", "]"}], "+", RowBox[{"3", "\[Lambda]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{ RowBox[{"Y", "[", "0", "]"}], "-", RowBox[{"3", "\[Lambda]"}]}], ",", RowBox[{ RowBox[{"Y", "[", "0", "]"}], "+", RowBox[{"3", "\[Lambda]"}]}]}], "}"}], ",", RowBox[{"Contours", "\[Rule]", "70"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"V1", "=", RowBox[{"Graphics", "[", RowBox[{"Arrow", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"X", "[", "1", "]"}], ",", RowBox[{"Y", "[", "1", "]"}]}], "}"}]}], "}"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}], "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"zoom1", ",", "V1", ",", "q2"}], "]"}], "\[IndentingNewLine]", RowBox[{ "Print", "[", "\"\<*******************************************************\>\"", "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}], "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"q1", ",", "q2", ",", "V1"}], "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", " ", "n", ",", "\"\< iterations of this modified Gradient Method,\>\""}], "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", RowBox[{"{", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", RowBox[{"F", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}], "]"}], "\[IndentingNewLine]", RowBox[{ "Print", "[", "\"\<*******************************************************\>\"", "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]"}]}]], "Input", CellChangeTimes->{{3.476460726553525*^9, 3.4764609225855618`*^9}, { 3.476461085910136*^9, 3.476461091557209*^9}, {3.476529160126828*^9, 3.4765292425998096`*^9}, {3.476529284287507*^9, 3.476529351328939*^9}, { 3.476529387738759*^9, 3.476529521952941*^9}, {3.4765307730131397`*^9, 3.4765308248028517`*^9}, {3.476530859708929*^9, 3.476531048426136*^9}, { 3.476531093198719*^9, 3.476531136363636*^9}, {3.476531180323299*^9, 3.476531310396146*^9}, {3.47653144962078*^9, 3.47653145763032*^9}, { 3.476531582829681*^9, 3.476531695198145*^9}, {3.476531735770521*^9, 3.476531931625484*^9}, {3.476531964787898*^9, 3.476532097400134*^9}, 3.476532137952367*^9, {3.476532198760453*^9, 3.476532211518087*^9}, { 3.476532278409204*^9, 3.476532283484378*^9}, {3.476533403152781*^9, 3.476533433971381*^9}, {3.47653346468853*^9, 3.476533674482564*^9}, { 3.476533760774273*^9, 3.476533978775939*^9}, {3.4765340535822697`*^9, 3.476534206172014*^9}, {3.4765342496782503`*^9, 3.476534294142187*^9}, { 3.476534330309328*^9, 3.4765345471785307`*^9}, {3.476534701212491*^9, 3.476534713497504*^9}, 3.476535327198307*^9, {3.476535408300788*^9, 3.476535502302401*^9}, {3.476535580598795*^9, 3.4765355864975357`*^9}, { 3.476535622093699*^9, 3.476535642556548*^9}, {3.4765356795744677`*^9, 3.476535746125102*^9}, {3.476535887411604*^9, 3.476535953720374*^9}, { 3.4765359897156076`*^9, 3.4765359922830067`*^9}, {3.4765360642374973`*^9, 3.476536089013588*^9}, {3.476536119971971*^9, 3.476536122516109*^9}, { 3.4765361563450623`*^9, 3.4765361575608053`*^9}, 3.4766157619584217`*^9, 3.4766159061620092`*^9, {3.476616155243684*^9, 3.47661624208315*^9}, { 3.47661909965844*^9, 3.4766190999661407`*^9}, {3.47661916556921*^9, 3.4766191753099613`*^9}, 3.476619534418762*^9, 3.476630611153516*^9, { 3.476630806380794*^9, 3.476630816772024*^9}, {3.476641688841962*^9, 3.476641691631822*^9}}], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{"(*", StyleBox[ RowBox[{"Modified", " ", "Gradient", " ", "Method", " ", "II"}], FontSize->18, FontVariations->{"Underline"->True}, FontColor->RGBColor[0.5, 0, 0.5]], "*)"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"Parameter", " ", "\[Lambda]", " ", "is", " ", "fixed"}], ",", " ", RowBox[{ RowBox[{"but", " ", "actual", " ", "stepsize", " ", "is"}], " ", "|", "\[Lambda]", "|", " ", RowBox[{"times", " ", "magnitude", " ", "of", " ", "gradient", " ", RowBox[{"(", RowBox[{"Gradient", " ", "Not", " ", "Normalized"}]}]}]}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Clear", "[", RowBox[{"F", ",", "Fx", ",", "Fy", ",", "X", ",", "Y"}], "]"}], "\[IndentingNewLine]", RowBox[{"(*", StyleBox[ RowBox[{ "Input", " ", "function", " ", "F", " ", "to", " ", "be", " ", "examined", " ", "and", " ", "its", " ", "1", "st", " ", "order", " ", "partials"}], FontWeight->"Plain", FontSlant->"Italic"], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"F", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", " ", RowBox[{"(", RowBox[{ SuperscriptBox["x", "4"], "+", SuperscriptBox["y", "6"], "-", SuperscriptBox["x", "2"], "-", RowBox[{"4", SuperscriptBox["y", "2"]}], "-", RowBox[{ SuperscriptBox["x", "2"], SuperscriptBox["y", "2"]}]}], ")"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Fx", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", RowBox[{ RowBox[{"4", SuperscriptBox["x", "3"]}], "-", RowBox[{"2", "x"}], "-", RowBox[{"2", "x", "*", SuperscriptBox["y", "2"]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Fy", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", RowBox[{ RowBox[{"6", SuperscriptBox["y", "5"]}], "-", RowBox[{"8", "y"}], "-", RowBox[{"2", SuperscriptBox["x", "2"], "y"}]}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"Intial", " ", "guess"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"X", "[", "0", "]"}], "=", ".2"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Y", "[", "0", "]"}], "=", ".2"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"|", "\[Lambda]", "|", " ", RowBox[{"=", " ", "Stepsize"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"set", " ", "\[Lambda]"}], ">", RowBox[{"0", " ", "for", " ", "local", " ", "max", " ", "search"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"set", " ", "\[Lambda]"}], "<", RowBox[{"0", " ", "for", " ", "local", " ", "min", " ", "search"}]}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Lambda]", "=", RowBox[{"-", ".05"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "Set", " ", "Maximum", " ", "iterations", " ", "and", " ", "tolerance"}], "*)"}], "\[IndentingNewLine]", StyleBox[ RowBox[{ RowBox[{"MaxIteration", "=", "25"}], ";"}], FontColor->RGBColor[0, 0, 1]], StyleBox["\[IndentingNewLine]", FontColor->RGBColor[0, 0, 1]], StyleBox[ RowBox[{ RowBox[{"tol", "=", ".0001"}], ";"}], FontColor->RGBColor[0, 0, 1]], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"First", " ", "Iterate"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"X", "[", "1", "]"}], "=", " ", RowBox[{ RowBox[{"X", "[", "0", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Y", "[", "1", "]"}], "=", " ", RowBox[{ RowBox[{"Y", "[", "0", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{ SqrtBox[ RowBox[{ SuperscriptBox[ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"], "+", SuperscriptBox[ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"]}]], ">", "tol"}], "&&", RowBox[{"n", "\[LessEqual]", StyleBox["MaxIteration", FontColor->RGBColor[0, 0, 1]]}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"X", "[", RowBox[{"n", "+", "1"}], "]"}], "=", " ", RowBox[{ RowBox[{"X", "[", "n", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"Y", "[", RowBox[{"n", "+", "1"}], "]"}], "=", " ", RowBox[{ RowBox[{"Y", "[", "n", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"n", "=", RowBox[{"n", "+", "1"}]}], ";"}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"n", "-", "1"}]}], ";", " ", RowBox[{"(*", RowBox[{"adjust", " ", "n"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "]"}], "*)"}], "\[IndentingNewLine]", RowBox[{"q1", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"Contours", "\[Rule]", "100"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"t1", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"X", "[", "j", "]"}], ",", RowBox[{"Y", "[", "j", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "0", ",", "n"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"q2", "=", RowBox[{"ListPlot", "[", RowBox[{"t1", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0", ",", "0"}], "]"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "1"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"zoom1", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{ RowBox[{"X", "[", "0", "]"}], "-", RowBox[{"3", "\[Lambda]"}]}], ",", RowBox[{ RowBox[{"X", "[", "0", "]"}], "+", RowBox[{"3", "\[Lambda]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{ RowBox[{"Y", "[", "0", "]"}], "-", RowBox[{"3", "\[Lambda]"}]}], ",", RowBox[{ RowBox[{"Y", "[", "0", "]"}], "+", RowBox[{"3", "\[Lambda]"}]}]}], "}"}], ",", RowBox[{"Contours", "\[Rule]", "70"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"V1", "=", RowBox[{"Graphics", "[", RowBox[{"Arrow", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"X", "[", "1", "]"}], ",", RowBox[{"Y", "[", "1", "]"}]}], "}"}]}], "}"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}], "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"zoom1", ",", "V1", ",", "q2"}], "]"}], "\[IndentingNewLine]", RowBox[{ "Print", "[", "\"\<*******************************************************\>\"", "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\\"", "]"}], "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"q1", ",", "q2", ",", "V1"}], "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", " ", "n", ",", "\"\< iterations of this modified Gradient Method,\>\""}], "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", RowBox[{"{", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", RowBox[{"F", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}], "]"}], "\[IndentingNewLine]", RowBox[{ "Print", "[", "\"\<*******************************************************\>\"", "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]"}]}]], "Input", CellChangeTimes->{{3.476460726553525*^9, 3.4764609225855618`*^9}, { 3.476461085910136*^9, 3.476461091557209*^9}, {3.476529160126828*^9, 3.4765292425998096`*^9}, {3.476529284287507*^9, 3.476529351328939*^9}, { 3.476529387738759*^9, 3.476529521952941*^9}, {3.4765307730131397`*^9, 3.4765308248028517`*^9}, {3.476530859708929*^9, 3.476531048426136*^9}, { 3.476531093198719*^9, 3.476531136363636*^9}, {3.476531180323299*^9, 3.476531310396146*^9}, {3.47653144962078*^9, 3.47653145763032*^9}, { 3.476531582829681*^9, 3.476531695198145*^9}, {3.476531735770521*^9, 3.476531931625484*^9}, {3.476531964787898*^9, 3.476532097400134*^9}, 3.476532137952367*^9, {3.476532198760453*^9, 3.476532211518087*^9}, { 3.476532278409204*^9, 3.476532283484378*^9}, {3.476533403152781*^9, 3.476533433971381*^9}, {3.47653346468853*^9, 3.476533674482564*^9}, { 3.476533760774273*^9, 3.476533978775939*^9}, {3.4765340535822697`*^9, 3.476534206172014*^9}, {3.4765342496782503`*^9, 3.476534294142187*^9}, { 3.476534330309328*^9, 3.4765345471785307`*^9}, {3.4765346087159243`*^9, 3.476534720119095*^9}, 3.47653528503507*^9, {3.476535534207047*^9, 3.476535555229291*^9}, {3.4765357538440647`*^9, 3.4765358826031237`*^9}, { 3.476535966893392*^9, 3.476536040895759*^9}, {3.476551114315178*^9, 3.476551122824794*^9}, {3.476615777124408*^9, 3.476615832177878*^9}, 3.476616115415895*^9, {3.476616252900566*^9, 3.476616264240149*^9}, 3.476616303737328*^9, {3.476619094258645*^9, 3.476619094686124*^9}, { 3.4766308380450497`*^9, 3.476630845163621*^9}, {3.476641697069788*^9, 3.476641700229974*^9}}], Cell[BoxData[ RowBox[{"\[IndentingNewLine]", "\[IndentingNewLine]", StyleBox[ RowBox[{"(*", StyleBox[ RowBox[{ RowBox[{"Cauchy", "'"}], "s", " ", "Gradient", " ", "Method"}], FontVariations->{"Underline"->True}, FontColor->RGBColor[1, 0, 0]], "*)"}], FontSize->18], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ "A", " ", "actual", " ", "stepsize", " ", "\[Lambda]", " ", "is", " ", "determined", " ", "at", " ", "each", " ", "stage", " ", "by", " ", "finding", " ", "a", " ", "local", " ", "extremum", " ", "along", " ", "line", " ", "parallel", " ", "to", " ", "Grad", RowBox[{"(", "F", ")"}], " ", "or"}], " ", "-", RowBox[{"Grad", RowBox[{"(", "F", ")"}]}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Clear", "[", RowBox[{"F", ",", "Fx", ",", "Fy", ",", "X", ",", "Y", ",", "G"}], "]"}], "\[IndentingNewLine]", RowBox[{"(*", StyleBox[ RowBox[{ "Input", " ", "function", " ", "F", " ", "to", " ", "be", " ", "examined", " ", "and", " ", "its", " ", "1", "st", " ", "order", " ", "partials"}], FontWeight->"Plain", FontSlant->"Italic"], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"F", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", " ", RowBox[{"(", RowBox[{ SuperscriptBox["x", "4"], "+", SuperscriptBox["y", "6"], "-", SuperscriptBox["x", "2"], "-", RowBox[{"4", SuperscriptBox["y", "2"]}], "-", RowBox[{ SuperscriptBox["x", "2"], SuperscriptBox["y", "2"]}]}], ")"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Fx", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", RowBox[{ RowBox[{"4", SuperscriptBox["x", "3"]}], "-", RowBox[{"2", "x"}], "-", RowBox[{"2", "x", "*", SuperscriptBox["y", "2"]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Fy", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", RowBox[{ RowBox[{"6", SuperscriptBox["y", "5"]}], "-", RowBox[{"8", "y"}], "-", RowBox[{"2", SuperscriptBox["x", "2"], "y"}]}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"Intial", " ", "guess"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"X", "[", "0", "]"}], "=", ".2"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Y", "[", "0", "]"}], "=", ".2"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"G", "[", "t_", "]"}], ":=", " ", RowBox[{"F", "[", RowBox[{ RowBox[{ RowBox[{"X", "[", "0", "]"}], "+", RowBox[{"t", "*", RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}]}]}], ",", RowBox[{ RowBox[{"Y", "[", "0", "]"}], "+", RowBox[{"t", "*", RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}]}]}]}], "]"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"\[Lambda]", "=", RowBox[{"t", "/.", RowBox[{ RowBox[{"Maximize", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"G", "[", "t", "]"}], ",", RowBox[{"t", "\[GreaterEqual]", " ", "0"}]}], "}"}], ",", "t"}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}]}]}], ";"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Lambda]", "=", RowBox[{"t", "/.", RowBox[{ RowBox[{"Minimize", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"G", "[", "t", "]"}], ",", RowBox[{"t", "\[LessEqual]", " ", "0"}]}], "}"}], ",", "t"}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Lambda]1", "=", "\[Lambda]"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"MaxIteration", "=", "25"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"tol", "=", ".0001"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"X", "[", "1", "]"}], "=", RowBox[{ RowBox[{"X", "[", "0", "]"}], "+", RowBox[{"\[Lambda]1", "*", RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Y", "[", "1", "]"}], "=", " ", RowBox[{ RowBox[{"Y", "[", "0", "]"}], "+", RowBox[{"\[Lambda]1", "*", RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "]"}]}]}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{ SqrtBox[ RowBox[{ SuperscriptBox[ RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"], "+", SuperscriptBox[ RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}], "2"]}]], ">", "tol"}], "&&", RowBox[{"n", "\[LessEqual]", "MaxIteration"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"G", "[", "t_", "]"}], ":=", " ", RowBox[{"F", "[", RowBox[{ RowBox[{ RowBox[{"X", "[", "n", "]"}], "+", RowBox[{"t", "*", RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}]}], ",", RowBox[{ RowBox[{"Y", "[", "n", "]"}], "+", RowBox[{"t", "*", RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"\[Lambda]", "=", RowBox[{"t", "/.", RowBox[{ RowBox[{"Maximize", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"G", "[", "t", "]"}], ",", RowBox[{"t", "\[GreaterEqual]", " ", "0"}]}], "}"}], ",", "t"}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}]}]}], ";"}], "*)"}], "\[IndentingNewLine]", RowBox[{ StyleBox["\[Lambda]", FontColor->RGBColor[1, 0, 0]], StyleBox["=", FontColor->RGBColor[1, 0, 0]], RowBox[{ StyleBox["t", FontColor->RGBColor[1, 0, 0]], StyleBox["/.", FontColor->RGBColor[1, 0, 0]], RowBox[{ RowBox[{ StyleBox["Minimize", FontColor->RGBColor[1, 0, 0]], StyleBox["[", FontColor->RGBColor[1, 0, 0]], RowBox[{ RowBox[{ StyleBox["{", FontColor->RGBColor[1, 0, 0]], RowBox[{ StyleBox[ RowBox[{"G", "[", "t", "]"}], FontColor->RGBColor[1, 0, 0]], StyleBox[",", FontColor->RGBColor[1, 0, 0]], RowBox[{ StyleBox["t", FontColor->RGBColor[1, 0, 0]], StyleBox["\[LessEqual]", FontColor->RGBColor[1, 0, 0]], "0"}]}], "}"}], StyleBox[",", FontColor->RGBColor[1, 0, 0]], StyleBox["t", FontColor->RGBColor[1, 0, 0]]}], StyleBox["]", FontColor->RGBColor[1, 0, 0]]}], StyleBox["[", FontColor->RGBColor[1, 0, 0]], StyleBox[ RowBox[{"[", "2", "]"}], FontColor->RGBColor[1, 0, 0]], StyleBox["]", FontColor->RGBColor[1, 0, 0]]}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"X", "[", RowBox[{"n", "+", "1"}], "]"}], "=", " ", RowBox[{ RowBox[{"X", "[", "n", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{"Fx", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"Y", "[", RowBox[{"n", "+", "1"}], "]"}], "=", " ", RowBox[{ RowBox[{"Y", "[", "n", "]"}], "+", RowBox[{"\[Lambda]", "*", RowBox[{"Fy", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"n", "=", RowBox[{"n", "+", "1"}]}], ";"}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"n", "-", "1"}]}], ";", " ", RowBox[{"(*", RowBox[{"adjust", " ", "n"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "]"}], "*)"}], "\[IndentingNewLine]", RowBox[{"q1", "=", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"F", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"Contours", "\[Rule]", "100"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"t1", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"X", "[", "j", "]"}], ",", RowBox[{"Y", "[", "j", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "0", ",", "n"}], "}"}]}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"q2", "=", RowBox[{"ListPlot", "[", RowBox[{"t1", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0", ",", "0"}], "]"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "1"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"V1", "=", RowBox[{"Graphics", "[", RowBox[{"Arrow", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"X", "[", "0", "]"}], ",", RowBox[{"Y", "[", "0", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"X", "[", "1", "]"}], ",", RowBox[{"Y", "[", "1", "]"}]}], "}"}]}], "}"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"q1", ",", "q2", ",", "V1"}], "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", " ", "n", ",", "\"\< iterations of Cauchy's Gradient Method,\>\""}], "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", RowBox[{"{", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", RowBox[{"F", "[", RowBox[{ RowBox[{"X", "[", "n", "]"}], ",", RowBox[{"Y", "[", "n", "]"}]}], "]"}]}], "]"}], "\[IndentingNewLine]", RowBox[{ "Print", "[", "\"\<*******************************************************\>\"", "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]"}]}]], "Input", CellChangeTimes->{{3.4766188188084793`*^9, 3.476618854548739*^9}, { 3.4766188918172903`*^9, 3.4766188990776367`*^9}, {3.4766189422335863`*^9, 3.476618952464519*^9}, {3.476618987530714*^9, 3.47661898798549*^9}, { 3.476619041111829*^9, 3.4766190690032597`*^9}, {3.476619106325141*^9, 3.4766191066380672`*^9}, {3.4766191964571457`*^9, 3.476619199704171*^9}, { 3.476641710284885*^9, 3.476641721008112*^9}, {3.476703652385378*^9, 3.476703712819318*^9}, {3.476703999418886*^9, 3.47670407466695*^9}, { 3.4767041079291687`*^9, 3.4767042294080763`*^9}, {3.476704424528194*^9, 3.47670443152649*^9}}] }, WindowSize->{1047, 672}, WindowMargins->{{66, Automatic}, {Automatic, 0}}, FrontEndVersion->"7.0 for Mac OS X x86 (32-bit) (November 10, 2008)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[545, 20, 2048, 32, 27, "Input"], Cell[2596, 54, 16769, 472, 1225, "Input"], Cell[19368, 528, 12540, 341, 1212, "Input"], Cell[31911, 871, 13572, 387, 1248, "Input"] } ] *) (* End of internal cache information *)