Jump to content

File:Collatz-graph-20-iterations.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (SVG file, nominally 1,440 × 1,406 pixels, file size: 520 KB)

Summary

Description
English: This is a graph, generated in bottom-up fashion, of the orbits of all numbers under the Collatz map with an orbit length of 20 or less.

Created with Graphviz, with the help of this Python program:

 # This python script generates a graph that shows 20 levels of the Collatz Conjecture.
 
 level = [1] # The root of the tree contains only "1"
 results = {} # This will hold the relationships for the graph
 
 # Loop 20 times
 for c in range(20):
     newlevel = set() # This will be the set of numbers in the level above us
     for x in level: # We now loop through each number in our current level
 
         # There will only sometimes be an odd multiple of 3 (plus one) above us
         # When (x-1) mod 3 is 0, x is an even number half the time
         # So we check against (x-4) mod 6 because we don't want to find evens
         odd = (x-1)/3 if not (x-4)%6 else 0
         if odd > 1: # We don't want 1 (the root) or 0 (no odd found)
             newlevel.add(odd) # Put this into the next level
             results[odd] = x # Add a relationship to the graph
 
         newlevel.add(x*2); # There will always be an even number above us
         results[x*2] = x # Add a relationship to the graph
 
     # Finally, advance to the next level
     level = newlevel
 
 # Technically, 1 is odd so 1*3+1 = 4. If included though, this tends to make 2 and 1 overlap on the graph, which is ugly.
 # Uncomment to include this relationship:
 # results[1] = 4;
 
 # Now we write the graph out to a file in dot format so that graphviz can read it
 f = open('collatz.dot', 'w')
 # For aesthetic reasons we set 8 as the centre node instead of 1
 f.write('digraph G {\n    size="16,16";\n    root=8;\n    splines=true;\n')
 for x in results:
     f.write("    %d -> %d;\n" % (x, results[x]))
 f.write('}\n')
 f.close()
 print "Generated %d nodes" % len(results)
Date 7 March 2010 (original upload date)
Source Transferred from en.wikipedia to Commons by Derlay using CommonsHelper.
Author TerrorBite at English Wikipedia

Licensing

Public domain This work has been released into the public domain by its author, TerrorBite at English Wikipedia. This applies worldwide.
In some countries this may not be legally possible; if so:
TerrorBite grants anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

Original upload log

The original description page was here. All following user names refer to en.wikipedia.
  • 2010-03-07 16:29 TerrorBite 1440×1406× (532396 bytes) This is a graph, generated in bottom-up fashion, of the orbits of all numbers under the Collatz map with an orbit length of 20 or less. Created with [[Graphviz]], with the help of this [[Python (programming language)|Python]] program: # This python sc

Captions

Add a one-line explanation of what this file represents

Éléments décrits dans ce fichier

depicts

7 March 2010

image/svg+xml

e228f25d455662fa61e6e4f16b60ef24be090161

532,396 byte

1,406 pixel

1,440 pixel

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current10:00, 25 May 2010Thumbnail for version as of 10:00, 25 May 20101,440 × 1,406 (520 KB)Derlay{{Information |Description={{en|This is a graph, generated in bottom-up fashion, of the orbits of all numbers under the Collatz map with an orbit length of 20 or less. Created with en:Graphviz, with the help of this [[:en:Python (programming langua
No pages on the English Wikipedia use this file (pages on other projects are not listed).

Global file usage

The following other wikis use this file: