(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 13509, 403]*) (*NotebookOutlinePosition[ 14152, 425]*) (* CellTagsIndexPosition[ 14108, 421]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[ \(\(\( (*\ This\ is\ the\ 3 x + 1\ map . \ It\ takes\ as\ input\ an\ odd\ number, \ and\ outputs\ \((3 x + 1)\)/2^k, \ where\ k\ is\ the\ largest\ power\ of\ 2\ dividing\ 3 x + 1. \ The\ second\ input, \ n, \ controls\ the\ printing . \ if\ n = 0\ then\ it\ just\ prints\ \((3 x + 1)\)/2^k; \ if\ n\ \[GreaterEqual] \ 1\ it\ prints\ n\ as\ well . \ this\ is\ useful\ when\ you\ want\ to\ print\ several\ iterates\ \ of\ a\ starting\ seed, \ and\ keep\ track\ of\ which\ iterate\ has\ which\ \(\(value\)\(.\)\)\ *) \)\(\[IndentingNewLine]\)\(\(M[x_, n_]\ := \ Module[{}, \[IndentingNewLine]y\ = \ 3\ x\ + \ 1; \[IndentingNewLine]m\ = \ n; \[IndentingNewLine]While[\ Mod[y, 2]\ \[Equal] \ 0, \ y\ = \ y/2]; \[IndentingNewLine]If[n == 0, \ Print[y], Print["\", \ m, "\< is \>", y]]; \[IndentingNewLine]m\ = \ m + 1;\[IndentingNewLine]];\)\[IndentingNewLine]\ \[IndentingNewLine] (*\ This\ function\ uses\ the\ function\ M[]\ from\ above\ to\ print\ the\ \ iterates\ of\ a\ starting\ seed\ until\ 1\ is\ reached\ \ *) \[IndentingNewLine] \(IM[x_]\ := \ Module[{}, \[IndentingNewLine]y\ = \ x; \[IndentingNewLine]Print["\", \ y]; \[IndentingNewLine]n\ = \ 1; \ \[IndentingNewLine]m\ = \ n; \[IndentingNewLine]While[\ y\ > \ 1, \ M[y, m]];\[IndentingNewLine]];\)\)\)\)], "Input"], Cell[BoxData[""], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\( (*\ This\ will\ print\ the\ first\ iterate\ of\ the\ 3 x + 1\ map, \ starting\ at\ 7\ *) \)\(\[IndentingNewLine]\)\(M[7, 0]\)\)\)], "Input"], Cell[BoxData[ \(11\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\( (*\ this\ will\ print\ out\ all\ the\ iterates\ of\ the\ 3 x + 1\ map, \ starting\ at\ 7, \ until\ 1\ is\ \(\(reached\)\(.\)\)\ *) \)\(\[IndentingNewLine]\)\(IM[ 7]\)\)\)], "Input"], Cell[BoxData[ InterpretationBox[\("Term 0 is "\[InvisibleSpace]7\), SequenceForm[ "Term 0 is ", 7], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]1\[InvisibleSpace]" is "\ \[InvisibleSpace]11\), SequenceForm[ "Term ", 1, " is ", 11], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]2\[InvisibleSpace]" is "\ \[InvisibleSpace]17\), SequenceForm[ "Term ", 2, " is ", 17], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]3\[InvisibleSpace]" is "\ \[InvisibleSpace]13\), SequenceForm[ "Term ", 3, " is ", 13], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]4\[InvisibleSpace]" is "\ \[InvisibleSpace]5\), SequenceForm[ "Term ", 4, " is ", 5], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]5\[InvisibleSpace]" is "\ \[InvisibleSpace]1\), SequenceForm[ "Term ", 5, " is ", 1], Editable->False]], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\( (*\ 27\ is\ a\ very\ interesting\ starting\ seed\ - \ it\ gives\ a\ very\ long\ sequence\ of\ iterates\ before\ reaching\ \ 1. \ it\ is\ MUCH\ longer\ if\ we\ do\ not\ pull\ out\ all\ powers\ of\ 2\ in\ \ one\ \(\(step\)\(.\)\)\ *) \)\(\[IndentingNewLine]\)\(IM[27]\)\)\)], "Input"], Cell[BoxData[ InterpretationBox[\("Term 0 is "\[InvisibleSpace]27\), SequenceForm[ "Term 0 is ", 27], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]1\[InvisibleSpace]" is "\ \[InvisibleSpace]41\), SequenceForm[ "Term ", 1, " is ", 41], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]2\[InvisibleSpace]" is "\ \[InvisibleSpace]31\), SequenceForm[ "Term ", 2, " is ", 31], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]3\[InvisibleSpace]" is "\ \[InvisibleSpace]47\), SequenceForm[ "Term ", 3, " is ", 47], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]4\[InvisibleSpace]" is "\ \[InvisibleSpace]71\), SequenceForm[ "Term ", 4, " is ", 71], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]5\[InvisibleSpace]" is "\ \[InvisibleSpace]107\), SequenceForm[ "Term ", 5, " is ", 107], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]6\[InvisibleSpace]" is "\ \[InvisibleSpace]161\), SequenceForm[ "Term ", 6, " is ", 161], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]7\[InvisibleSpace]" is "\ \[InvisibleSpace]121\), SequenceForm[ "Term ", 7, " is ", 121], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]8\[InvisibleSpace]" is "\ \[InvisibleSpace]91\), SequenceForm[ "Term ", 8, " is ", 91], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]9\[InvisibleSpace]" is "\ \[InvisibleSpace]137\), SequenceForm[ "Term ", 9, " is ", 137], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]10\[InvisibleSpace]" is "\ \[InvisibleSpace]103\), SequenceForm[ "Term ", 10, " is ", 103], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]11\[InvisibleSpace]" is "\ \[InvisibleSpace]155\), SequenceForm[ "Term ", 11, " is ", 155], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]12\[InvisibleSpace]" is "\ \[InvisibleSpace]233\), SequenceForm[ "Term ", 12, " is ", 233], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]13\[InvisibleSpace]" is "\ \[InvisibleSpace]175\), SequenceForm[ "Term ", 13, " is ", 175], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]14\[InvisibleSpace]" is "\ \[InvisibleSpace]263\), SequenceForm[ "Term ", 14, " is ", 263], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]15\[InvisibleSpace]" is "\ \[InvisibleSpace]395\), SequenceForm[ "Term ", 15, " is ", 395], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]16\[InvisibleSpace]" is "\ \[InvisibleSpace]593\), SequenceForm[ "Term ", 16, " is ", 593], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]17\[InvisibleSpace]" is "\ \[InvisibleSpace]445\), SequenceForm[ "Term ", 17, " is ", 445], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]18\[InvisibleSpace]" is "\ \[InvisibleSpace]167\), SequenceForm[ "Term ", 18, " is ", 167], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]19\[InvisibleSpace]" is "\ \[InvisibleSpace]251\), SequenceForm[ "Term ", 19, " is ", 251], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]20\[InvisibleSpace]" is "\ \[InvisibleSpace]377\), SequenceForm[ "Term ", 20, " is ", 377], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]21\[InvisibleSpace]" is "\ \[InvisibleSpace]283\), SequenceForm[ "Term ", 21, " is ", 283], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]22\[InvisibleSpace]" is "\ \[InvisibleSpace]425\), SequenceForm[ "Term ", 22, " is ", 425], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]23\[InvisibleSpace]" is "\ \[InvisibleSpace]319\), SequenceForm[ "Term ", 23, " is ", 319], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]24\[InvisibleSpace]" is "\ \[InvisibleSpace]479\), SequenceForm[ "Term ", 24, " is ", 479], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]25\[InvisibleSpace]" is "\ \[InvisibleSpace]719\), SequenceForm[ "Term ", 25, " is ", 719], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]26\[InvisibleSpace]" is "\ \[InvisibleSpace]1079\), SequenceForm[ "Term ", 26, " is ", 1079], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]27\[InvisibleSpace]" is "\ \[InvisibleSpace]1619\), SequenceForm[ "Term ", 27, " is ", 1619], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]28\[InvisibleSpace]" is "\ \[InvisibleSpace]2429\), SequenceForm[ "Term ", 28, " is ", 2429], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]29\[InvisibleSpace]" is "\ \[InvisibleSpace]911\), SequenceForm[ "Term ", 29, " is ", 911], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]30\[InvisibleSpace]" is "\ \[InvisibleSpace]1367\), SequenceForm[ "Term ", 30, " is ", 1367], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]31\[InvisibleSpace]" is "\ \[InvisibleSpace]2051\), SequenceForm[ "Term ", 31, " is ", 2051], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]32\[InvisibleSpace]" is "\ \[InvisibleSpace]3077\), SequenceForm[ "Term ", 32, " is ", 3077], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]33\[InvisibleSpace]" is "\ \[InvisibleSpace]577\), SequenceForm[ "Term ", 33, " is ", 577], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]34\[InvisibleSpace]" is "\ \[InvisibleSpace]433\), SequenceForm[ "Term ", 34, " is ", 433], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]35\[InvisibleSpace]" is "\ \[InvisibleSpace]325\), SequenceForm[ "Term ", 35, " is ", 325], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]36\[InvisibleSpace]" is "\ \[InvisibleSpace]61\), SequenceForm[ "Term ", 36, " is ", 61], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]37\[InvisibleSpace]" is "\ \[InvisibleSpace]23\), SequenceForm[ "Term ", 37, " is ", 23], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]38\[InvisibleSpace]" is "\ \[InvisibleSpace]35\), SequenceForm[ "Term ", 38, " is ", 35], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]39\[InvisibleSpace]" is "\ \[InvisibleSpace]53\), SequenceForm[ "Term ", 39, " is ", 53], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]40\[InvisibleSpace]" is "\ \[InvisibleSpace]5\), SequenceForm[ "Term ", 40, " is ", 5], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Term "\[InvisibleSpace]41\[InvisibleSpace]" is "\ \[InvisibleSpace]1\), SequenceForm[ "Term ", 41, " is ", 1], Editable->False]], "Print"] }, Open ]] }, FrontEndVersion->"5.2 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, WindowSize->{496, 537}, WindowMargins->{{0, Automatic}, {Automatic, 0}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 1581, 31, 590, "Input"], Cell[3338, 84, 26, 0, 30, "Input"], Cell[CellGroupData[{ Cell[3389, 88, 180, 3, 70, "Input"], Cell[3572, 93, 35, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[3644, 99, 234, 5, 70, "Input"], Cell[3881, 106, 143, 3, 25, "Print"], Cell[4027, 111, 189, 4, 25, "Print"], Cell[4219, 117, 189, 4, 25, "Print"], Cell[4411, 123, 189, 4, 25, "Print"], Cell[4603, 129, 187, 4, 25, "Print"], Cell[4793, 135, 187, 4, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[5017, 144, 324, 5, 110, "Input"], Cell[5344, 151, 145, 3, 25, "Print"], Cell[5492, 156, 189, 4, 25, "Print"], Cell[5684, 162, 189, 4, 25, "Print"], Cell[5876, 168, 189, 4, 25, "Print"], Cell[6068, 174, 189, 4, 25, "Print"], Cell[6260, 180, 191, 4, 25, "Print"], Cell[6454, 186, 191, 4, 25, "Print"], Cell[6648, 192, 191, 4, 25, "Print"], Cell[6842, 198, 189, 4, 25, "Print"], Cell[7034, 204, 191, 4, 25, "Print"], Cell[7228, 210, 193, 4, 25, "Print"], Cell[7424, 216, 193, 4, 25, "Print"], Cell[7620, 222, 193, 4, 25, "Print"], Cell[7816, 228, 193, 4, 25, "Print"], Cell[8012, 234, 193, 4, 25, "Print"], Cell[8208, 240, 193, 4, 25, "Print"], Cell[8404, 246, 193, 4, 25, "Print"], Cell[8600, 252, 193, 4, 25, "Print"], Cell[8796, 258, 193, 4, 25, "Print"], Cell[8992, 264, 193, 4, 25, "Print"], Cell[9188, 270, 193, 4, 25, "Print"], Cell[9384, 276, 193, 4, 25, "Print"], Cell[9580, 282, 193, 4, 25, "Print"], Cell[9776, 288, 193, 4, 25, "Print"], Cell[9972, 294, 193, 4, 25, "Print"], Cell[10168, 300, 193, 4, 25, "Print"], Cell[10364, 306, 195, 4, 25, "Print"], Cell[10562, 312, 195, 4, 25, "Print"], Cell[10760, 318, 195, 4, 25, "Print"], Cell[10958, 324, 193, 4, 25, "Print"], Cell[11154, 330, 195, 4, 25, "Print"], Cell[11352, 336, 195, 4, 25, "Print"], Cell[11550, 342, 195, 4, 25, "Print"], Cell[11748, 348, 193, 4, 25, "Print"], Cell[11944, 354, 193, 4, 25, "Print"], Cell[12140, 360, 193, 4, 25, "Print"], Cell[12336, 366, 191, 4, 25, "Print"], Cell[12530, 372, 191, 4, 25, "Print"], Cell[12724, 378, 191, 4, 25, "Print"], Cell[12918, 384, 191, 4, 25, "Print"], Cell[13112, 390, 189, 4, 25, "Print"], Cell[13304, 396, 189, 4, 25, "Print"] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)