(* 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[ 30732, 1071] NotebookOptionsPosition[ 26687, 940] NotebookOutlinePosition[ 27100, 958] CellTagsIndexPosition[ 27057, 955] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["3D Walks", "Title"], Cell["\<\ A.P. 1601 Columbia University\ \>", "Subsubtitle"], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell[TextData[{ "In this notebook, we extend the results of ", StyleBox["6-RandomWalks.nb", FontSlant->"Italic"], " and ", StyleBox["7-SelfAvoiding Walks.nb", FontSlant->"Italic"], " from 2D to 3D." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Off", "[", RowBox[{"General", "::", "spell1"}], "]"}], ";"}]], "Input", CellLabel->"In[1]:="] }, Closed]], Cell[CellGroupData[{ Cell["Random Walks", "Section"], Cell[BoxData[ RowBox[{ RowBox[{"walk3D", "[", "n_", "]"}], ":=", RowBox[{"NestList", "[", RowBox[{ RowBox[{ RowBox[{"#1", "+", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0", ",", "0"}], "}"}]}], "}"}], "\[LeftDoubleBracket]", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "6"}], "}"}], "]"}], "\[RightDoubleBracket]"}]}], "&"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",", "n"}], "]"}]}]], "Input", CellLabel->"In[2]:="], Cell[BoxData[ RowBox[{ RowBox[{"showWalk3D", "[", RowBox[{"pts_List", ",", "opts___"}], "]"}], " ", ":=", " ", RowBox[{"Show", "[", RowBox[{"Graphics3D", "[", RowBox[{ RowBox[{"Line", "[", "pts", "]"}], ",", "opts", ",", RowBox[{"AspectRatio", "\[Rule]", " ", "Automatic"}]}], "]"}], "]"}]}]], "Input", CellLabel->"In[3]:="], Cell[BoxData[ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"awalk", " ", "=", " ", RowBox[{"walk3D", "[", "50000", "]"}]}], ";"}], ")"}], " ", "//", " ", "Timing"}]], "Input", CellLabel->"In[4]:="], Cell[BoxData[ RowBox[{ RowBox[{"showWalk3D", "[", RowBox[{"awalk", ",", " ", RowBox[{"Axes", "\[Rule]", " ", "True"}]}], "]"}], ";"}]], "Input", CellLabel->"In[5]:="], Cell[CellGroupData[{ Cell["Statistics in Three-Dimensions", "Subsection"], Cell[BoxData[ RowBox[{ RowBox[{"Needs", "[", "\"\\"", "]"}], ";"}]], "Input", CellLabel->"In[6]:="], Cell[BoxData[{ RowBox[{ RowBox[{"nWalkers", " ", "=", " ", "1000"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"walkList", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"walk3D", "[", "500", "]"}], ",", RowBox[{"{", "nWalkers", "}"}]}], "]"}]}], ";"}]}], "Input", CellLabel->"In[7]:="], Cell[BoxData[ RowBox[{"walkList", " ", "//", " ", "Shallow", " ", RowBox[{"(*", " ", RowBox[{"1000", " ", "walks", " ", "500", " ", "steps", " ", "long"}], " ", "*)"}]}]], "Input", CellLabel->"In[9]:="], Cell[CellGroupData[{ Cell["Average position (\"center of mass\")", "Subsubsection"], Cell[BoxData[ RowBox[{ RowBox[{"avgXYZ", "[", "walkers_List", "]"}], " ", ":=", " ", RowBox[{"N", "[", RowBox[{ RowBox[{"(", RowBox[{"Plus", " ", "@@", " ", "walkers"}], ")"}], "/", RowBox[{"Length", "[", "walkers", "]"}]}], "]"}]}]], "Input", CellLabel->"In[10]:="], Cell[BoxData[ RowBox[{ RowBox[{"avgXYZList", " ", "=", " ", RowBox[{"avgXYZ", " ", "/@", " ", RowBox[{"Transpose", "[", "walkList", "]"}]}]}], ";"}]], "Input", CellLabel->"In[11]:="], Cell[BoxData[ RowBox[{"avgXYZList", " ", "//", " ", "Shallow"}]], "Input", CellLabel->"In[12]:="], Cell[BoxData[ RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "avgXYZList", "]"}], "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[13]:="], Cell["\<\ The average position of all walkers remains near the orgin (as expected).\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Average radius", "Subsubsection"], Cell[BoxData[ RowBox[{ RowBox[{"radius", "[", RowBox[{"{", RowBox[{"x_", ",", " ", "y_", ",", " ", "z_"}], "}"}], "]"}], " ", ":=", " ", RowBox[{"Sqrt", "[", RowBox[{"N", "[", RowBox[{ RowBox[{"x", "^", "2"}], " ", "+", " ", RowBox[{"y", "^", "2"}], " ", "+", " ", RowBox[{"z", "^", "2"}]}], "]"}], "]"}]}]], "Input", CellLabel->"In[14]:="], Cell[BoxData[ RowBox[{ RowBox[{"rList", " ", "=", " ", RowBox[{"Map", "[", RowBox[{"radius", ",", " ", "walkList", ",", RowBox[{"{", "2", "}"}]}], "]"}]}], ";"}]], "Input", CellLabel->"In[15]:="], Cell[BoxData[{ RowBox[{ RowBox[{"avgR", "=", RowBox[{"Mean", "/@", RowBox[{"Transpose", "[", "rList", "]"}]}]}], ";"}], "\n", RowBox[{"ListPlot", "[", "avgR", "]"}]}], "Input", CellLabel->"In[16]:="] }, Closed]], Cell[CellGroupData[{ Cell["Modeling average radius per step", "Subsubsection"], Cell["\<\ The average radius increases at a power-law of the number of steps.\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"rData", "=", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"N", "[", RowBox[{"Log", "[", "n", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "2", ",", RowBox[{"Length", "[", "avgR", "]"}]}], "}"}]}], "]"}], ",", RowBox[{"N", "[", RowBox[{"Log", "[", RowBox[{"Drop", "[", RowBox[{"avgR", ",", "1"}], "]"}], "]"}], "]"}]}], "}"}], "]"}]}], ";"}], "\n", RowBox[{"ListPlot", "[", RowBox[{"rData", ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]}], "Input", CellLabel->"In[18]:="], Cell[BoxData[ RowBox[{"power", " ", "=", " ", RowBox[{"Fit", "[", RowBox[{"rData", ",", RowBox[{"{", "x", "}"}], ",", " ", "x"}], "]"}]}]], "Input", CellLabel->"In[20]:="], Cell[TextData[{ "Therefore, \[LeftAngleBracket]", StyleBox["r", FontSlant->"Italic"], "\[RightAngleBracket] ~ ", Cell[BoxData[ FormBox[ SqrtBox["n"], TraditionalForm]]], "." }], "Text"] }, Closed]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["4D Walking", "Section"], Cell[BoxData[ RowBox[{ RowBox[{"walk4D", "[", "n_", "]"}], ":=", RowBox[{"NestList", "[", RowBox[{ RowBox[{ RowBox[{"#1", "+", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "1"}], ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0", ",", "0", ",", "0"}], "}"}]}], "}"}], "\[LeftDoubleBracket]", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "8"}], "}"}], "]"}], "\[RightDoubleBracket]"}]}], "&"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", "n"}], "]"}]}]], "Input", CellLabel->"In[21]:="], Cell[BoxData[ RowBox[{"walk4D", "[", "4", "]"}]], "Input", CellLabel->"In[22]:="], Cell[BoxData[ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"awalk", " ", "=", " ", RowBox[{"walk4D", "[", "50000", "]"}]}], ";"}], ")"}], " ", "//", " ", "Timing"}]], "Input", CellLabel->"In[23]:="], Cell[BoxData[ RowBox[{"Dimensions", "[", "awalk", "]"}]], "Input", CellLabel->"In[24]:="], Cell[BoxData[ RowBox[{"Dimensions", "[", RowBox[{"awalk", "\[LeftDoubleBracket]", RowBox[{"All", ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}]}], "\[RightDoubleBracket]"}], "]"}]], "Input", CellLabel->"In[25]:="], Cell[BoxData[ RowBox[{ RowBox[{"showWalk3D", "[", RowBox[{ RowBox[{"awalk", "\[LeftDoubleBracket]", RowBox[{"All", ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}]}], "\[RightDoubleBracket]"}], ",", " ", RowBox[{"Axes", "\[Rule]", " ", "True"}]}], "]"}], ";"}]], "Input", CellLabel->"In[26]:="], Cell[BoxData[ RowBox[{ RowBox[{"showWalk3D", "[", RowBox[{ RowBox[{"awalk", "\[LeftDoubleBracket]", RowBox[{"All", ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "4"}], "}"}]}], "\[RightDoubleBracket]"}], ",", " ", RowBox[{"Axes", "\[Rule]", " ", "True"}]}], "]"}], ";"}]], "Input", CellLabel->"In[27]:="], Cell[BoxData[{ RowBox[{ RowBox[{"nWalkers", " ", "=", " ", "1000"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"walkList", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"walk4D", "[", "500", "]"}], ",", RowBox[{"{", "nWalkers", "}"}]}], "]"}]}], ";"}]}], "Input", CellLabel->"In[28]:="], Cell[CellGroupData[{ Cell["Average position (\"center of mass\")", "Subsubsection"], Cell[BoxData[ RowBox[{ RowBox[{"avgXYZ", "[", "walkers_List", "]"}], " ", ":=", " ", RowBox[{"N", "[", RowBox[{ RowBox[{"(", RowBox[{"Plus", " ", "@@", " ", "walkers"}], ")"}], "/", RowBox[{"Length", "[", "walkers", "]"}]}], "]"}]}]], "Input", CellLabel->"In[30]:="], Cell[BoxData[ RowBox[{ RowBox[{"avgXYZList", " ", "=", " ", RowBox[{"avgXYZ", " ", "/@", " ", RowBox[{"Transpose", "[", "walkList", "]"}]}]}], ";"}]], "Input", CellLabel->"In[31]:="], Cell[BoxData[ RowBox[{"avgXYZList", " ", "//", " ", "Shallow"}]], "Input", CellLabel->"In[32]:="], Cell[BoxData[ RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "avgXYZList", "]"}], "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellLabel->"In[33]:="], Cell[BoxData[ RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ RowBox[{"Transpose", "[", "avgXYZList", "]"}], "\[LeftDoubleBracket]", "4", "\[RightDoubleBracket]"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}]}], "]"}]], "Input",\ CellLabel->"In[34]:="], Cell["\<\ The average position of all walkers remains near the orgin (as expected).\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Average radius", "Subsubsection"], Cell[BoxData[ RowBox[{ RowBox[{"radius", "[", RowBox[{"{", RowBox[{"x_", ",", " ", "y_", ",", " ", "z_", ",", " ", "zz_"}], "}"}], "]"}], " ", ":=", " ", RowBox[{"Sqrt", "[", RowBox[{"N", "[", RowBox[{ RowBox[{"x", "^", "2"}], " ", "+", " ", RowBox[{"y", "^", "2"}], " ", "+", " ", RowBox[{"z", "^", "2"}], " ", "+", " ", RowBox[{"zz", "^", "2"}]}], "]"}], "]"}]}]], "Input", CellLabel->"In[35]:="], Cell[BoxData[ RowBox[{ RowBox[{"rList", " ", "=", " ", RowBox[{"Map", "[", RowBox[{"radius", ",", " ", "walkList", ",", RowBox[{"{", "2", "}"}]}], "]"}]}], ";"}]], "Input", CellLabel->"In[36]:="], Cell[BoxData[{ RowBox[{ RowBox[{"avgR", "=", RowBox[{"Mean", "/@", RowBox[{"Transpose", "[", "rList", "]"}]}]}], ";"}], "\n", RowBox[{"ListPlot", "[", "avgR", "]"}]}], "Input", CellLabel->"In[37]:="] }, Closed]], Cell[CellGroupData[{ Cell["Modeling average radius per step", "Subsubsection"], Cell["\<\ The average radius increases at a power-law of the number of steps.\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"rData", "=", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"N", "[", RowBox[{"Log", "[", "n", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "2", ",", RowBox[{"Length", "[", "avgR", "]"}]}], "}"}]}], "]"}], ",", RowBox[{"N", "[", RowBox[{"Log", "[", RowBox[{"Drop", "[", RowBox[{"avgR", ",", "1"}], "]"}], "]"}], "]"}]}], "}"}], "]"}]}], ";"}], "\n", RowBox[{"ListPlot", "[", RowBox[{"rData", ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]}], "Input", CellLabel->"In[39]:="], Cell[BoxData[ RowBox[{"power", " ", "=", " ", RowBox[{"Fit", "[", RowBox[{"rData", ",", RowBox[{"{", "x", "}"}], ",", " ", "x"}], "]"}]}]], "Input", CellLabel->"In[41]:="], Cell[TextData[{ "Therefore, \[LeftAngleBracket]", StyleBox["r", FontSlant->"Italic"], "\[RightAngleBracket] ~ ", Cell[BoxData[ FormBox[ SqrtBox["n"], TraditionalForm]]], "." }], "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Self-Avoiding Walks", "Section"], Cell["\<\ For three-dimensional self-avoiding walks, we need consider nine rotations: \t\[Bullet] rotate x-y by 90 Degrees, 180 Degrees, or 270 Degrees \t\[Bullet] rotate x-z by 90 Degree, 180 Degrees, or 270 Degrees \t\[Bullet] rotate y-z by 90 Degree, 180 Degree, or 270 Degrees\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Needs", "[", "\"\\"", "]"}], ";"}]], "Input",\ CellLabel->"In[42]:="], Cell[BoxData[ RowBox[{"?", "RotationMatrix3D"}]], "Input", CellLabel->"In[43]:="], Cell[CellGroupData[{ Cell["x-y rotations", "Subsubsection"], Cell[BoxData[ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"90", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"a", ",", " ", "0", ",", " ", "0"}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"a", ",", " ", "0", ",", " ", "0"}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]], "Input", CellLabel->"In[44]:="], Cell[BoxData[ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"180", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"a", ",", " ", "0", ",", " ", "0"}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"a", ",", " ", "0", ",", " ", "0"}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]], "Input", CellLabel->"In[45]:="], Cell[BoxData[ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"270", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"a", ",", " ", "0", ",", " ", "0"}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"a", ",", " ", "0", ",", " ", "0"}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]], "Input", CellLabel->"In[46]:="] }, Closed]], Cell[CellGroupData[{ Cell["y-z rotations", "Subsubsection"], Cell[BoxData[ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"90", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"0", ",", " ", "a", ",", " ", "0"}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"0", ",", " ", "a", ",", " ", "0"}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]], "Input", CellLabel->"In[47]:="], Cell[BoxData[ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"180", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"0", ",", " ", "a", ",", " ", "0"}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"0", ",", " ", "a", ",", " ", "0"}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]], "Input", CellLabel->"In[48]:="], Cell[BoxData[ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"270", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"0", ",", " ", "a", ",", " ", "0"}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"0", ",", " ", "a", ",", " ", "0"}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]], "Input", CellLabel->"In[49]:="] }, Closed]], Cell[CellGroupData[{ Cell["x-z rotations", "Subsubsection"], Cell[BoxData[{ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"90", " ", "Degree"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"b", " ", "=", " ", RowBox[{"90", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"b", ",", " ", "a", ",", " ", RowBox[{"-", "b"}]}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"b", ",", " ", "a", ",", " ", RowBox[{"-", "b"}]}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]}], "Input", CellLabel->"In[50]:="], Cell[BoxData[{ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"180", " ", "Degree"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"b", " ", "=", " ", RowBox[{"90", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"b", ",", " ", "a", ",", " ", RowBox[{"-", "b"}]}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"b", ",", " ", "a", ",", " ", RowBox[{"-", "b"}]}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]}], "Input", CellLabel->"In[52]:="], Cell[BoxData[{ RowBox[{ RowBox[{"a", " ", "=", " ", RowBox[{"270", " ", "Degree"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"b", " ", "=", " ", RowBox[{"90", " ", "Degree"}]}], ";", RowBox[{"{", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"b", ",", " ", "a", ",", " ", RowBox[{"-", "b"}]}], "]"}], ",", RowBox[{ RowBox[{"RotationMatrix3D", "[", RowBox[{"b", ",", " ", "a", ",", " ", RowBox[{"-", "b"}]}], "]"}], " ", "//", " ", "MatrixForm"}]}], "}"}]}]}], "Input", CellLabel->"In[54]:="] }, Closed]], Cell[CellGroupData[{ Cell["Twist", "Subsection"], Cell[BoxData[ RowBox[{ RowBox[{"twist", "[", "chain_List", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "n", ",", "iPivot", ",", "fixpart", ",", "movepart", ",", "rotchoice", ",", "newpart", ",", "newchain", ",", "rot"}], "}"}], ",", RowBox[{ RowBox[{"rot", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0", ",", "0"}], "}"}]}], "}"}]}], "}"}]}], ";", RowBox[{"n", "=", RowBox[{ RowBox[{"Length", "[", "chain", "]"}], "-", "1"}]}], ";", RowBox[{"iPivot", "=", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", RowBox[{"n", "-", "1"}]}], "}"}], "]"}]}], ";", RowBox[{"fixpart", "=", RowBox[{"Take", "[", RowBox[{"chain", ",", "iPivot"}], "]"}]}], ";", RowBox[{"movepart", "=", RowBox[{"Take", "[", RowBox[{"chain", ",", RowBox[{"iPivot", "-", RowBox[{"(", RowBox[{"n", "+", "1"}], ")"}]}]}], "]"}]}], ";", RowBox[{"rotchoice", "=", RowBox[{"rot", "\[LeftDoubleBracket]", RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "9"}], "}"}], "]"}], "\[RightDoubleBracket]"}]}], ";", RowBox[{"newpart", "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ RowBox[{ "chain", "\[LeftDoubleBracket]", "iPivot", "\[RightDoubleBracket]"}], "+", RowBox[{ RowBox[{"(", RowBox[{"#1", "-", RowBox[{ "chain", "\[LeftDoubleBracket]", "iPivot", "\[RightDoubleBracket]"}]}], ")"}], ".", "rotchoice"}]}], "&"}], ")"}], "/@", "movepart"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"newpart", "\[Intersection]", "fixpart"}], "\[Equal]", RowBox[{"{", "}"}]}], ",", RowBox[{"newchain", "=", RowBox[{"Join", "[", RowBox[{"fixpart", ",", "newpart"}], "]"}]}], ",", "chain"}], "]"}]}]}], "]"}]}]], "Input", CellLabel->"In[56]:="], Cell[CellGroupData[{ Cell["Example 3D SAWs", "Subsubsection"], Cell[BoxData[{ RowBox[{ RowBox[{"nSteps", "=", "500"}], ";"}], "\n", RowBox[{ RowBox[{"chain0", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "0", ",", "nSteps"}], "}"}]}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"chain100", "=", RowBox[{"Nest", "[", RowBox[{"twist", ",", "chain0", ",", "100"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"chain500", "=", RowBox[{"Nest", "[", RowBox[{"twist", ",", "chain100", ",", "400"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"chain1000", "=", RowBox[{"Nest", "[", RowBox[{"twist", ",", "chain500", ",", "500"}], "]"}]}], ";"}], "\n", RowBox[{"Show", "[", RowBox[{ RowBox[{"GraphicsRow", "[", RowBox[{"{", RowBox[{ RowBox[{"showWalk3D", "[", RowBox[{"chain100", ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}], ",", RowBox[{"showWalk3D", "[", RowBox[{"chain500", ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}], ",", RowBox[{"showWalk3D", "[", RowBox[{"chain1000", ",", RowBox[{"DisplayFunction", "\[Rule]", "Identity"}]}], "]"}]}], "}"}], "]"}], ",", RowBox[{"DisplayFunction", "\[Rule]", "$DisplayFunction"}]}], "]"}]}], "Input", CellLabel->"In[57]:="], Cell[BoxData[ RowBox[{"First", " ", "/@", " ", RowBox[{"{", RowBox[{ "chain0", ",", " ", "chain100", ",", " ", "chain500", ",", " ", "chain1000"}], "}"}]}]], "Input", CellLabel->"In[63]:="], Cell[BoxData[ RowBox[{"Last", " ", "/@", " ", RowBox[{"{", RowBox[{ "chain0", ",", " ", "chain100", ",", " ", "chain500", ",", " ", "chain1000"}], "}"}]}]], "Input", CellLabel->"In[64]:="], Cell["Radius at end of walk\[Ellipsis]", "Text"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"N", "[", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"#1", "^", "2"}], " ", "+", " ", RowBox[{"#2", "^", "2"}], " ", "+", " ", RowBox[{"#3", "^", "2"}]}], "]"}], "]"}], "&"}], " ", "@@@", " ", "%"}]], "Input", CellLabel->"In[65]:="] }, Closed]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Summary", "Section"], Cell[TextData[{ "As it turns out, ", StyleBox["Mathematica", FontSlant->"Italic"], " can display and process three-dimensional data just as simply as it deals \ with two-dimensions. Generating 3D random and self-avoiding walks is minor \ extension from three-dimensions. " }], "Text"] }, Closed]] }, Open ]] }, WindowSize->{720, 775}, WindowMargins->{{1, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, ShowSelection->True, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (May 21, 2008)", StyleDefinitions->"TutorialBook.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 25, 0, 51, "Title"], Cell[618, 25, 60, 3, 41, "Subsubtitle"], Cell[CellGroupData[{ Cell[703, 32, 31, 0, 86, "Section"], Cell[737, 34, 219, 8, 23, "Text"], Cell[959, 44, 133, 4, 24, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[1129, 53, 31, 0, 54, "Section"], Cell[1163, 55, 1077, 32, 78, "Input"], Cell[2243, 89, 359, 10, 46, "Input"], Cell[2605, 101, 212, 7, 26, "Input"], Cell[2820, 110, 179, 5, 24, "Input"], Cell[CellGroupData[{ Cell[3024, 119, 52, 0, 34, "Subsection"], Cell[3079, 121, 142, 4, 26, "Input"], Cell[3224, 127, 326, 9, 43, "Input"], Cell[3553, 138, 215, 5, 26, "Input"], Cell[CellGroupData[{ Cell[3793, 147, 62, 0, 33, "Subsubsection"], Cell[3858, 149, 292, 8, 28, "Input"], Cell[4153, 159, 195, 5, 26, "Input"], Cell[4351, 166, 99, 2, 26, "Input"], Cell[4453, 170, 323, 9, 45, "Input"], Cell[4779, 181, 97, 2, 23, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4913, 188, 39, 0, 33, "Subsubsection"], Cell[4955, 190, 385, 12, 28, "Input"], Cell[5343, 204, 214, 6, 26, "Input"], Cell[5560, 212, 214, 6, 45, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[5811, 223, 57, 0, 33, "Subsubsection"], Cell[5871, 225, 91, 2, 23, "Text"], Cell[5965, 229, 685, 21, 60, "Input"], Cell[6653, 252, 185, 5, 26, "Input"], Cell[6841, 259, 197, 9, 27, "Text"] }, Closed]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[7099, 275, 29, 0, 54, "Section"], Cell[7131, 277, 1361, 38, 95, "Input"], Cell[8495, 317, 83, 2, 24, "Input"], Cell[8581, 321, 213, 7, 26, "Input"], Cell[8797, 330, 91, 2, 26, "Input"], Cell[8891, 334, 248, 7, 26, "Input"], Cell[9142, 343, 347, 10, 24, "Input"], Cell[9492, 355, 347, 10, 24, "Input"], Cell[9842, 367, 327, 9, 43, "Input"], Cell[CellGroupData[{ Cell[10194, 380, 62, 0, 33, "Subsubsection"], Cell[10259, 382, 292, 8, 28, "Input"], Cell[10554, 392, 195, 5, 26, "Input"], Cell[10752, 399, 99, 2, 26, "Input"], Cell[10854, 403, 323, 9, 45, "Input"], Cell[11180, 414, 326, 10, 45, "Input"], Cell[11509, 426, 97, 2, 23, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[11643, 433, 39, 0, 33, "Subsubsection"], Cell[11685, 435, 450, 13, 28, "Input"], Cell[12138, 450, 214, 6, 26, "Input"], Cell[12355, 458, 214, 6, 45, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[12606, 469, 57, 0, 33, "Subsubsection"], Cell[12666, 471, 91, 2, 23, "Text"], Cell[12760, 475, 685, 21, 60, "Input"], Cell[13448, 498, 185, 5, 26, "Input"], Cell[13636, 505, 197, 9, 27, "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[13882, 520, 38, 0, 54, "Section"], Cell[13923, 522, 295, 5, 114, "Text"], Cell[14221, 529, 128, 4, 26, "Input"], Cell[14352, 535, 83, 2, 26, "Input"], Cell[CellGroupData[{ Cell[14460, 541, 38, 0, 33, "Subsubsection"], Cell[14501, 543, 418, 12, 45, "Input"], Cell[14922, 557, 419, 12, 45, "Input"], Cell[15344, 571, 419, 12, 45, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[15800, 588, 38, 0, 33, "Subsubsection"], Cell[15841, 590, 418, 12, 45, "Input"], Cell[16262, 604, 419, 12, 45, "Input"], Cell[16684, 618, 419, 12, 45, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[17140, 635, 38, 0, 33, "Subsubsection"], Cell[17181, 637, 571, 17, 61, "Input"], Cell[17755, 656, 572, 17, 61, "Input"], Cell[18330, 675, 572, 17, 61, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[18939, 697, 27, 0, 34, "Subsection"], Cell[18969, 699, 5078, 145, 344, "Input"], Cell[CellGroupData[{ Cell[24072, 848, 40, 0, 33, "Subsubsection"], Cell[24115, 850, 1386, 40, 186, "Input"], Cell[25504, 892, 206, 6, 26, "Input"], Cell[25713, 900, 205, 6, 26, "Input"], Cell[25921, 908, 48, 0, 23, "Text"], Cell[25972, 910, 308, 10, 24, "Input"] }, Closed]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[26341, 927, 26, 0, 54, "Section"], Cell[26370, 929, 289, 7, 41, "Text"] }, Closed]] }, Open ]] } ] *) (* End of internal cache information *)