Attachment 'CollatzConjecture.rst'

Download

The 3n+1 Conjecture

Authors: Franco Saliola
Vincent Delecroix

The 3n + 1 conjecture is an unsolved conjecture in mathematics. It is named after Lothar Collatz, who first proposed it in 1937. It is also known as the Collatz conjecture , as the Ulam conjecture (after Stanislaw Ulam), or as the Syracuse problem .

The 3n+1 operation

Consider the following operation on positive integers n .

  • If n is even, then divide it by 2 .
  • If n is odd, then multiply it by 3 and add 1 .

For example, if we apply this transformation to 6 , then we get 3 since 6 is even; and if we apply this operation to 11 , then we get 34 since 11 is odd.

Exercise: Write a function that implements this operation, and compute the images of 1, 2, ..., 100.

Statement of the conjecture

If we start with n = 6 and apply this operation, then we get 3 . If we now apply this operation to 3 , then we get 10 . Applying the operation to 10 outputs 5 . Continuing in this way, we get a sequence of integers. For example, starting with n = 6 , we get the sequence

6, 3, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 1, …

Notice that this sequence has entered the loop 4↦2↦1↦4. The conjecture is

3n+1 conjecture: For every n, the resulting sequence will always reach the number 1.

Exercise: Write a function that takes a positive integer and returns the sequence until it reaches 1 . For example, for 6, your function will return [6, 3, 10, 5, 16, 8, 4, 2, 1].

(hint : You might find a while loop helpful here.)

Exercise: Find the largest values in the sequences for n = 1, 3, 6, 9, 16, 27.

Exercise: Use the line or list_plot command to plot the sequence for 27 .

Exercise: Write an @interact function that takes an integer n and plots the sequence for n.

Stopping Time

The number of steps it takes for a sequence to reach 1 is the stopping time . For example, the stopping time of 1 is 0 and the stopping time of 6 is 8.

Exercise: Write a function that returns the stopping time of a positve integer n . Plot the stopping times for 1, 2, ..., 100 in a bar chart.

Exercise: Find the number less than 1000 with the largest stopping time. What is its stopping time? Repeat this for 2000, 3000, …, 10000.

Exercise: A little more challenging: could you solve Euler problem 14?

Extension to Complex Numbers

Exercise: If n is odd, then 3n + 1 is even. So we can instead consider the function T that maps n to (n)/(2), if n is even; and to (3n + 1)/(2), if n is odd. Let

f(z) = (z)/(2)cos2z(π)/(2) + ((3z + 1))/(2)sin2z(π)/(2).

