(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 15466, 434] NotebookOptionsPosition[ 14706, 404] NotebookOutlinePosition[ 15072, 420] CellTagsIndexPosition[ 15029, 417] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ StyleBox[ RowBox[{ RowBox[{ "Seeing", " ", "how", " ", "long", " ", "it", " ", "takes", " ", "to", " ", "iterate", " ", "to", " ", "1", " ", "in", " ", "3", "x"}], "+", RowBox[{"1", " ", "Problem"}]}], "Subtitle"]], "Input", CellChangeTimes->{{3.463699480484375*^9, 3.463699490484375*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ "number", " ", "=", " ", "27378675654323346464096990095909090234289295774747302"}], ";"}]], "Input", CellChangeTimes->{{3.463698653921875*^9, 3.463698659828125*^9}, { 3.463699072875*^9, 3.463699079640625*^9}, {3.46369916290625*^9, 3.4636992610625*^9}, {3.46369936909375*^9, 3.463699369296875*^9}, { 3.463699424734375*^9, 3.46369943346875*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"iteratingtofixedpoint", "[", RowBox[{"numb_", ",", "option_"}], "]"}], " ", ":=", " ", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"count", " ", "=", " ", "0"}], ";", "\[IndentingNewLine]", RowBox[{"num", " ", "=", " ", "numb"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{"numb", ",", "2"}], "]"}], " ", "\[Equal]", " ", "0"}], ",", " ", RowBox[{"num", " ", "=", " ", RowBox[{"numb", " ", "+", " ", "1"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{"numb", ",", "3"}], "]"}], " ", "\[Equal]", " ", "0"}], ",", " ", RowBox[{"num", " ", "=", " ", RowBox[{"numb", " ", "+", " ", "2"}]}]}], "]"}], ";"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"initialnum", " ", "=", " ", "num"}], ";", "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{"num", " ", ">", " ", "1"}], ",", "\[IndentingNewLine]", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"num", " ", "=", " ", RowBox[{ RowBox[{"3", " ", "num"}], " ", "+", " ", "1"}]}], ";", "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{"num", ",", "2"}], "]"}], " ", "\[Equal]", " ", "0"}], ",", " ", RowBox[{"num", " ", "=", " ", RowBox[{"num", "/", "2"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"count", " ", "=", " ", RowBox[{"count", " ", "+", " ", "1"}]}], ";"}], "\[IndentingNewLine]", "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"option", " ", "\[Equal]", " ", "1"}], ",", "\[IndentingNewLine]", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", " ", "count", ",", " ", "\"\<.\>\""}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", " ", RowBox[{ RowBox[{"Log", "[", "initialnum", "]"}], " ", "/", " ", RowBox[{"Log", "[", RowBox[{"4.", "/", "3"}], "]"}]}], ",", " ", "\"\<.\>\""}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", " ", RowBox[{"Floor", "[", RowBox[{"Log", "[", RowBox[{"10", ",", "initialnum"}], "]"}], "]"}], ",", " ", "\"\< digits.\>\""}], "]"}], ";"}], "\[IndentingNewLine]", "}"}], ",", " ", RowBox[{"Return", "[", "count", "]"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.4636986674375*^9, 3.463698833484375*^9}, 3.463698904078125*^9, {3.463698940796875*^9, 3.463699043484375*^9}, { 3.463699129125*^9, 3.463699152296875*^9}, {3.463699265109375*^9, 3.4636992888125*^9}, {3.46369935540625*^9, 3.463699364140625*^9}, { 3.4636994140625*^9, 3.463699416125*^9}, {3.46370101915625*^9, 3.46370106009375*^9}, {3.46370120903125*^9, 3.463701211921875*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"iteratingtofixedpoint", "[", RowBox[{ RowBox[{"number", " ", RowBox[{"10", "^", "200"}]}], ",", "1"}], "]"}]], "Input", CellChangeTimes->{{3.463698977828125*^9, 3.46369899046875*^9}, { 3.46369907525*^9, 3.463699075796875*^9}, {3.463700744625*^9, 3.463700748203125*^9}, {3.46370097209375*^9, 3.463700986375*^9}, { 3.46370106609375*^9, 3.46370106696875*^9}}], Cell[CellGroupData[{ Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Number of iterations to reach 1 is \"\>", "\[InvisibleSpace]", "2421", "\[InvisibleSpace]", "\<\".\"\>"}], SequenceForm["Number of iterations to reach 1 is ", 2421, "."], Editable->False]], "Print", CellChangeTimes->{3.463700699953125*^9, 3.4637007496875*^9, 3.46370097546875*^9, 3.463701069453125*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Expected number of iterations is \"\>", "\[InvisibleSpace]", "2020.4895558395717`", "\[InvisibleSpace]", "\<\".\"\>"}], SequenceForm["Expected number of iterations is ", 2020.4895558395717`, "."], Editable->False]], "Print", CellChangeTimes->{3.463700699953125*^9, 3.4637007496875*^9, 3.46370097546875*^9, 3.463701069453125*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Number has roughly \"\>", "\[InvisibleSpace]", "252", "\[InvisibleSpace]", "\<\" digits.\"\>"}], SequenceForm["Number has roughly ", 252, " digits."], Editable->False]], "Print", CellChangeTimes->{3.463700699953125*^9, 3.4637007496875*^9, 3.46370097546875*^9, 3.463701069453125*^9}] }, Open ]] }, Open ]], Cell[BoxData[""], "Input", CellChangeTimes->{{3.463700945859375*^9, 3.463700946265625*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"histogramiterates", "[", RowBox[{"start_", ",", "numdo_"}], "]"}], " ", ":=", " ", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"output", " ", "=", " ", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"n", " ", "=", " ", "1"}], ",", " ", RowBox[{"n", " ", "\[LessEqual]", " ", "numdo"}], ",", " ", RowBox[{"n", "++"}], ",", " ", RowBox[{"output", " ", "=", " ", RowBox[{"AppendTo", "[", RowBox[{"output", ",", " ", RowBox[{"iteratingtofixedpoint", "[", " ", RowBox[{ RowBox[{"start", " ", "+", " ", RowBox[{"Floor", "[", " ", RowBox[{"n", " ", RowBox[{"Sqrt", "[", "start", " ", "]"}]}], "]"}]}], ",", "0"}], "]"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"Histogram", "[", RowBox[{"output", ",", "Automatic", ",", " ", "\"\\""}], "]"}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.46370094878125*^9, 3.46370095934375*^9}, { 3.463700990890625*^9, 3.46370100815625*^9}, {3.463701076046875*^9, 3.463701097515625*^9}, {3.46370122646875*^9, 3.4637012760625*^9}, { 3.46370139040625*^9, 3.46370141709375*^9}, {3.463701501109375*^9, 3.4637015055625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"histogramiterates", "[", RowBox[{ "123424989089080980989089089098989898988980984523523543535353535435444444444\ 444444444444444444444555555555555555555555555555555555544444444444444444444449\ 089898989898989929", ",", "1000"}], "]"}]], "Input", CellChangeTimes->{{3.4637007899375*^9, 3.463700811578125*^9}, { 3.46370089390625*^9, 3.4637008973125*^9}, {3.463700928890625*^9, 3.4637009304375*^9}, {3.463701280078125*^9, 3.463701305578125*^9}, { 3.463701356*^9, 3.463701361828125*^9}, {3.463701426515625*^9, 3.463701462109375*^9}, {3.463701547046875*^9, 3.463701547203125*^9}}], Cell[BoxData[ GraphicsBox[ {RGBColor[0.798413061722744, 0.824719615472648, 0.968322270542458], EdgeForm[Opacity[0.7]], {}, {RGBColor[0.798413061722744, 0.824719615472648, 0.968322270542458], EdgeForm[Opacity[0.7]], TagBox[ TooltipBox[ TagBox[ DynamicBox[{ FEPrivate`If[ CurrentValue["MouseOver"], EdgeForm[{ GrayLevel[0.5], AbsoluteThickness[1.5], Opacity[0.66]}], {}, {}], RectangleBox[{950, 0}, {1000, 0.001}]}, ImageSizeCache->{{20.75, 40.54411764705884}, {94.97770420937698, 96.06574920711158}}], StatusArea[#, 0.001]& , TagBoxNote->"0.001"], StyleBox["0.001`", { GrayLevel[0]}, StripOnInput -> False]], Annotation[#, Style[0.001, { GrayLevel[0]}], "Tooltip"]& ], {}, {}, TagBox[ TooltipBox[ TagBox[ DynamicBox[{ FEPrivate`If[ CurrentValue["MouseOver"], EdgeForm[{ GrayLevel[0.5], AbsoluteThickness[1.5], Opacity[0.66]}], {}, {}], RectangleBox[{1100, 0}, {1150, 0.238}]}, ImageSizeCache->{{78.63235294117646, 98.4264705882353}, {-44.38896025372428, 96.06574920711158}}], StatusArea[#, 0.238]& , TagBoxNote->"0.238"], StyleBox["0.238`", { GrayLevel[0]}, StripOnInput -> False]], Annotation[#, Style[0.238, { GrayLevel[0]}], "Tooltip"]& ], {}, {}, TagBox[ TooltipBox[ TagBox[ DynamicBox[{ FEPrivate`If[ CurrentValue["MouseOver"], EdgeForm[{ GrayLevel[0.5], AbsoluteThickness[1.5], Opacity[0.66]}], {}, {}], RectangleBox[{1250, 0}, {1300, 0.126}]}, ImageSizeCache->{{136.51470588235293`, 156.30882352941177`}, { 21.472079492551416`, 96.06574920711158}}], StatusArea[#, 0.126]& , TagBoxNote->"0.126"], StyleBox["0.126`", { GrayLevel[0]}, StripOnInput -> False]], Annotation[#, Style[0.126, { GrayLevel[0]}], "Tooltip"]& ], {}, TagBox[ TooltipBox[ TagBox[ DynamicBox[{ FEPrivate`If[ CurrentValue["MouseOver"], EdgeForm[{ GrayLevel[0.5], AbsoluteThickness[1.5], Opacity[0.66]}], {}, {}], RectangleBox[{1350, 0}, {1400, 0.255}]}, ImageSizeCache->{{175.1029411764706, 194.8970588235294}, {-54.38572521521259, 96.06574920711158}}], StatusArea[#, 0.255]& , TagBoxNote->"0.255"], StyleBox["0.255`", { GrayLevel[0]}, StripOnInput -> False]], Annotation[#, Style[0.255, { GrayLevel[0]}], "Tooltip"]& ], TagBox[ TooltipBox[ TagBox[ DynamicBox[{ FEPrivate`If[ CurrentValue["MouseOver"], EdgeForm[{ GrayLevel[0.5], AbsoluteThickness[1.5], Opacity[0.66]}], {}, {}], RectangleBox[{1400, 0}, {1450, 0.316}]}, ImageSizeCache->{{194.3970588235294, 214.19117647058818`}, {-90.25647007702345, 96.06574920711158}}], StatusArea[#, 0.316]& , TagBoxNote->"0.316"], StyleBox["0.316`", { GrayLevel[0]}, StripOnInput -> False]], Annotation[#, Style[0.316, { GrayLevel[0]}], "Tooltip"]& ], {}, {}, TagBox[ TooltipBox[ TagBox[ DynamicBox[{ FEPrivate`If[ CurrentValue["MouseOver"], EdgeForm[{ GrayLevel[0.5], AbsoluteThickness[1.5], Opacity[0.66]}], {}, {}], RectangleBox[{1550, 0}, {1600, 0.045}]}, ImageSizeCache->{{252.27941176470586`, 272.07352941176464`}, { 69.10372430905437, 96.06574920711158}}], StatusArea[#, 0.045]& , TagBoxNote->"0.045"], StyleBox["0.045`", { GrayLevel[0]}, StripOnInput -> False]], Annotation[#, Style[0.045, { GrayLevel[0]}], "Tooltip"]& ], TagBox[ TooltipBox[ TagBox[ DynamicBox[{ FEPrivate`If[ CurrentValue["MouseOver"], EdgeForm[{ GrayLevel[0.5], AbsoluteThickness[1.5], Opacity[0.66]}], {}, {}], RectangleBox[{1600, 0}, {1650, 0.018}]}, ImageSizeCache->{{271.57352941176464`, 291.36764705882354`}, { 84.9809392478887, 96.06574920711158}}], StatusArea[#, 0.018]& , TagBoxNote->"0.018"], StyleBox["0.018`", { GrayLevel[0]}, StripOnInput -> False]], Annotation[#, Style[0.018, { GrayLevel[0]}], "Tooltip"]& ], {}, {}, TagBox[ TooltipBox[ TagBox[ DynamicBox[{ FEPrivate`If[ CurrentValue["MouseOver"], EdgeForm[{ GrayLevel[0.5], AbsoluteThickness[1.5], Opacity[0.66]}], {}, {}], RectangleBox[{1750, 0}, {1800, 0.001}]}, ImageSizeCache->{{329.4558823529411, 349.25}, {94.97770420937698, 96.06574920711158}}], StatusArea[#, 0.001]& , TagBoxNote->"0.001"], StyleBox["0.001`", { GrayLevel[0]}, StripOnInput -> False]], Annotation[#, Style[0.001, { GrayLevel[0]}], "Tooltip"]& ]}, {}, {}}, AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948], Axes->{True, True}, AxesOrigin->{950, 0}, FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}}, PlotRange->{{950, 1800}, {All, All}}, PlotRangePadding->{{ Scaled[0.02], Scaled[0.02]}, { Scaled[0.02], Scaled[0.1]}}, Ticks->{Automatic, Automatic}]], "Print", CellChangeTimes->{{3.4637012871875*^9, 3.463701307015625*^9}, 3.4637013635625*^9, {3.463701394625*^9, 3.463701432328125*^9}, 3.463701475765625*^9, 3.46370152025*^9, 3.46370156890625*^9}] }, Open ]] }, WindowSize->{616, 750}, WindowMargins->{{18, Automatic}, {Automatic, 23}}, ShowSelection->True, FrontEndVersion->"7.0 for Microsoft Windows (32-bit) (February 18, 2009)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[545, 20, 322, 7, 82, "Input"], Cell[870, 29, 392, 8, 31, "Input"], Cell[1265, 39, 3686, 84, 452, "Input"], Cell[CellGroupData[{ Cell[4976, 127, 399, 8, 31, "Input"], Cell[CellGroupData[{ Cell[5400, 139, 363, 7, 23, "Print"], Cell[5766, 148, 389, 7, 23, "Print"], Cell[6158, 157, 343, 7, 23, "Print"] }, Open ]] }, Open ]], Cell[6528, 168, 92, 1, 31, "Input"], Cell[6623, 171, 1536, 35, 152, "Input"], Cell[CellGroupData[{ Cell[8184, 210, 614, 10, 92, "Input"], Cell[8801, 222, 5889, 179, 236, "Print"] }, Open ]] } ] *) (* End of internal cache information *)