(* 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[ 10946, 306] NotebookOptionsPosition[ 10515, 286] NotebookOutlinePosition[ 10850, 301] CellTagsIndexPosition[ 10807, 298] WindowFrame->Normal ContainsDynamic->True *) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{"Clear", "[", RowBox[{ "v", ",", "w", ",", "k", ",", "n", ",", "f", ",", "t2", ",", "x1", ",", "x2"}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"B", "=", "2"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", " ", RowBox[{"x", "+", RowBox[{ SuperscriptBox["\[ExponentialE]", RowBox[{ RowBox[{"-", "B"}], "*", SuperscriptBox["x", "2"]}]], RowBox[{"Cos", "[", "x", "]"}]}]}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"a", "=", RowBox[{"-", "1."}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"b", "=", "0."}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x0", "=", ".001"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x0", ">>", "v"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x1", "=", RowBox[{"x0", "-", RowBox[{ RowBox[{"f", "[", "x0", "]"}], "/", RowBox[{ RowBox[{"f", "'"}], "[", "x0", "]"}]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x1", ">>>", "v"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"tol", "=", RowBox[{"5", "*", SuperscriptBox["10", RowBox[{"-", "8"}]]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Abs", "[", RowBox[{"x1", "-", "x0"}], "]"}], "\[GreaterEqual]", " ", "tol"}], "\[And]", RowBox[{"n", "\[LessEqual]", " ", "10"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"x0", "=", "x1"}], ";", "\[IndentingNewLine]", RowBox[{"x1", "=", RowBox[{"x0", "-", RowBox[{ RowBox[{"f", "[", "x0", "]"}], "/", RowBox[{ RowBox[{"f", "'"}], "[", "x0", "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"x1", ">>>", "v"}], ";", "\[IndentingNewLine]", RowBox[{"n", "=", RowBox[{"n", "+", "1"}]}], ";"}]}], "]"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "n"}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "x1"}], "]"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"w", "=", RowBox[{"ReadList", "[", "\"\\"", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"p1", "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "a", ",", "b"}], "}"}], ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"t2", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{ RowBox[{"w", "[", RowBox[{"[", "k", "]"}], "]"}], ",", "0"}], "}"}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Animate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"p2", "=", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{"t2", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], ",", RowBox[{"PlotRange", "\[Rule]", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1.2"}], ",", "2.2"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"Hue", "[", ".7", "]"}], ",", RowBox[{"PointSize", "[", "0.02", "]"}]}], "}"}]}], ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"p4", "=", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{"t2", "[", RowBox[{"[", "k", "]"}], "]"}], ",", RowBox[{"PlotRange", "\[Rule]", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1.2"}], ",", "2.2"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"Hue", "[", "1", "]"}], ",", RowBox[{"PointSize", "[", "0.02", "]"}]}], "}"}]}], ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"p3", "=", RowBox[{"Show", "[", RowBox[{"Graphics", "[", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"w", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], ",", RowBox[{"f", "[", RowBox[{"w", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"w", "[", RowBox[{"[", "k", "]"}], "]"}], ",", "0"}], "}"}]}], "}"}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"p1", ",", "p2", ",", "p3", ",", "p4"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"k", ",", "2", ",", "n", ",", "1"}], "}"}]}], "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]"}], "\[IndentingNewLine]"}], "Input", CellChangeTimes->{{3.442752493834536*^9, 3.442752564199211*^9}, 3.442752608280129*^9, {3.442752665601396*^9, 3.4427527968647957`*^9}, 3.442752930552734*^9, {3.442753020089971*^9, 3.4427530387299557`*^9}, { 3.442753130431561*^9, 3.44275315981361*^9}, {3.442753203430862*^9, 3.4427532036210403`*^9}, {3.442753243742597*^9, 3.442753305256959*^9}, { 3.442755052773652*^9, 3.4427550703181267`*^9}, 3.442755104542609*^9, { 3.442755150904399*^9, 3.4427552643145227`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Newton's Method iterations=\"\>", "\[InvisibleSpace]", "6"}], SequenceForm["Newton's Method iterations=", 6], Editable->False]], "Print", CellChangeTimes->{{3.442755043588327*^9, 3.442755070721822*^9}, 3.442755105094091*^9, {3.442755166650136*^9, 3.442755174476275*^9}, 3.4427552137722073`*^9, {3.4427552439779053`*^9, 3.442755264805519*^9}}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"approximate root = \"\>", "\[InvisibleSpace]", RowBox[{"-", "0.5137327241262893`"}]}], SequenceForm["approximate root = ", -0.5137327241262893], Editable->False]], "Print", CellChangeTimes->{{3.442755043588327*^9, 3.442755070721822*^9}, 3.442755105094091*^9, {3.442755166650136*^9, 3.442755174476275*^9}, 3.4427552137722073`*^9, {3.4427552439779053`*^9, 3.442755264839747*^9}}] }, Open ]], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`k$$ = 2, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold[$CellContext`k$$], 2, 6, 1}}, Typeset`size$$ = { 360., {109., 113.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`k$7386$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`k$$ = 2}, "ControllerVariables" :> { Hold[$CellContext`k$$, $CellContext`k$7386$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> ($CellContext`p2 = ListPlot[ Part[$CellContext`t2, $CellContext`k$$ - 1], PlotRange -> {{0, 1}, {-1.2, 2.2}}, PlotStyle -> { Hue[0.7], PointSize[0.02]}, DisplayFunction -> Identity]; $CellContext`p4 = ListPlot[ Part[$CellContext`t2, $CellContext`k$$], PlotRange -> {{0, 1}, {-1.2, 2.2}}, PlotStyle -> { Hue[1], PointSize[0.02]}, DisplayFunction -> Identity]; $CellContext`p3 = Show[ Graphics[ Line[{{ Part[$CellContext`w, $CellContext`k$$ - 1], $CellContext`f[ Part[$CellContext`w, $CellContext`k$$ - 1]]}, { Part[$CellContext`w, $CellContext`k$$], 0}}]]]; Show[$CellContext`p1, $CellContext`p2, $CellContext`p3, \ $CellContext`p4]), "Specifications" :> {{$CellContext`k$$, 2, 6, 1, AppearanceElements -> { "ProgressSlider", "PlayPauseButton", "FasterSlowerButtons", "DirectionButton"}}}, "Options" :> { ControlType -> Animator, AppearanceElements -> None, SynchronousUpdating -> True, ShrinkingDelay -> 10.}, "DefaultOptions" :> {}], ImageSizeCache->{406., {146., 153.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{{3.44275504366083*^9, 3.442755070792211*^9}, 3.442755105167053*^9, {3.442755166685832*^9, 3.4427551745517797`*^9}, 3.4427552138437033`*^9, {3.4427552440530157`*^9, 3.4427552648785677`*^9}}] }, Open ]] }, WindowSize->{640, 750}, WindowMargins->{{4, Automatic}, {Automatic, 4}}, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (April 20, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 6289, 179, 923, "Input"], Cell[CellGroupData[{ Cell[6904, 206, 404, 7, 24, "Print"], Cell[7311, 215, 443, 8, 24, "Print"] }, Open ]], Cell[7769, 226, 2730, 57, 316, "Output"] }, Open ]] } ] *) (* End of internal cache information *)