Collatz Conjecture (3n+1 Problem) Iteration Visualization
2021-01-24 13:00
This GeoGebra applet visualizes the iteration process of the Collatz Conjecture (also known as the 3n+1 problem). The conjecture states that for any positive integer n, if n is even, divide it by 2; if n is odd, multiply by 3 and add 1. Repeating this process will eventually reach 1. The applet uses IterationList, Sequence, and Zip commands to generate the Collatz sequence, and PolyLine and Polygo
Loading the GeoGebra board and drawing, please wait…
<?xml version="1.0" encoding="utf-8"?>
<geogebra format="5.0" version="5.0.624.0" app="classic" platform="w" id="264f413c-ab4e-4341-9d98-f813260a45dd" xsi:noNamespaceSchemaLocation="https://ggb123.cn/apps/xsd/ggb.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<gui>
<window width="1366" height="551" />
<perspectives>
<perspective id="tmp">
<panes>
<pane location="" divider="0.1925329428989751" orientation="1" />
</panes>
<views>
<view id="512" toolbar="0 | 1 501 5 19 , 67 | 2 15 45 18 , 7 37 | 514 3 9 , 13 44 , 47 | 16 51 | 551 550 11 , 20 22 21 23 , 55 56 57 , 12 | 69 | 510 511 , 512 513 | 533 531 , 534 532 , 522 523 , 537 536 , 535 , 538 | 521 520 | 36 , 38 49 560 | 571 30 29 570 31 33 | 17 | 540 40 41 42 , 27 28 35 , 6 , 502" visible="false" inframe="false" stylebar="false" location="1,1,1" size="500" window="100,100,600,400" />
<view id="4" toolbar="0 || 2020 , 2021 , 2022 , 66 || 2001 , 2003 , 2002 , 2004 , 2005 || 2040 , 2041 , 2042 , 2044 , 2043" visible="false" inframe="false" stylebar="true" location="1,1" size="300" window="100,100,600,400" />
<view id="8" toolbar="1001 | 1002 | 1003 || 1005 | 1004 || 1006 | 1007 | 1010 || 1008 1009 || 66 68 || 6" visible="false" inframe="false" stylebar="false" location="1,3" size="300" window="100,100,600,400" />
<view id="16" visible="false" inframe="false" stylebar="false" location="1,2" size="284" window="50,50,500,500" />
<view id="1" visible="true" inframe="false" stylebar="true" location="1" size="1366" window="100,100,600,400" />
<view id="2" visible="false" inframe="false" stylebar="false" location="3" size="263" tab="ALGEBRA" window="100,100,600,400" />
<view id="32" visible="false" inframe="false" stylebar="true" location="1" size="150" window="50,50,500,500" />
<view id="64" toolbar="0" visible="false" inframe="false" stylebar="false" location="1" size="150" window="50,50,500,500" />
<view id="128" visible="false" inframe="false" stylebar="false" location="1" size="480" window="50,50,500,500" />
<view id="4097" visible="false" inframe="false" stylebar="true" location="1" size="330" window="610,245,700,550" />
<view id="70" toolbar="0 || 2020 || 2021 || 2022" visible="false" inframe="false" stylebar="true" location="1" size="150" window="50,50,500,500" />
</views>
<toolbar show="false" items="| 0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 100002 100001 100003 100004 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6" position="1" help="false" />
<input show="false" cmd="true" top="true" />
<dockBar show="false" east="false" />
</perspective>
</perspectives>
<labelingStyle val="0"/>
<font size="18"/>
</gui>
<euclidianView>
<viewNumber viewNo="1"/>
<size width="1366" height="551"/>
<coordSystem xZero="278.80165289256183" yZero="284.2809917355373" scale="41.32231404958674" yscale="41.322314049586815"/>
<evSettings axes="false" grid="false" gridIsBold="false" pointCapturing="3" rightAngleStyle="1" checkboxSize="26" gridType="3"/>
<bgColor r="255" g="255" b="255"/>
<axesColor r="0" g="0" b="0"/>
<gridColor r="192" g="192" b="192"/>
<lineStyle axes="1" grid="0"/>
<axis id="0" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
</euclidianView>
<kernel>
<uses3D val="true"/>
<continuous val="false"/>
<usePathAndRegionParameters val="true"/>
<decimals val="2"/>
<angleUnit val="degree"/>
<algebraStyle val="0" spreadsheet="0"/>
<coordStyle val="0"/>
</kernel>
<tableview min="-2" max="2" step="1"/>
<scripting blocked="false" disabled="false"/>
<construction title="" author="" date="">
<expression label="iterMax" exp="300"/>
<element type="numeric" label="iterMax">
<value val="300"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
<layer val="0"/>
<labelMode val="1"/>
<fixed val="true"/>
</element>
<expression label="inputV" exp="912"/>
<element type="numeric" label="inputV">
<value val="912"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
<layer val="0"/>
<labelMode val="1"/>
<animation speed="1" type="0" playing="false"/>
</element>
<expression label="f" exp="f(x) = If[floor(x / 2) - x / 2 ≟ 0, x / 2, (3 * x) + 1]" type="function"/>
<element type="function" label="f">
<show object="false" label="true" ev="4"/>
<objColor r="0" g="0" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
</element>
<command name="LaTeX">
<input a0="f" a1="true" a2="true"/>
<output a0="text1"/>
</command>
<element type="text" label="text1">
<show object="true" label="true" ev="8"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<bgColor r="255" g="250" b="205" alpha="255"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<isLaTeX val="true"/>
<font serif="false" sizeM="1" size="0" style="0"/>
<auxiliary val="true"/>
<startPoint x="3.9031999999999956" y="5.758000000000001" z="1"/>
</element>
<command name="IterationList">
<input a0="f" a1="inputV" a2="iterMax"/>
<output a0="vList"/>
</command>
<element type="list" label="vList">
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="5"/>
<pointStyle val="0"/>
<angleStyle val="0"/>
</element>
<command name="Textfield">
<input a0="inputV"/>
<output a0="InputBox1"/>
</command>
<element type="textfield" label="InputBox1">
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelOffset x="40" y="54"/>
<labelMode val="0"/>
<fixed val="true"/>
<auxiliary val="true"/>
<font serif="false" sizeM="1.4" size="8" style="0"/>
<length val="7"/>
<caption val="初始值"/>
</element>
<command name="IndexOf">
<input a0="1" a1="vList"/>
<output a0="steps"/>
</command>
<element type="numeric" label="steps">
<value val="37"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
</element>
<command name="Take">
<input a0="vList" a1="1" a2="steps"/>
<output a0="vMinList"/>
</command>
<element type="list" label="vMinList">
<objColor r="0" g="100" b="0" alpha="0.10000000149011612"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<lineStyle thickness="5" type="0" typeHidden="1"/>
<pointSize val="5"/>
<pointStyle val="0"/>
<angleStyle val="0"/>
</element>
<command name="Max">
<input a0="vMinList"/>
<output a0="maxL1"/>
</command>
<element type="numeric" label="maxL1">
<value val="912"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
</element>
<expression label="text3" exp=""计算过程=" + (LaTeX[vMinList]) + """ />
<element type="text" label="text3">
<show object="true" label="true" ev="8"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<bgColor r="175" g="238" b="238" alpha="255"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<isLaTeX val="true"/>
<font serif="false" sizeM="1" size="0" style="0"/>
<startPoint x="-5.706400000000003" y="3.3706" z="1"/>
</element>
<expression label="text2" exp=""迭代次数=" + (LaTeX[steps]) + ",最大值=" + (LaTeX[maxL1]) + """ />
<element type="text" label="text2">
<show object="true" label="true" ev="8"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<bgColor r="255" g="192" b="203" alpha="255"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="1" size="0" style="0"/>
<startPoint x="-5.706400000000004" y="4.1934000000000005" z="1"/>
</element>
<expression label="text4" exp=""Collatz\; Conjecture(考拉兹猜想):""/>
<element type="text" label="text4">
<show object="true" label="false" ev="40"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<bgColor r="255" g="250" b="205" alpha="255"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="1" size="0" style="1"/>
<startPoint x="3.900999999999999" y="6.710199999999998" z="1"/>
</element>
<expression label="B" exp="Corner[2] + (-0.5, 0.5)" type="point" />
<element type="point" label="B">
<show object="true" label="false" ev="4"/>
<objColor r="68" g="68" b="68" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<coords x="25.83440000000003" y="-5.978799999999991" z="1"/>
<pointSize val="2"/>
<pointStyle val="0"/>
</element>
<expression label="A" exp="Corner[1] + (0.5, 0.5)" type="point" />
<element type="point" label="A">
<show object="true" label="false" ev="8"/>
<objColor r="68" g="68" b="68" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<coords x="-6.271200000000003" y="-5.978799999999991" z="1"/>
<pointSize val="2"/>
<pointStyle val="0"/>
</element>
<expression label="C" exp="Corner[3] + (-0.5, -5)" type="point" />
<element type="point" label="C">
<show object="true" label="false" ev="4"/>
<objColor r="68" g="68" b="68" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<coords x="25.83440000000003" y="1.9037999999999968" z="1"/>
<pointSize val="2"/>
<pointStyle val="0"/>
</element>
<expression label="D" exp="Corner[4] + (0.5, -5)" type="point" />
<element type="point" label="D">
<show object="true" label="false" ev="4"/>
<objColor r="68" g="68" b="68" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<coords x="-6.271200000000003" y="1.9037999999999968" z="1"/>
<pointSize val="2"/>
<pointStyle val="0"/>
</element>
<expression label="width" exp="x(B) - x(A)" />
<element type="numeric" label="width">
<value val="32.10560000000003"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
</element>
<expression label="high" exp="y(C) - y(B)" />
<element type="numeric" label="high">
<value val="7.882599999999988"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
</element>
<command name="Sequence">
<input a0="A + ((k / steps, 0) * width)" a1="k" a2="0" a3="steps"/>
<output a0="l1"/>
</command>
<element type="list" label="l1">
<show object="true" label="true" ev="4"/>
<objColor r="0" g="100" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<lineStyle thickness="5" type="0" typeHidden="1"/>
<pointSize val="2"/>
<pointStyle val="0"/>
<angleStyle val="0"/>
</element>
<expression label="vDisplayList" exp="(vMinList * high / maxL1)" />
<element type="list" label="vDisplayList">
<objColor r="0" g="100" b="0" alpha="0.10000000149011612"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<lineStyle thickness="5" type="0" typeHidden="1"/>
<pointSize val="5"/>
<pointStyle val="0"/>
<angleStyle val="0"/>
</element>
<command name="Zip">
<input a0="(x(p), y(A) + q)" a1="p" a2="l1" a3="q" a4="vDisplayList"/>
<output a0="l2"/>
</command>
<element type="list" label="l2">
<show object="true" label="true" ev="4"/>
<objColor r="0" g="0" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<lineStyle thickness="5" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="6"/>
<angleStyle val="0"/>
</element>
<command name="PolyLine">
<input a0="l2"/>
<output a0="g"/>
</command>
<element type="polyline" label="g">
<lineStyle thickness="9" type="0" typeHidden="1" opacity="178"/>
<show object="true" label="false" ev="4"/>
<objColor r="255" g="127" b="0" alpha="0"/>
<layer val="1"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
</element>
<command name="Polygon">
<input a0="A" a1="B" a2="C" a3="D"/>
<output a0="q1" a1="a" a2="b" a3="c" a4="d"/>
</command>
<element type="polygon" label="q1">
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
<show object="true" label="false" ev="4"/>
<objColor r="0" g="0" b="0" alpha="0.20999999344348907"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
</element>
<element type="segment" label="a">
<show object="true" label="false" ev="4"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<coords x="0" y="32.10560000000003" z="191.9529612799999"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<element type="segment" label="b">
<show object="true" label="false" ev="4"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<coords x="-7.882599999999988" y="0" z="203.6422414399999"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<element type="segment" label="c">
<show object="true" label="false" ev="4"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<coords x="0" y="-32.10560000000003" z="61.12264127999997"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<element type="segment" label="d">
<show object="true" label="false" ev="4"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<fixed val="true"/>
<selectionAllowed val="false"/>
<auxiliary val="true"/>
<coords x="7.882599999999988" y="0" z="49.433361119999944"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
</construction>
</geogebra>