(* 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[ 38554, 920] NotebookOptionsPosition[ 37859, 896] NotebookOutlinePosition[ 38202, 911] CellTagsIndexPosition[ 38159, 908] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell["\<\ Jon Newman Sept 6 2008 The following is an implementation of the multipoint shooting algorithm for \ continuos flows applied to the Rossler Flow. This code is good for finding \ periodic orbits of that are 2-periodic or greater.\ \>", "Text", CellChangeTimes->{{3.4323054295360003`*^9, 3.432305483946*^9}, { 3.4343835898166*^9, 3.4343836167536*^9}, {3.4343847352326*^9, 3.4343847367966003`*^9}}], Cell[TextData[{ StyleBox["Function 1: CycleEstimateRossler\n", FontWeight->"Bold"], "This function takes a set of initial guesses on a specified \ Poincar\[EAcute] section and runs each of them for one return to that \ section. It simultaneously records the deformation of a sphere surrounding \ each initial guess during its time evolution. This provides the MPS \ algorithm with an initial guess and information about how that a change to \ that guess will affect the resulting end point after a single return." }], "Text", CellChangeTimes->{{3.4323054295360003`*^9, 3.432305483946*^9}, { 3.4343818084556*^9, 3.4343818437335997`*^9}, {3.4343819769316*^9, 3.4343820061085997`*^9}, {3.4343821187046003`*^9, 3.4343822417736*^9}, { 3.4343847423096*^9, 3.4343847487576*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"cycleEstimateRossler", "[", RowBox[{"a_", ",", "b_", ",", "c_", ",", "guess_"}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"state", " ", RowBox[{"equations", ":", " ", RowBox[{"Rossler", " ", "Flow"}]}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dxdt", "=", RowBox[{ RowBox[{ RowBox[{"x", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{ RowBox[{"-", RowBox[{"y", "[", "t", "]"}]}], "-", RowBox[{"z", "[", "t", "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"dydt", "=", RowBox[{ RowBox[{ RowBox[{"y", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{ RowBox[{"x", "[", "t", "]"}], "+", RowBox[{"a", "*", RowBox[{"y", "[", "t", "]"}]}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"dzdt", "=", RowBox[{ RowBox[{ RowBox[{"z", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{"b", "+", RowBox[{ RowBox[{"z", "[", "t", "]"}], "*", RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "-", "c"}], ")"}]}]}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{ "evolution", " ", "operators", " ", "of", " ", "fundamental", " ", RowBox[{"matrix", ":", " ", OverscriptBox["J", "\[Degree]"]}]}], "=", "AJ"}], "*)"}], "\n", " ", RowBox[{"dm11", "=", RowBox[{ RowBox[{ RowBox[{"m11", "'"}], "[", "t", "]"}], "==", RowBox[{ RowBox[{"-", RowBox[{"m21", "[", "t", "]"}]}], "-", RowBox[{"m31", "[", "t", "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"dm12", "=", RowBox[{ RowBox[{ RowBox[{"m12", "'"}], "[", "t", "]"}], "==", RowBox[{ RowBox[{"-", RowBox[{"m22", "[", "t", "]"}]}], "-", RowBox[{"m32", "[", "t", "]"}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"dm13", "=", RowBox[{ RowBox[{ RowBox[{"m13", "'"}], "[", "t", "]"}], "==", RowBox[{ RowBox[{"-", RowBox[{"m23", "[", "t", "]"}]}], "-", RowBox[{"m33", "[", "t", "]"}]}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"dm21", "=", RowBox[{ RowBox[{ RowBox[{"m21", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{ RowBox[{"m11", "[", "t", "]"}], "+", RowBox[{"a", "*", RowBox[{"m21", "[", "t", "]"}]}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"dm22", "=", RowBox[{ RowBox[{ RowBox[{"m22", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{ RowBox[{"m12", "[", "t", "]"}], "+", RowBox[{"a", "*", RowBox[{"m22", "[", "t", "]"}]}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"dm23", "=", RowBox[{ RowBox[{ RowBox[{"m23", "'"}], "[", "t", "]"}], "\[Equal]", RowBox[{ RowBox[{"m13", "[", "t", "]"}], "+", RowBox[{"a", "*", RowBox[{"m23", "[", "t", "]"}]}]}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"dm31", "=", RowBox[{ RowBox[{ RowBox[{"m31", "'"}], "[", "t", "]"}], "==", RowBox[{ RowBox[{ RowBox[{"z", "[", "t", "]"}], "*", RowBox[{"m11", "[", "t", "]"}]}], "+", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "-", "c"}], ")"}], "*", RowBox[{"m31", "[", "t", "]"}]}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"dm32", "=", RowBox[{ RowBox[{ RowBox[{"m32", "'"}], "[", "t", "]"}], "==", RowBox[{ RowBox[{ RowBox[{"z", "[", "t", "]"}], "*", RowBox[{"m12", "[", "t", "]"}]}], "+", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "-", "c"}], ")"}], "*", RowBox[{"m32", "[", "t", "]"}]}]}]}]}], ";", "\[IndentingNewLine]", RowBox[{"dm33", "=", RowBox[{ RowBox[{ RowBox[{"m33", "'"}], "[", "t", "]"}], "==", RowBox[{ RowBox[{ RowBox[{"z", "[", "t", "]"}], "*", RowBox[{"m13", "[", "t", "]"}]}], "+", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"x", "[", "t", "]"}], "-", "c"}], ")"}], "*", RowBox[{"m33", "[", "t", "]"}]}]}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"storage", ":", " ", RowBox[{ "points", " ", "from", " ", "the", " ", "poincare", " ", "section"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"sect", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"storage", ":", " ", RowBox[{ "Fundemental", " ", "matrix", " ", "at", " ", "time", " ", "of", " ", "poincare", " ", "section", " ", "crossing"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"Jmatrix", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "Here", " ", "we", " ", "test", " ", "the", " ", "performance", " ", "of", " ", "the", " ", "intial", " ", "guesses", " ", "by", " ", "numerically", " ", "integrating", " ", "each", " ", "for", " ", "a", " ", "single", " ", RowBox[{"return", ".", " ", "This"}], " ", "gives", " ", "us", " ", "a", " ", "set", " ", "of", " ", "errors", " ", "that", " ", "can", " ", "be", " ", "simultaneiously", " ", "minimized", " ", "in", " ", "the", " ", "MPSM", " ", "newton", " ", RowBox[{"routine", "."}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"xinit", ",", "yinit", ",", "zinit"}], "}"}], "=", "j"}], ";", "\[IndentingNewLine]", RowBox[{"sol", "=", RowBox[{"NDSolve", "[", RowBox[{"(*", "RK4", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{ "dxdt", ",", "dydt", ",", "dzdt", ",", "\[IndentingNewLine]", "dm11", ",", "dm12", ",", "dm13", ",", "\[IndentingNewLine]", "dm21", ",", "dm22", ",", "dm23", ",", "\[IndentingNewLine]", "dm31", ",", "dm32", ",", "dm33", ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "[", "0", "]"}], "\[Equal]", "xinit"}], ",", RowBox[{ RowBox[{"y", "[", "0", "]"}], "\[Equal]", "yinit"}], ",", RowBox[{ RowBox[{"z", "[", "0", "]"}], "\[Equal]", "zinit"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"m11", "[", "0", "]"}], "\[Equal]", "1"}], ",", RowBox[{ RowBox[{"m13", "[", "0", "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"m12", "[", "0", "]"}], "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"m21", "[", "0", "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"m22", "[", "0", "]"}], "\[Equal]", "1"}], ",", RowBox[{ RowBox[{"m23", "[", "0", "]"}], "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"m31", "[", "0", "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"m32", "[", "0", "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{"m33", "[", "0", "]"}], "\[Equal]", "1"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ "x", ",", "y", ",", "z", ",", "m11", ",", "m12", ",", "m13", ",", "m21", ",", "m22", ",", "m23", ",", "m31", ",", "m32", ",", "m33"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"t", ",", "0", ",", "1000"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"MaxSteps", "\[Rule]", "Infinity"}], ",", "\[IndentingNewLine]", RowBox[{"MaxStepSize", "\[Rule]", "0.01"}], ",", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"EventLocator", " ", "is", " ", RowBox[{"Mathematica", "'"}], "s", " ", "even", " ", "finding", " ", "system", " ", "for", " ", "numerical", " ", "integration"}], "*)"}], "\[IndentingNewLine]", RowBox[{"Method", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"poincare", " ", RowBox[{"section", ":", " ", RowBox[{"x", "[", "t", "]"}]}]}], "=", "0"}], "*)"}], "\[IndentingNewLine]", RowBox[{"\"\\"", "\[Rule]", RowBox[{"x", "[", "t", "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"Orientation", " ", RowBox[{"condition", ":", " ", RowBox[{ RowBox[{ "only", " ", "record", " ", "section", " ", "point", " ", "for", " ", RowBox[{ SubscriptBox["\[PartialD]", "t"], "x"}]}], ">", RowBox[{"0", " ", "at", " ", "crossing"}]}]}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"Direction", "\[Rule]", RowBox[{"-", "1"}]}], ",", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "EvenAction", " ", "says", " ", "what", " ", "to", " ", "do", " ", "when", " ", "even", " ", "criteria", " ", "are", " ", "met"}], "*)"}], "\[IndentingNewLine]", RowBox[{"EventAction", "\[RuleDelayed]", RowBox[{"Throw", "[", RowBox[{ RowBox[{"{", RowBox[{"AppendTo", "[", RowBox[{"sect", ",", RowBox[{"{", RowBox[{ RowBox[{"x", "[", "t", "]"}], ",", RowBox[{"y", "[", "t", "]"}], ",", RowBox[{"z", "[", "t", "]"}]}], "}"}]}], "]"}], "}"}], ",", "\"\\""}], "]"}]}]}], "}"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "find", " ", "the", " ", "total", " ", "time", " ", "of", " ", "the", " ", "run", " ", "up", " ", "to", " ", "the", " ", "even"}], "*)"}], "\[IndentingNewLine]", RowBox[{"tOfRun", "=", RowBox[{ RowBox[{"(", RowBox[{"x", "/.", RowBox[{"sol", "[", RowBox[{"[", RowBox[{"1", ",", "1"}], "]"}], "]"}]}], ")"}], "[", RowBox[{"[", RowBox[{"1", ",", "1", ",", "2"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "find", " ", "the", " ", "total", " ", "time", " ", "of", " ", "the", " ", "run", " ", "up", " ", "to", " ", "the", " ", "even"}], "*)"}], "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"Jmatrix", ",", RowBox[{"Flatten", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"m11", "[", "tOfRun", "]"}], ",", RowBox[{"m12", "[", "tOfRun", "]"}], ",", RowBox[{"m13", "[", "tOfRun", "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"m21", "[", "tOfRun", "]"}], ",", RowBox[{"m22", "[", "tOfRun", "]"}], ",", RowBox[{"m23", "[", "tOfRun", "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"m31", "[", "tOfRun", "]"}], ",", RowBox[{"m32", "[", "tOfRun", "]"}], ",", RowBox[{"m33", "[", "tOfRun", "]"}]}], "}"}]}], "}"}], "/.", "sol"}], ",", "1"}], "]"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"j", ",", "guess"}], "}"}]}], "]"}], ";", RowBox[{"(*", RowBox[{ RowBox[{ "repeat", " ", "one", " ", "period", " ", "of", " ", "for", " ", "every", " ", "j"}], " ", "\[Element]", " ", RowBox[{"initial", " ", "guess"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"{", RowBox[{"Jmatrix", ",", "sect"}], "}"}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.432300254602*^9, 3.432300462955*^9}, { 3.4323005151210003`*^9, 3.432300534039*^9}, {3.432300590785*^9, 3.432300667742*^9}, {3.432301114192*^9, 3.432301114906*^9}, { 3.432301146208*^9, 3.432301185953*^9}, {3.432302385449*^9, 3.432302388491*^9}, {3.432303250774*^9, 3.432303253374*^9}, 3.4323033673859997`*^9, {3.4343810124376*^9, 3.4343810762896*^9}, { 3.4343811214656*^9, 3.4343817987376003`*^9}, 3.4343831827595997`*^9}], Cell[TextData[StyleBox["######################################################\ ##########################################################\nFrom here on code \ should be easily generalizable to any continuous flow\n\ ##############################################################################\ ##################################", FontWeight->"Bold"]], "Text", CellChangeTimes->{{3.4343822597046003`*^9, 3.4343823359476*^9}, { 3.4343823675506*^9, 3.4343826828976*^9}, {3.4343829934196*^9, 3.4343830356666*^9}, 3.4343847518526*^9}], Cell[TextData[{ StyleBox["Function 2 : MConstructRossler", FontWeight->"Bold"], "\nThis function constructs a matrix, M, that essentially allows a single \ newton method to be run for each periodic portion of an n-periodic cycle. \ The logic is this: the end point at the section after time evolution of a", Cell[BoxData[ FormBox[ RowBox[{" ", RowBox[{ RowBox[{ SubscriptBox["j", "1"], "\[Element]", RowBox[{"{", RowBox[{"initial", " ", "guess"}], "}"}]}], " ", "=", SubscriptBox["j", "2"]}]}], TraditionalForm]]], ", the end point of ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ SubscriptBox["j", "2"], "\[Element]", RowBox[{"{", RowBox[{"initial", " ", "guess"}], "}"}]}], " ", "=", SubscriptBox["j", "3"]}], TraditionalForm]]], "...the end point of ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ SubscriptBox["j", "n"], "\[Element]", RowBox[{"{", RowBox[{"initial", " ", "guess"}], "}"}]}], " ", "=", SubscriptBox["j", "1"]}], TraditionalForm]]], ". Each of these allows us to correct an error that is the dimension using \ a separate Newton routine. The amount of change to each initial guess is a \ function of the deformation matrices calculated in the previous function." }], "Text", CellChangeTimes->{{3.4343822597046003`*^9, 3.4343823359476*^9}, { 3.4343823675506*^9, 3.4343826828976*^9}, {3.4343831335346003`*^9, 3.4343831701126003`*^9}, {3.4343833689226*^9, 3.4343833706006002`*^9}, { 3.4343847563106003`*^9, 3.4343847698486*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", RowBox[{ "Function", " ", "to", " ", "create", " ", "M", " ", "Matrix", " ", "by", " ", "constructing", " ", "its", " ", "four", " ", "blocks", " ", "and", " ", "the", " ", "concatinating"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"MConstructRossler", "[", RowBox[{ "n_", ",", "JM_", ",", "guess_", ",", "aMat_", ",", "a_", ",", "b_", ",", "c_"}], "]"}], ":=", RowBox[{"(*", RowBox[{ RowBox[{"cycle", "-", "length"}], ",", "J", ",", " ", RowBox[{"guess", " ", "placement"}], ",", "A", ",", "a", ",", "b", ",", "c"}], "*)"}], "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"nullSeed", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"3", ",", RowBox[{ RowBox[{"(", RowBox[{"n", "-", "2"}], ")"}], "*", "3"}]}], "}"}]}], "]"}]}], ";", "\n", "\t", RowBox[{"upperleft", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"piece", "=", RowBox[{"RotateRight", "[", RowBox[{ RowBox[{"Join", "[", RowBox[{ RowBox[{"-", RowBox[{"JM", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"IdentityMatrix", "[", "3", "]"}], ",", "nullSeed", ",", "2"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{ RowBox[{"(", RowBox[{"3", "*", "i"}], ")"}], "-", "3"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"upperleft", ",", "piece"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"n", "-", "1"}]}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"PrependTo", "[", RowBox[{"upperleft", ",", RowBox[{"Join", "[", RowBox[{ RowBox[{"IdentityMatrix", "[", "3", "]"}], ",", "nullSeed", ",", RowBox[{"-", RowBox[{"JM", "[", RowBox[{"[", "n", "]"}], "]"}]}], ",", "2"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"UL", "=", RowBox[{"Flatten", "[", RowBox[{"upperleft", ",", "1"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"lowerleft", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"piece", "=", RowBox[{"RotateRight", "[", RowBox[{ RowBox[{"Join", "[", RowBox[{"aMat", ",", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{ RowBox[{"(", RowBox[{"n", "-", "1"}], ")"}], "*", "3"}]}], "]"}]}], "]"}], ",", RowBox[{ RowBox[{"(", RowBox[{"3", "*", "i"}], ")"}], "-", "3"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"lowerleft", ",", "piece"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"LL", "=", "lowerleft"}], ";", "\[IndentingNewLine]", RowBox[{"upperright", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"piece", "=", RowBox[{"RotateRight", "[", RowBox[{ RowBox[{"Join", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", RowBox[{"guess", "[", RowBox[{"[", RowBox[{"i", ",", "2"}], "]"}], "]"}]}], "-", RowBox[{"guess", "[", RowBox[{"[", RowBox[{"i", ",", "3"}], "]"}], "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"guess", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "+", RowBox[{"a", "*", RowBox[{"guess", "[", RowBox[{"[", RowBox[{"i", ",", "2"}], "]"}], "]"}]}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"b", "+", RowBox[{ RowBox[{"guess", "[", RowBox[{"[", RowBox[{"i", ",", "3"}], "]"}], "]"}], "*", RowBox[{"(", RowBox[{ RowBox[{"guess", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "-", "c"}], ")"}]}]}], "}"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"3", ",", RowBox[{"(", RowBox[{"n", "-", "1"}], ")"}]}], "}"}]}], "]"}], ",", "2"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"i", "-", "1"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"upperright", ",", "piece"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"UR", "=", RowBox[{"Flatten", "[", RowBox[{"upperright", ",", "1"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"LR", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"n", ",", "n"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"M", "=", RowBox[{ RowBox[{"Join", "[", RowBox[{"UL", ",", "UR", ",", "2"}], "]"}], "~", "Join", "~", RowBox[{"Join", "[", RowBox[{"LL", ",", "LR", ",", "2"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", "M", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]}]], "Input", CellChangeTimes->{{3.432132993561*^9, 3.432132997969*^9}, {3.432135184887*^9, 3.4321352875150003`*^9}, {3.432135578322*^9, 3.432135681427*^9}, { 3.4321357138970003`*^9, 3.432135725374*^9}, {3.432135757752*^9, 3.4321358576210003`*^9}, {3.432135921891*^9, 3.432135943051*^9}, { 3.432136503376*^9, 3.4321365300690002`*^9}, {3.432136615269*^9, 3.432136679936*^9}, {3.432139642038*^9, 3.432139658866*^9}, { 3.432139724901*^9, 3.432139730072*^9}, {3.432139769087*^9, 3.4321398139230003`*^9}, {3.432140084834*^9, 3.432140102527*^9}, 3.432140251641*^9, 3.432146960592*^9, {3.432148738324*^9, 3.432148755376*^9}, {3.4321489049700003`*^9, 3.432148915446*^9}, { 3.432149625951*^9, 3.4321496461730003`*^9}, {3.432149832778*^9, 3.432149850656*^9}, {3.432162316267*^9, 3.432162323449*^9}, { 3.4321648692460003`*^9, 3.432164882993*^9}, {3.432164926282*^9, 3.432164956008*^9}, {3.432300748553*^9, 3.432300864844*^9}, { 3.43230115669*^9, 3.432301159175*^9}, 3.432301502948*^9, { 3.432301851648*^9, 3.432301859245*^9}, {3.432302706769*^9, 3.4323027114189997`*^9}, {3.432303675704*^9, 3.4323037032390003`*^9}, { 3.432303803983*^9, 3.432303844898*^9}, {3.432303919814*^9, 3.432303934527*^9}, {3.432304490355*^9, 3.432304497959*^9}, { 3.4343822824896*^9, 3.4343822826386003`*^9}, {3.4343826960246*^9, 3.4343827770456*^9}}], Cell[TextData[{ StyleBox["Function 3 : FConstructRossler", FontWeight->"Bold"], "\nThis is a 1 X n*d matrix that calculates the error between the Poincar\ \[EAcute] crossing point of evolution of guess[i] and the location of \ guess[i+1] for each of the d dimensions." }], "Text", CellChangeTimes->{{3.4343822597046003`*^9, 3.4343823359476*^9}, { 3.4343823675506*^9, 3.4343826828976*^9}, {3.4343830604496*^9, 3.4343831218276*^9}, {3.4343832153036003`*^9, 3.4343832719536*^9}, 3.4343833765926*^9, {3.4343847749786*^9, 3.4343847778666*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", RowBox[{"Function", " ", "to", " ", "create", " ", "F", " ", "matrix"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"FConstructRossler", "[", RowBox[{"guess_", ",", "sec_", ",", "n_"}], "]"}], ":=", RowBox[{"(*", RowBox[{ RowBox[{"array", " ", "of", " ", "guesses"}], ",", " ", RowBox[{"the", " ", "numerically", " ", "calculated", " ", "section"}], ",", " ", RowBox[{"cycle", "-", "length"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"F", "=", RowBox[{"{", RowBox[{ RowBox[{"guess", "[", RowBox[{"[", "1", "]"}], "]"}], "-", RowBox[{"sec", "[", RowBox[{"[", "n", "]"}], "]"}]}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"diff", "=", RowBox[{"(", RowBox[{ RowBox[{"guess", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{"sec", "[", RowBox[{"[", RowBox[{"i", "-", "1"}], "]"}], "]"}]}], ")"}]}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"F", ",", "diff"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"i", ",", "2", ",", "n"}], "}"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"F", ",", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", "n"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"F", "=", RowBox[{"Flatten", "[", "F", "]"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]}]], "Input", CellChangeTimes->{{3.4321400630690002`*^9, 3.432140115771*^9}, { 3.4321402298859997`*^9, 3.432140426126*^9}, {3.43214050375*^9, 3.432140515414*^9}, {3.432140562553*^9, 3.432140564277*^9}, { 3.4321406279119997`*^9, 3.4321406287130003`*^9}, 3.43214070002*^9, { 3.43214182535*^9, 3.4321418282279997`*^9}, {3.432141871217*^9, 3.432141871415*^9}, {3.4321419095559998`*^9, 3.43214194208*^9}, { 3.432141994311*^9, 3.4321419976470003`*^9}, {3.432142028566*^9, 3.432142028731*^9}, {3.432142075914*^9, 3.4321422472209997`*^9}, { 3.432142293598*^9, 3.4321423035299997`*^9}, {3.4321423418710003`*^9, 3.4321424208450003`*^9}, {3.4321430642799997`*^9, 3.4321430644969997`*^9}, {3.432144579082*^9, 3.432144581001*^9}, { 3.432144681334*^9, 3.4321447043570004`*^9}, {3.4321447630439997`*^9, 3.432144767083*^9}, 3.4321476290030003`*^9, {3.4323009369890003`*^9, 3.43230097387*^9}, {3.4323010163190002`*^9, 3.432301038269*^9}, { 3.432302816415*^9, 3.432302820039*^9}, {3.432303405229*^9, 3.4323034127799997`*^9}, {3.432304036186*^9, 3.432304037098*^9}, { 3.432305027699*^9, 3.4323050445550003`*^9}, {3.432305177079*^9, 3.432305182329*^9}, {3.432305253712*^9, 3.432305253948*^9}, { 3.4343832781666*^9, 3.4343832976626*^9}}], Cell[TextData[{ StyleBox["Function 4 : VarConstruct", FontWeight->"Bold"], "\nMake an array of variables to solve for. Because this is Mathematica I \ can leave these variables in symbol form." }], "Text", CellChangeTimes->{{3.4343822597046003`*^9, 3.4343823359476*^9}, { 3.4343823675506*^9, 3.4343826828976*^9}, {3.4343830604496*^9, 3.4343831218276*^9}, {3.4343832153036003`*^9, 3.4343832719536*^9}, { 3.4343833149606*^9, 3.4343833792246*^9}, 3.4343847812176*^9}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"VarConstruct", "[", "n_", "]"}], ":=", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"DM", "=", RowBox[{ RowBox[{ RowBox[{"ToExpression", "[", RowBox[{"\"\\"", "<>", RowBox[{"ToString", "[", "#", "]"}]}], "]"}], "&"}], "/@", RowBox[{"Range", "[", RowBox[{ RowBox[{"3", "*", "n"}], "+", "n"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", "DM", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.432142674148*^9, 3.4321426972869997`*^9}, { 3.432142729752*^9, 3.4321427332609997`*^9}, {3.432142784449*^9, 3.4321428465179996`*^9}, {3.432142917584*^9, 3.432142918653*^9}, { 3.4321429598120003`*^9, 3.432142963783*^9}, {3.432145922898*^9, 3.4321459266809998`*^9}, {3.432146930506*^9, 3.432146932994*^9}}], Cell[TextData[{ StyleBox["Function 5 : MPSA", FontWeight->"Bold"], "\nThis is the fully implemented algorithm for the Rossler flow:\n1. create \ section from initial guesses. Record deformation under the flow of the \ initial guesses.\n2. Construct M matrix\n3.Construct F (error) matrix\n4. \ Construct variable matrix\n5. Create n*d equations\n6. Solve for n*d \ variables to find the change in initial guess. Use guess+=change as your new \ guess and repeat until convergence." }], "Text", CellChangeTimes->{{3.4343822597046003`*^9, 3.4343823359476*^9}, { 3.4343823675506*^9, 3.4343826828976*^9}, {3.4343830604496*^9, 3.4343831218276*^9}, {3.4343832153036003`*^9, 3.4343832719536*^9}, { 3.4343833149606*^9, 3.4343833506516*^9}, {3.4343833810576*^9, 3.4343835497506*^9}, {3.4343847836745996`*^9, 3.4343848036336*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", RowBox[{"Full", " ", "Multipoint", " ", "Shooting", " ", "Algorithm"}], "*)"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"input", " ", "is", " ", RowBox[{"guess", ":", " ", RowBox[{"initial", " ", "guess"}]}]}], ",", " ", RowBox[{"cl", ":", " ", RowBox[{"cycle", " ", "length"}]}], ",", " ", RowBox[{"n", ":", " ", RowBox[{"num", " ", "interations", "*", "\[IndentingNewLine]", "*", RowBox[{"normvec", ":", " ", RowBox[{"vector", " ", "normal", " ", "to", " ", "section"}]}]}]}], ",", " ", "a", ",", " ", RowBox[{"b", " ", "and", " ", RowBox[{"c", ":", " ", RowBox[{"parameters", " ", "for", " ", "Rossler", " ", "flow"}]}]}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"MPSA", "[", RowBox[{ "guess_", ",", "cl_", ",", "n_", ",", "normvec_", ",", "a_", ",", "b_", ",", "c_"}], "]"}], ":=", RowBox[{"(*", RowBox[{"guess", ",", " ", RowBox[{"cycle", " ", "length"}], ",", RowBox[{"number", " ", "of", " ", "revisions"}], ",", RowBox[{ "unit", " ", "vector", " ", "normal", " ", "to", " ", "the", " ", "section"}], ",", "a", ",", "b", ",", "c"}], "*)"}], "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"g", "=", "guess"}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"jm", ",", "section"}], "}"}], "=", RowBox[{"cycleEstimateRossler", "[", RowBox[{"a", ",", "b", ",", "c", ",", "g"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Mmat", "=", RowBox[{"MConstructRossler", "[", RowBox[{ "cl", ",", "jm", ",", "g", ",", "normvec", ",", "a", ",", "b", ",", "c"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Fmat", "=", RowBox[{"FConstructRossler", "[", RowBox[{"g", ",", "section", ",", "cl"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Dmat", "=", RowBox[{"VarConstruct", "[", "cl", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dotProd", "=", RowBox[{"Mmat", ".", "Dmat"}]}], ";", "\[IndentingNewLine]", RowBox[{"eqs", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"dotProd", "[", RowBox[{"[", "i", "]"}], "]"}], "\[Equal]", RowBox[{"-", RowBox[{"Fmat", "[", RowBox[{"[", "i", "]"}], "]"}]}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "dotProd", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"deltaPos", "=", RowBox[{"Solve", "[", RowBox[{"eqs", ",", "DM"}], "]"}]}], ";", RowBox[{"(*", RowBox[{ "this", " ", "line", " ", "is", " ", "why", " ", "Mathematica", " ", "is", " ", RowBox[{"nice", ".", " ", "I"}], " ", "have", " ", "used", " ", "its", " ", "symbolic", " ", "capabilites", " ", "to", " ", "solve", " ", "this", " ", "set", " ", "of", " ", RowBox[{"equations", ".", " ", "In"}], " ", "matlab", " ", "one", " ", "would", " ", "have", " ", "to", " ", "due", " ", "some", " ", "actual", " ", "inversions", " ", "and", " ", RowBox[{"stuff", ".", " ", "see"}], " ", "the", " ", "book"}], "*)"}], "\[IndentingNewLine]", RowBox[{"g", "+=", RowBox[{"Partition", "[", RowBox[{ RowBox[{"Drop", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"DM", "/.", "deltaPos"}], "]"}], ",", RowBox[{"-", "cl"}]}], "]"}], ",", "3"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", "g", "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", "n", "}"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]}]], "Input", CellChangeTimes->{{3.432301091175*^9, 3.432301098084*^9}, {3.432301231808*^9, 3.4323012894*^9}, {3.4323013512139997`*^9, 3.432301603473*^9}, { 3.432301871844*^9, 3.4323018756099997`*^9}, 3.432301911026*^9, { 3.432302005284*^9, 3.4323020121879997`*^9}, {3.432302050914*^9, 3.4323020881470003`*^9}, {3.432302148791*^9, 3.432302158297*^9}, { 3.432302288153*^9, 3.432302300047*^9}, {3.432303026775*^9, 3.432303072461*^9}, 3.432303120984*^9, {3.432303443748*^9, 3.432303485038*^9}, {3.432303530264*^9, 3.432303542109*^9}, { 3.4323036360950003`*^9, 3.432303648508*^9}, 3.432303714224*^9, { 3.432303993653*^9, 3.432303995125*^9}, {3.432304040958*^9, 3.4323040611549997`*^9}, {3.432305120343*^9, 3.432305123909*^9}, { 3.432305188243*^9, 3.4323051902*^9}, {3.432305276481*^9, 3.4323052779890003`*^9}, {3.432305492627*^9, 3.4323055818710003`*^9}, 3.432305856138*^9, {3.432306316856*^9, 3.4323063263129997`*^9}, { 3.4343828252016*^9, 3.4343828973176003`*^9}, {3.4343840205066*^9, 3.4343840705216*^9}}] }, WindowSize->{874, 597}, WindowMargins->{{Automatic, -80}, {Automatic, -27}}, 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[568, 21, 412, 9, 83, "Text"], Cell[983, 32, 785, 13, 83, "Text"], Cell[1771, 47, 14067, 336, 1232, "Input"], Cell[15841, 385, 542, 8, 65, "Text"], Cell[16386, 395, 1567, 40, 101, "Text"], Cell[17956, 437, 8358, 199, 612, "Input"], Cell[26317, 638, 555, 10, 65, "Text"], Cell[26875, 650, 3234, 71, 272, "Input"], Cell[30112, 723, 480, 9, 47, "Text"], Cell[30595, 734, 1009, 24, 112, "Input"], Cell[31607, 760, 835, 14, 155, "Text"], Cell[32445, 776, 5410, 118, 432, "Input"] } ] *) (* End of internal cache information *)