(* 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[ 13215, 417] NotebookOptionsPosition[ 11683, 363] NotebookOutlinePosition[ 12864, 404] CellTagsIndexPosition[ 12821, 401] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[TextData[StyleBox["", FontFamily->"Arial", FontWeight->"Bold", FontColor->RGBColor[0, 0, 1]]], "Text"], Cell[TextData[StyleBox["Short Programs That Might Help ", FontFamily->"Modern", FontSize->18, FontWeight->"Bold"]], "Title", PageWidth->WindowWidth, CellMargins->{{Inherited, 0}, {Inherited, Inherited}}, TextAlignment->Left, TextJustification->1, FontFamily->"Arial"], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["ITERATION: ", FontSize->16, FontWeight->"Bold"], "The following program will interate a function for any given initial \ condition. " }], "Text", PageWidth->WindowWidth, CellMargins->{{Inherited, 0}, {Inherited, Inherited}}, TextAlignment->Left, TextJustification->1, FontFamily->"Arial", FontSize->14], Cell[BoxData[{ RowBox[{ RowBox[{"Clear", "[", RowBox[{"f", ",", " ", "x0", ",", " ", "n"}], "]"}], "\[IndentingNewLine]", " ", RowBox[{"(*", RowBox[{ "f", " ", "is", " ", "the", " ", "function", " ", "you", " ", "want", " ", "to", " ", "iterate"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{"3.9", "x", " ", RowBox[{"(", RowBox[{"1", "-", "x"}], ")"}]}]}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"x0", " ", "is", " ", "the", " ", "initial", " ", "value"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"x0", "=", ".3"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "n", " ", "is", " ", "the", " ", "number", " ", "of", " ", "iterations"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"n", "=", "10"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "the", " ", "program", " ", "will", " ", "display", " ", "the", " ", "n", " ", "iterates"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{"NestList", "[", RowBox[{"f", ",", "x0", ",", "n"}], "]"}], "\[IndentingNewLine]"}], "Input",\ CellChangeTimes->{{3.441039612592125*^9, 3.441039688367448*^9}, { 3.44103972209825*^9, 3.441039722480385*^9}, {3.441039758923656*^9, 3.441039791035194*^9}}] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["TIME SERIES PLOT:", FontSize->16, FontWeight->"Bold"], "The following program will provide a time series plot for any orbit of \ f=f(x) for any inputed seed and number of iterations." }], "Text", PageWidth->WindowWidth, CellMargins->{{Inherited, 0}, {Inherited, Inherited}}, TextAlignment->Left, TextJustification->1, FontFamily->"Arial", FontSize->14], Cell[BoxData[{ RowBox[{ RowBox[{"Clear", "[", "f", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{"3", " ", "x", " ", RowBox[{"(", RowBox[{"1", "-", "x"}], ")"}]}]}]}], "Input"], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"Clear", "[", "n", "]"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "n", " ", "is", " ", "the", " ", "number", " ", "of", " ", "iterations", " ", "of", " ", "function", " ", "f", " ", "you", " ", "want", " ", "to", " ", "see"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"n", "=", "40"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"p", "[", "0", "]"}], " ", "is", " ", "the", " ", "seed", " ", "value"}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"p", "[", "0", "]"}], "=", ".2"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"Range", " ", "of", " ", "y"}], "-", RowBox[{"values", " ", "is", " ", "b0", " ", "to", " ", "b1"}]}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"b0", "=", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"b1", "=", "1"}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "1"}], ",", RowBox[{"i", "<", RowBox[{"n", "+", "1"}]}], ",", RowBox[{ RowBox[{ RowBox[{"p", "[", "i", "]"}], "=", RowBox[{"f", "[", RowBox[{"p", "[", RowBox[{"i", "-", "1"}], "]"}], "]"}]}], ";", RowBox[{"i", "++"}]}]}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", RowBox[{"p", "[", "i", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "0", ",", "n"}], "}"}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"ListPlot", "[", RowBox[{"t", ",", RowBox[{"Joined", "\[Rule]", "True"}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"b0", ",", "b1"}], "}"}]}]}], "]"}], "\[IndentingNewLine]"}], "Input", CellChangeTimes->{{3.441039825885025*^9, 3.441039857774005*^9}, { 3.4410399069454308`*^9, 3.441039914968835*^9}}] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox[" WEB DIAGRAM:", FontSize->16, FontWeight->"Bold"], "The following program will show the web diagram of f=f(x) for any inputed \ seed and number of iterations. " }], "Text", PageWidth->WindowWidth, CellMargins->{{Inherited, 0}, {Inherited, Inherited}}, CellChangeTimes->{3.441040983999874*^9}, TextAlignment->Left, TextJustification->1, FontFamily->"Arial", FontSize->14], Cell[BoxData[ RowBox[{"Clear", "[", "g", "]"}]], "Input"], Cell[BoxData[{ RowBox[{ RowBox[{"Clear", "[", RowBox[{ "f", ",", "s", ",", "k", ",", " ", "a0", ",", " ", "a1", ",", " ", "b0", ",", " ", "b1"}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{"\[Pi]", " ", "*", "x", " ", RowBox[{"(", RowBox[{"1", "-", "x"}], ")"}]}]}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "k", " ", "is", " ", "the", " ", "number", " ", "of", " ", "iterations", " ", "of", " ", "function", " ", "f", " ", "you", " ", "want", " ", "to", " ", "see"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"k", "=", "20"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"s", " ", "is", " ", "the", " ", "seed", " ", "value"}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"s", "=", ".9"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ "x", " ", "values", " ", "depicted", " ", "range", " ", "from", " ", "a0", " ", "to", " ", "a1"}], ",", " ", RowBox[{ "y", " ", "values", " ", "from", " ", "b0", " ", "to", " ", "b1"}]}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"a0", "=", RowBox[{"-", ".1"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"a1", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"b0", "=", RowBox[{"-", ".1"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"b1", "=", "1"}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"line", "=", RowBox[{"Plot", "[", RowBox[{"x", ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", "a0", ",", "a1"}], " ", "}"}], ",", " ", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"fplot", "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", " ", RowBox[{"{", RowBox[{"x", ",", " ", "a0", ",", "a1"}], " ", "}"}], ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"g", "[", "0", "]"}], "=", RowBox[{"Show", "[", RowBox[{"fplot", ",", " ", "line", ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"a0", ",", "a1"}], "}"}], ",", RowBox[{"{", RowBox[{"b0", ",", "b1"}], "}"}]}], "}"}]}], ",", " ", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"ver", "[", "n", "]"}], "=", " ", RowBox[{"ParametricPlot", "[", RowBox[{ RowBox[{"{", RowBox[{"s", ",", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "t"}], ")"}], "s"}], "+", RowBox[{"t", " ", RowBox[{"f", "[", "s", "]"}]}]}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", "0", ",", "1"}], "}"}], ",", " ", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "Red", "}"}]}], ",", " ", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"hor", "[", "n", "]"}], "=", " ", RowBox[{"ParametricPlot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "-", "t"}], " ", ")"}], "s"}], " ", "+", RowBox[{"t", " ", RowBox[{"f", "[", "s", "]"}]}]}], ",", " ", RowBox[{"f", "[", "s", "]"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", "0", ",", "1"}], "}"}], ",", " ", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", "Red", "}"}]}], ",", " ", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"g", "[", "n", "]"}], "=", RowBox[{"Show", "[", RowBox[{ RowBox[{"ver", "[", "n", "]"}], ",", " ", RowBox[{"hor", "[", "n", "]"}], ",", " ", RowBox[{"g", "[", RowBox[{"n", "-", "1"}], "]"}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"a0", ",", "a1"}], "}"}], ",", RowBox[{"{", RowBox[{"b0", ",", "b1"}], "}"}]}], "}"}]}], ",", " ", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], ";", " ", RowBox[{"s", "=", RowBox[{"f", "[", "s", "]"}]}]}], "}"}], ",", "\[IndentingNewLine]", " ", RowBox[{"{", RowBox[{"n", ",", "k"}], "}"}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{ RowBox[{"ver", "[", "k", "]"}], ",", " ", RowBox[{"hor", "[", "k", "]"}], ",", " ", RowBox[{"g", "[", RowBox[{"k", "-", "1"}], "]"}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"a0", ",", "a1"}], "}"}], ",", RowBox[{"{", RowBox[{"b0", ",", "b1"}], "}"}]}], "}"}]}], ",", " ", RowBox[{"DisplayFunction", "\[Rule]", "$DisplayFunction"}], ",", RowBox[{"AxesOrigin", "\[Rule]", "Automatic"}]}], "]"}]}], "Input", CellChangeTimes->{{3.441040769626124*^9, 3.441040773087886*^9}, { 3.4410410823105927`*^9, 3.441041088947226*^9}}] }, Open ]] }, AutoGeneratedPackage->None, ScreenStyleEnvironment->"Working", PrintingStyleEnvironment->"Printout", WindowToolbars->"EditBar", CellGrouping->Manual, WindowSize->{834, 862}, WindowMargins->{{97, Automatic}, {9, Automatic}}, DockedCells->FEPrivate`FrontEndResource[ "FEExpressions", "CompatibilityToolbar"], PrintingCopies->1, PrintingPageRange->{Automatic, Automatic}, PageHeaders->{{ Cell["Introduction to Mathematica", "Text", FontFamily -> "Arial"], Inherited, Cell[ TextData[{ CounterBox["Page"]}], "PageNumber"]}, { Cell["Introduction to Mathematica", "Text", FontFamily -> "Arial"], Inherited, Cell[ TextData[{ CounterBox["Page"]}], "PageNumber"]}}, PrintingOptions->{"FacingPages"->True, "FirstPageHeader"->False, "PrintCellBrackets"->False, "PrintMultipleHorizontalPages"->False, "PrintRegistrationMarks"->False, "PrintingMargins"->{{46.0625, 46.75}, {45, 100.75}}}, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (June 19, 2007)", StyleDefinitions->"Classroom.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 110, 3, 24, "Text"], Cell[681, 26, 275, 8, 34, "Title"], Cell[CellGroupData[{ Cell[981, 38, 341, 12, 27, "Text"], Cell[1325, 52, 1352, 37, 180, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[2714, 94, 390, 12, 46, "Text"], Cell[3107, 108, 240, 7, 60, "Input"], Cell[3350, 117, 2112, 62, 255, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[5499, 184, 410, 13, 27, "Text"], Cell[5912, 199, 58, 1, 44, "Input"], Cell[5973, 202, 5694, 158, 420, "Input"] }, Open ]] } ] *) (* End of internal cache information *)