Let's not do this all by hand

 May 13th 2012 release below, Version 3.1:

Development language:   C#
 .NET requirements:   Minimum of .NET Version 2
Compiled and Tested on:   Vista 32 bit Home professional

Download Version 3.1

note: If you have already installed the previous version you must uninstall it before installing this new version.

This version is capable of generating images up to 10 Gigapixels in size... 100,000 x 100,000 pixels. It can be easily enhanced to create larger spiral images but the practical matter of viewing the resulting image becomes difficult. You can see the 10 Gigapixel Ulam spiral on this website here.

John Conway's 'Game of Life' is also implemented in this version for a bit of fun... I had always wanted to see the result of running the game of life on an Ulam Spiral and I finally got around to it.

Ulam Spirals larger than 46,340 pixels will be generated as multiple slices... horizontal slices that are output from the top to bottom:

[ Slice 1]
[ Slice 2]
[ Slice 3]

To generate a 10 Gigapixel spiral I did the following (these settings are required to work with HD View from Microsoft, which requires 8 bits per pixel and white pixels on a black background).

  1. Check the 'Invert Colours' checkbox
  2. Select a Zoom of 1
  3. Check the '8 bits per pixel' checkbox
  4. Select the size 100000... if you have not already checked 'Bypass Screen' you should say 'yes' to the prompt that appears.
  5. Click 'Start...' and you will be informed that the process will need to create 5 slices.
  6. If you continue and your PC has enough free memory the application will proceed to create the image slices.... be patient, this could take a while.
  7. Upon completion the 'Save' dialogue will appear... you need to save all 5 image slices, give them a suitable name like 'Slice1.tiff', 'Slice2.tiff'... etc.
  8. You need to combine the image slices somehow. I used HD View from Microsoft... the following command stiched the slices together for me and created a web based viewer interface:
    "C:\UlamSpiral\hdmake.exe" -nozip -extension png -html -srcgrid 1 5 "C:\UlamSpiral\Slice1.tiff" "C:\UlamSpiral\Slice2.tiff" "C:\UlamSpiral\Slice3.tiff" "C:\UlamSpiral\Slice4.tiff" "C:\UlamSpiral\Slice5.tiff"


Software Version 3.0

Software Version 3.0





First public release below, Version 3.0:

Development language:   C#
 .NET requirements:   Minimum of .NET Version 2
Compiled and Tested on:   Vista 32 bit Home professional
 Download:    Download Version 3

Software Version 3.0



Old version below, not publicly released as it was an prototyping version... written in a largely defunct language Visual Basic 6.0.

Software Version 2.1

The above is a screenshot of my software (which seems to evolve every time I work with it... I will try to keep this section up to date) after generating the first Ulam spiral. It is written in a language that allows quick protyping, with the sacrifice of some speed. I needed the ability to quickly change things as I experimented with different methods of creating Ulam spirals. There is more prototyping to be done, but after reaching a stable state and conversion to a faster language the software will be made available.

The software currently uses the Sieve of Eratosthenes to identify primes. There are faster way to identify primes but the performance improvement will not have an impact on the actual process of generating the Ulams, only in the inital loading of the software... it takes 0.7 seconds to find all primes in the first 1 Million integers (which is enough for a 1000 x 1000 Ulam spiral) on my old Pentium so making this more efficient is not really a priority.

The controls on the left panel going from the top down are:

1. The size of the Ulam spiral being created. The software lets you resize arbitrarily but it is handy to be able to define specific sizes, especially when creating images for websites ;-)

2. The integer that is the centre of the Ulam spiral

3. Some people don't consider the number one to be prime, this option lets you decide where you stand on that one

4. Rendering the number 1 in red helps when doing image analysis... it serves as a reference point / marker

5. X Axis movement. This controls the movement of the centre of the Ulam spiral though each Iteration

6. Y Axis movement. Same as 5. but for the Y Axis

7. This option allows you to start at an arbitrary iteration of the Ulam spiral

8. When rendering overlaid Ulam spirals you might want the software to automatically stop after a certain number of Iterations

9. The iteration step control allows you to skip iteration steps, for example allow you to render every 5th Ulam Iteration

10. Take pictures... when ticked the software will save a picture of the rendering screen after each Iteration is finished rendering. The image is first saved as a .bmp and a background process converts this to an optimized .gif and removes the .bmp

11. The create animated .gif option instructs the software to join together all the .gif images that are saved to produce a single animated .gif file

12. When the clear screen option is checked the rendering area is cleared between each Ulam Iteration... good for watching the evolution of the Ulam spiral as it progresses through the integer spiral iterations

13. Go easy on the CPU means give the PC a chance to breathe... the software can run at 100% CPU and will get to the finish line faster, but my poor old PC can get a bit over heated if I run at max speed for too long so I thought I'd be a bit considerate.

14. Invert color tells the software to render the primes as white pixels on a black background

15. The zoom setting tells the software to draw filled squares rather than single pixels... effectively zooming into the spiral. 2 x 2 filled square for 2 x zoom, 4 x 4 square for 4 x zoom... etc.

16. The delay setting allows you to set a delay in millseconds between each ulam iteration being rendered

17. The show numbers options tells the software to render the actual numbers in their location on the spiral... this setting will only take effect when zooming in to a certain level as there just isn't room to render them before that, even at a ridiculously small font

Copyright © 2007 - H Rudd