(* 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[ 13991, 427] NotebookOptionsPosition[ 13284, 399] NotebookOutlinePosition[ 13731, 417] CellTagsIndexPosition[ 13688, 414] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["3D vector function movie", "Subsubtitle"], Cell[BoxData[{ RowBox[{ RowBox[{"x", "[", "t_", "]"}], ":=", RowBox[{"Cos", "[", "t", "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", "t_", "]"}], ":=", RowBox[{"Sin", "[", "t", "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"z", "[", "t_", "]"}], ":=", RowBox[{"t", "/", "10"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"xmin", "=", RowBox[{"-", "1.1"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"xmax", " ", "=", " ", "1.1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ymin", " ", "=", " ", RowBox[{"-", "1.1"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ymax", " ", "=", " ", "1.1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"zmin", "=", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"zmax", "=", "3"}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"Animate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Show", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"ParametricPlot3D", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", " ", RowBox[{"y", "[", "t", "]"}], ",", " ", RowBox[{"z", "[", "t", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "stop"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Graphics3D", "[", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "0.03", "]"}], ",", RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0", ",", "0"}], "]"}], ",", RowBox[{"Point", "[", RowBox[{"{", RowBox[{ RowBox[{"x", "[", "stop", "]"}], ",", RowBox[{"y", "[", "stop", "]"}], ",", RowBox[{"z", "[", "stop", "]"}]}], "}"}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"xmin", ",", "xmax"}], "}"}], ",", RowBox[{"{", RowBox[{"ymin", ",", "ymax"}], "}"}], ",", RowBox[{"{", RowBox[{"zmin", ",", "zmax"}], "}"}]}], "}"}]}]}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"stop", ",", "1", ",", "30", ",", "0.5"}], "}"}]}], "\[IndentingNewLine]", "]"}]}], "Input", CellChangeTimes->{{3.416897884637187*^9, 3.4168978904730062`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["3D vector function movie with position/tangent vectors", "Subsubtitle"], Cell[BoxData[{ RowBox[{ RowBox[{"x", "[", "t_", "]"}], ":=", RowBox[{"Cos", "[", "t", "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"y", "[", "t_", "]"}], ":=", RowBox[{"Sin", "[", "t", "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"z", "[", "t_", "]"}], ":=", RowBox[{"t", "/", "10"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"r", "[", "t_", "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}], ",", RowBox[{"z", "[", "t", "]"}]}], "}"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"xmin", "=", RowBox[{"-", "1.1"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"xmax", " ", "=", " ", "1.1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ymin", " ", "=", " ", RowBox[{"-", "1.1"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ymax", " ", "=", " ", "1.1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"zmin", "=", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"zmax", "=", "3"}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"Animate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Show", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"ParametricPlot3D", "[", RowBox[{ RowBox[{"r", "[", "t", "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "stop"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Graphics3D", "[", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "0.03", "]"}], ",", RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0", ",", "0"}], "]"}], ",", RowBox[{"Point", "[", RowBox[{"r", "[", "stop", "]"}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Graphics3D", "[", RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"0", ",", "1", ",", "0"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"r", "[", "stop", "]"}]}], "}"}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Graphics3D", "[", RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"0", ",", "0", ",", "1"}], "]"}], ",", RowBox[{"Line", "[", RowBox[{"{", RowBox[{ RowBox[{"r", "[", "stop", "]"}], ",", RowBox[{ RowBox[{"r", "[", "stop", "]"}], "+", RowBox[{ RowBox[{ RowBox[{"r", "'"}], "[", "stop", "]"}], "/", RowBox[{"Norm", "[", RowBox[{ RowBox[{"r", "'"}], "[", "stop", "]"}], "]"}]}]}]}], "}"}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"xmin", ",", "xmax"}], "}"}], ",", RowBox[{"{", RowBox[{"ymin", ",", "ymax"}], "}"}], ",", RowBox[{"{", RowBox[{"zmin", ",", "zmax"}], "}"}]}], "}"}]}]}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"stop", ",", "1", ",", "30", ",", "0.5"}], "}"}]}], "\[IndentingNewLine]", "]"}]}], "Input", CellChangeTimes->{{3.416897909568254*^9, 3.416897915475663*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Lorenz System", "Subsubtitle"], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"Clear", "[", RowBox[{"f", ",", "x"}], "]"}], "\n"}], RowBox[{"(*", RowBox[{ RowBox[{ RowBox[{"Note", " ", "that", " ", "the", " ", "x"}], "-", RowBox[{ "input", " ", "to", " ", "the", " ", "function", " ", "f", " ", "is", " ", "a", " ", "3"}], "-", RowBox[{"dimensional", " ", "vector"}]}], ",", RowBox[{ "and", " ", "the", " ", "output", " ", "of", " ", "f", " ", "is", " ", "one", " ", "as", " ", RowBox[{"well", "."}]}]}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{"\[Sigma]", "*", RowBox[{"(", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "2", "]"}], "]"}], "-", RowBox[{"x", "[", RowBox[{"[", "1", "]"}], "]"}]}], ")"}]}], ",", RowBox[{ RowBox[{"r", "*", RowBox[{"x", "[", RowBox[{"[", "1", "]"}], "]"}]}], "-", RowBox[{"x", "[", RowBox[{"[", "2", "]"}], "]"}], "-", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "1", "]"}], "]"}], "*", RowBox[{"x", "[", RowBox[{"[", "3", "]"}], "]"}]}]}], ",", RowBox[{ RowBox[{ RowBox[{"x", "[", RowBox[{"[", "1", "]"}], "]"}], "*", RowBox[{"x", "[", RowBox[{"[", "2", "]"}], "]"}]}], "-", RowBox[{"b", "*", RowBox[{"x", "[", RowBox[{"[", "3", "]"}], "]"}]}]}]}], "}"}]}], "\n"}], RowBox[{"(*", RowBox[{ "Assign", " ", "values", " ", "to", " ", "the", " ", "three", " ", RowBox[{"parameters", "."}]}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Sigma]", "=", "10"}], ";"}], "\n", RowBox[{ RowBox[{"b", "=", RowBox[{"8", "/", "3"}]}], ";"}], "\n", RowBox[{ RowBox[{ RowBox[{ RowBox[{"r", "=", "28"}], ";"}], "\n"}], RowBox[{"(*", RowBox[{ "Assign", " ", "initial", " ", "conditions", " ", "to", " ", "the", " ", "vector", " ", RowBox[{"x", "."}]}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"x0", "=", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], ";"}], "\n", RowBox[{ RowBox[{ RowBox[{ RowBox[{"t0", "=", "0"}], ";"}], "\n"}], RowBox[{"(*", RowBox[{ "Set", " ", "deltat", " ", "and", " ", "determine", " ", "how", " ", "many", " ", "future", " ", RowBox[{"points", "."}]}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"deltat", "=", "0.02"}], ";"}], "\n", RowBox[{ RowBox[{ RowBox[{ RowBox[{"n", "=", "2000"}], ";"}], "\n"}], RowBox[{"(*", RowBox[{"Initialize", " ", "pts", " ", "list"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"pts", "=", RowBox[{"{", "x0", "}"}]}], ";"}], "\n", RowBox[{ RowBox[{"xCurr", "=", "x0"}], ";"}], "\n", RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"k1", "=", RowBox[{"deltat", "*", RowBox[{"f", "[", "xCurr", "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"k2", "=", RowBox[{"deltat", "*", RowBox[{"f", "[", RowBox[{"xCurr", "+", RowBox[{"k1", "/", "2"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"k3", "=", RowBox[{"deltat", "*", RowBox[{"f", "[", RowBox[{"xCurr", "+", RowBox[{"k2", "/", "2"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"k4", "=", RowBox[{"deltat", "*", RowBox[{"f", "[", RowBox[{"xCurr", "+", "k3"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"xCurr", "=", RowBox[{"xCurr", "+", RowBox[{ RowBox[{"(", RowBox[{"k1", "+", RowBox[{"2", "*", "k2"}], "+", RowBox[{"2", "*", "k3"}], "+", "k4"}], ")"}], "/", "6"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"pts", ",", "xCurr"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "n"}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"(*", RowBox[{ RowBox[{ RowBox[{ "If", " ", "the", " ", "algorithm", " ", "is", " ", "modified", " ", "to", " ", "a", " ", "2"}], "-", RowBox[{"dimensional", " ", "flow"}]}], ",", RowBox[{"a", " ", "simple"}], ",", RowBox[{ "then", " ", "the", " ", "next", " ", "command", " ", "can", " ", "have", " ", "the", " ", "\"\<3D\>\"", " ", RowBox[{"removed", ".", "A"}], " ", "simple", " ", RowBox[{"ListPlot", "[", "]"}], " ", "would", " ", "suffice", " ", "as", " ", RowBox[{"well", "."}]}]}], "*)"}]}]}], "Input"], Cell[BoxData[{ RowBox[{ RowBox[{"xmin", " ", "=", RowBox[{"-", "20"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"xmax", " ", "=", " ", "22"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ymin", " ", "=", " ", RowBox[{"-", "23"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ymax", " ", "=", " ", "30"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"zmin", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"zmax", " ", "=", " ", "50"}], ";"}], "\[IndentingNewLine]", RowBox[{"Animate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Show", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Graphics3D", "[", RowBox[{"Line", "[", RowBox[{"pts", "[", RowBox[{"[", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "stop"}], "}"}]}], "]"}], "]"}], "]"}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Graphics3D", "[", RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0", ",", "0"}], "]"}], ",", RowBox[{"PointSize", "[", "0.03", "]"}], ",", RowBox[{"Point", "[", RowBox[{"pts", "[", RowBox[{"[", "stop", "]"}], "]"}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"xmin", ",", "xmax"}], "}"}], ",", RowBox[{"{", RowBox[{"ymin", ",", "ymax"}], "}"}], ",", RowBox[{"{", RowBox[{"zmin", ",", "zmax"}], "}"}]}], "}"}]}]}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"stop", ",", "5", ",", "n", ",", "5"}], "}"}]}], "\[IndentingNewLine]", "]"}]}], "Input", CellChangeTimes->{{3.4168979365950327`*^9, 3.41689793933424*^9}}] }, Open ]] }, WindowSize->{760, 813}, WindowMargins->{{257, Automatic}, {Automatic, 0}}, DockedCells->(FrontEndExecute[{ FrontEnd`NotebookApply[ FrontEnd`InputNotebook[], #, Placeholder]}]& ), FrontEndVersion->"6.0 for Mac OS X x86 (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, 47, 0, 26, "Subsubtitle"], Cell[640, 25, 2427, 66, 283, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[3104, 96, 77, 0, 26, "Subsubtitle"], Cell[3184, 98, 3429, 95, 328, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[6650, 198, 36, 0, 26, "Subsubtitle"], Cell[6689, 200, 4650, 143, 403, "Input"], Cell[11342, 345, 1926, 51, 223, "Input"] }, Open ]] } ] *) (* End of internal cache information *)