Construct f as a symbolic function and use Sage to show that f(n) = T(n) for all 1 ≤ n ≤ 1000, where T is the (3n + 1)/(2)-operator. Afterwards, argue that f is a smooth extension of T to the complex plane (you have to argue that applying f to a positive integer has the same effect as applying T to that integer. You don't need Sage to do this, but it might offer you some insight!)

Exercise: Let g(z) be the complex function:

g(z) = (1)/(4)(1 + 4z − (1 + 2z)cos(πz))

Construct g as a symbolic function, and show that f and g are equal.

(hint : One way of doing this is to use a combination of .trig_expand(), .trig_reduce() and .trig_simplify().)

Exercise: Use the complex_plot command to plot the function g in the domain x =  − 5, ..., 5 and y =  − 5, ..., 5.

Exercise: Consider the composition hn(z) = (gg∘⋯∘g) (where there are n copies of g in this composition). Use complex_plot and graphics_array to plot h1, h2, h3, ..., h6 on the domain x = 1, ..., 5 and y =  − 0.5, ..., 0.5.

( hint: To speed things up or control the precision of the computations, you may want to replace pi in your equation with CDF.pi(). Type CDF? and CDF.pi? for more information.)

Exercise: Generate some really nice images of hn that illustrate the fractal-like behaviour of hn.

(hint: You may want to explore the plot_points and interpolation options for the complex_plot function.)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2018-08-12 22:01:42, 8.3 KB) [[attachment:CollatzConjecture.ipynb]]
  • [get | view] (2018-08-12 22:01:45, 100.9 KB) [[attachment:CollatzConjecture.pdf]]
  • [get | view] (2018-08-12 22:01:49, 4.8 KB) [[attachment:CollatzConjecture.rst]]
  • [get | view] (2018-08-12 22:01:53, 12.3 KB) [[attachment:Dictionaries-GraphTheory.ipynb]]
  • [get | view] (2018-08-12 22:01:56, 202.6 KB) [[attachment:Dictionaries-GraphTheory_Solutions.pdf]]
  • [get | view] (2018-08-12 22:02:00, 9.1 KB) [[attachment:Dictionaries-GraphTheory_Solutions.rst]]
  • [get | view] (2018-08-15 12:32:58, 16.0 KB) [[attachment:Fields-2018-flatsurf_and_surface_dynamics_demo.ipynb]]
  • [get | view] (2018-08-11 19:25:37, 15.0 KB) [[attachment:S_2_1.svg]]
  • [get | view] (2018-08-12 22:02:10, 13.4 KB) [[attachment:Strings-BWT.ipynb]]
  • [get | view] (2018-08-12 22:02:14, 72.4 KB) [[attachment:Strings-BWT.pdf]]
  • [get | view] (2018-08-12 22:02:17, 7.0 KB) [[attachment:Strings-BWT.rst]]
  • [get | view] (2018-08-11 19:28:42, 16.7 KB) [[attachment:chap1-first_steps.ipynb]]
  • [get | view] (2018-08-11 19:28:46, 103.1 KB) [[attachment:chap1-first_steps.pdf]]
  • [get | view] (2018-08-11 19:28:53, 7.8 KB) [[attachment:chap1-first_steps.rst]]
  • [get | view] (2018-08-11 19:29:05, 24.6 KB) [[attachment:chap1-first_steps_solutions.ipynb]]
  • [get | view] (2018-08-11 19:29:09, 108.7 KB) [[attachment:chap1-first_steps_solutions.pdf]]
  • [get | view] (2018-08-11 19:29:12, 12.0 KB) [[attachment:chap1-first_steps_solutions.rst]]
  • [get | view] (2018-08-11 19:29:17, 30.8 KB) [[attachment:chap2-list_and_for.ipynb]]
  • [get | view] (2018-08-11 19:29:23, 110.0 KB) [[attachment:chap2-list_and_for.pdf]]
  • [get | view] (2018-08-11 19:29:26, 17.6 KB) [[attachment:chap2-list_and_for.rst]]
  • [get | view] (2018-08-11 19:29:32, 42.0 KB) [[attachment:chap2-list_and_for_Solutions.ipynb]]
  • [get | view] (2018-08-11 19:29:35, 116.1 KB) [[attachment:chap2-list_and_for_Solutions.pdf]]
  • [get | view] (2018-08-11 19:29:38, 25.6 KB) [[attachment:chap2-list_and_for_Solutions.rst]]
  • [get | view] (2018-08-11 19:29:51, 21.1 KB) [[attachment:chap3-if-solutions.ipynb]]
  • [get | view] (2018-08-11 19:29:58, 95.4 KB) [[attachment:chap3-if-solutions.pdf]]
  • [get | view] (2018-08-11 19:29:55, 9.0 KB) [[attachment:chap3-if-solutions.rst]]
  • [get | view] (2018-08-11 19:29:41, 11.8 KB) [[attachment:chap3-if.ipynb]]
  • [get | view] (2018-08-11 19:29:45, 91.6 KB) [[attachment:chap3-if.pdf]]
  • [get | view] (2018-08-11 19:29:48, 5.7 KB) [[attachment:chap3-if.rst]]
  • [get | view] (2018-08-11 19:30:02, 4.4 KB) [[attachment:chap4-functions.ipynb]]
  • [get | view] (2018-08-11 19:30:06, 83.1 KB) [[attachment:chap4-functions.pdf]]
  • [get | view] (2018-08-11 19:30:09, 2.3 KB) [[attachment:chap4-functions.rst]]
  • [get | view] (2018-08-11 19:30:20, 3.2 KB) [[attachment:chap5-while.ipynb]]
  • [get | view] (2018-08-11 19:30:14, 62.1 KB) [[attachment:chap5-while.pdf]]
  • [get | view] (2018-08-11 19:30:39, 1.5 KB) [[attachment:chap5-while.rst]]
  • [get | view] (2018-08-11 19:30:47, 4.0 KB) [[attachment:chap6-advanced_exercises.ipynb]]
  • [get | view] (2018-08-11 19:30:53, 69.7 KB) [[attachment:chap6-advanced_exercises.pdf]]
  • [get | view] (2018-08-11 19:31:00, 2.0 KB) [[attachment:chap6-advanced_exercises.rst]]
  • [get | view] (2018-08-12 22:02:04, 90.9 KB) [[attachment:euler.png]]
  • [get | view] (2018-08-13 21:52:57, 1.1 KB) [[attachment:flipper_nf_conversion.py]]
  • [get | view] (2018-08-15 12:18:55, 55.4 KB) [[attachment:flipper_tutorial.pdf]]
  • [get | view] (2018-08-12 21:56:57, 16.1 KB) [[attachment:floating_point_and_stability.ipynb]]
  • [get | view] (2018-08-12 21:57:01, 78.0 KB) [[attachment:floating_point_and_stability.pdf]]
  • [get | view] (2018-08-12 21:57:04, 6.6 KB) [[attachment:floating_point_and_stability.rst]]
  • [get | view] (2018-08-12 22:02:07, 17.6 KB) [[attachment:graph0.png]]
  • [get | view] (2018-08-11 23:44:38, 23.2 KB) [[attachment:intro.en.ipynb]]
  • [get | view] (2018-08-11 23:44:45, 117.5 KB) [[attachment:intro.en.pdf]]
  • [get | view] (2018-08-11 23:44:53, 12.5 KB) [[attachment:intro.en.rst]]
  • [get | view] (2018-08-12 23:25:35, 62.3 KB) [[attachment:logistic_orbit_interact.png]]
  • [get | view] (2018-08-11 19:48:34, 9.6 KB) [[attachment:random_walk.ipynb]]
  • [get | view] (2018-08-11 19:48:38, 87.9 KB) [[attachment:random_walk.pdf]]
  • [get | view] (2018-08-11 19:48:44, 5.7 KB) [[attachment:random_walk.rst]]
  • [get | view] (2018-08-15 19:25:46, 67.3 KB) [[attachment:real_and_complex_numbers.ipynb]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.