File:Ulam4004001.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(4,001 × 4,001 pixels, file size: 687 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: An Ulam Spiral for numbers from 1 to 16008001. Note that in this picture, the number 1 is coloured black even though it is, by convention, not prime. Also, note that the image is rotated by 90 degrees clockwise when compared with this picture.
Date
Source Own work
Author Purpy Pupple

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following licenses:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
You may select the license of your choice.

Matlab Code

[edit]

The image was generated with MATLAB in 1600 seconds. Here's my remarkably clunky and inefficient code:

function spiral

   n=2000;
   A=zeros(2*n+1);
   B=A;
   x=n+1;
   y=x;
   A(x,y)=true;
   B(x,y)=true;
   direction=1;
   for i=2:(2*n+1)^2
       switch direction
           case 1
               x=x+1;
               B(x,y)=true;
               A(x,y)=isprime(i);
               if ~B(x,y+1)
                   direction=2;
               end
           case 2
               y=y+1;
               B(x,y)=true;
               A(x,y)=isprime(i);
               if ~B(x-1,y)
                   direction=3;
               end
           case 3
               x=x-1;
               B(x,y)=true;
               A(x,y)=isprime(i);
               if ~B(x,y-1)
                   direction=4;
               end
           case 4
               y=y-1;
               B(x,y)=true;
               A(x,y)=isprime(i);
               if ~B(x+1,y)
                   direction=1;
               end            
       end
   end
   imwrite(imresize(~A,3,'nearest'),['output' num2str(n) '.png'],'png');

end

File history

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

Date/TimeThumbnailDimensionsUserComment
current03:28, 3 February 2011Thumbnail for version as of 03:28, 3 February 20114,001 × 4,001 (687 KB)Dllu (talk | contribs)Resized back to the correct size (the original uploaded version was needlessly enlarged by 3x)
08:11, 24 December 2010Thumbnail for version as of 08:11, 24 December 201012,003 × 12,003 (1.15 MB)Dllu (talk | contribs){{Information |Description={{en|1=An Ulam Spiral for numbers from 1 to 4004001.}} |Source={{own}} |Author=Purpy Pupple |Date=2010-12-23 |Permission= |other_versions= }}

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file: