Primify – esoteric.codes


Starting search for prime.
Note that in this instance we would expect to run
about 13799 primality tests.
Found!
Did ~2291 primality tests
77777777777777777777777777777777777777777777777777777777777777777777777777777
77777777777777777777777777777777779888388897777777777777777777777777777777777
77777777777777777777777779111111111111111111111111197777777777777777777777777
77777777777777777777711111111111111111111111111111111111777777777777777777777
77777777777777777911111111111111111111111111111111111111111977777777777777777
77777777777777711111111111111111111111111111111111111111111111777777777777777
77777777777791111117777311111111111111111111111111111877771111119777777777777
77777777777111111177777777791111111111111111111117777777777111111177777777777
77777777711111111177777777777777777777777777777777777777777111111111777777777
77777777111111111177777777777777777777777777777777777777777111111111177777777
77777791111111111117777777777777777777777777777777777777773111111111119777777
77777711111111111177777777777777777777777777777777777777777811111111111777777
77777111111111117777777777777777777777777777777777777777777771111111111177777
77771111111111177777777777777777777777777777777777777777777777111111111117777
77771111111111177777777777777777777777777777777777777777777777311111111117777
77771111111111777777777777777777777777777777777777777777777777711111111117777
77781111111111777777777777777777777777777777777777777777777777711111111118777
77781111111111877777777777777777777777777777777777777777777777811111111118777
77771111111111177777777777777777777777777777777777777777777777111111111117777
77771111111111117777777777777777777777777777777777777777777771111111111117777
77773111111111111877777777777777777777777777777777777777777811111111111137777
77777111111111111113777777777777777777777777777777777777731111111111111177777
77777711111111111111111777777777777777777777777777777711111111111111111777777
77777771111117777711111111113837777777777777773831111111111111111111117777777
77777777111111117777111111111117777777777777771111111111111111111111177777777
77777777781111111777773111111187777777777777779111111111111111111118777777777
77777777777111111177777777777777777777777777779111111111111111111177777777777
77777777777771111111877777777777777777777777779111111111111111117777777777777
77777777777777781111111111111137777777777777779111111111111118777777777777777
77777777777777777781111111111137777777777777778111111111118777777777777777777
77777777777777777777773111111197777777777777779111111137777777777777777777777
77777777777777777777777777789777777777777777777788777777777777777777777777777
77777777777777777777777777777777777777777777777777777777777777777777777784651

Primify takes an image and embeds it into a prime number, so that, when viewed from a distance, it resembles the original image. It was created by Levi Borodenko, a masters student in mathematics and statistics at the University of Oxford. While it works particularly well for logos and simple line art, was actually first developed for portraits.

The idea came while I was a counselor at PROMYS — a summer camp providing an immersion into rigorous mathematics. We had a secret Santa and me being a poor student, I tried to come up with a gift idea that would light a maths majors heart without being pricey. So I decided to find a prime that looked like the face of the person that I had to gift. I coded up a quick and dirty script (back then I was using python to find the number and then mathematica to find the next prime). After doing this for a few years I decided that more people should be able to enjoy generating these primes. This is when I coded up the open-source tool.

In primify, the underlying data is not only used in a graphical way, but also holds information when read as text; in this case, a single prime number. This is multicoding, where content holds multiple meanings when read in different systems. It’s a strategy familiar not only from esolangs like legit, which multicodes between git commands and code, and polyglots, where one program executes successfully in multiple programming languages. The strategy here, where the text functions as a picture, is more akin to how multicoding functions in obfuscated code that builds on concrete poetics, where the opacity of the code is offset with a visual clue as to its function. We can see this in the example cited here by Adrian Cables, or the cauldron example in this post about the IOCCC. The term multicoding comes from the seminal paper on esolangs and code art, “A Box Darkly” by Matteas and Montfort (as “multiple coding”).

Where obfuscated code can use whitespace (quite indiscriminately when it’s in C), this is not an option when the text is a number. Primify has access only to the ten digit symbols, which are presented without breaks — so its visual strategy comes from ASCII art, where each pixel (after resizing) is represented by one character. The choices of digits selected by their relative density, to represent different shadings. Borodenko uses only the digits with the most distinct grayness values: 1, 7, 3, 9, and 8 (in that order). To prepare the image, primify runs image processing steps like edge enhancement and smoothing, and then quantizes the image into grayness levels corresponding to the palette of those five numbers.

But, as Borodenko points out, not only does ASCII art have a large variety of different characters (“,” and “@” instead of just “1” and “7”, etc) but also usually turns images into strings of the order of 25,000 – 40,000 characters. This would create far too large a number to find a close prime in a reasonable amount of time, and so creates an additional challenge for primify.

For primify the numbers should not exceed 17,000 as otherwise it is simply very hard to find a nearby prime as the primality tests take a long time and more of them are needed. Thus, we face the problem of creating a small resolution ASCII art using only numbers. Here is where only using 5 characters comes in. 5 and 6 for example create a very similar shade and with the small space that we have, that simply does not provide a visible difference.

I use sympy for primality checking. If the number is larger than 2^64, then a strong BPSW test is performed. While this is a probable prime test and we believe counterexamples exist, there are no known counterexamples. So if primify returns a prime that is actually not a prime, you get to publish a paper as a consolation price 😉

The images with simple line art seem to work the best. The strategy for how the edges are determined can be set with the “method” argument, but images with large fields of color (I attempted several Josef Albers Homage to the Square paintings) seem to gain excessive edges due to the enhancements. Logos like the github one above work quite well, as do some portraits.

The size of the image determines how long it takes to find an appropriate prime. If you want a very large prime, to get the most density of digits, you may be in for a long wait.

It may very well be that the next number after the generated number is prime so the tool may run VERY quickly. However, it is known that the gaps between primes are unbounded. Take for example n = 2 x 3 x 4 x …. x 1000 + 1, then the next 1000 number will not be prime as n+1 will be divisible by 2, n+2 by 3 etc.. So the program may take a loooong time. Thankfully we know that there are infinity many primes – so at least we have a guarantee that the code will halt 😛

In my experience, the numbers have about 5000 digits to be reasonable easy to compute in <30min. between 7000 and 10000 may take 1-3h or even longer if you are unlucky.

Apart from primify, Borodenko developed Best Circle, a fun app that evaluates how well you can awkwardly draw a circle with a mouse (for people who don’t use drawing tablets). And has a great landing page for his website; net artists take note!

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111837777377777777777777379111111111111111111111111111111111
11111111111111111111111111118999883939993773333333333977711111111111111111111111111111111
11111111111111111111111118999999887999911199999999889777777811111111111111111111111111111
11111111111111111111888899888899887777777997738999333993373731111111111111111111111111111
11111111111111111117811888888188893788377779837777733981933337911111111111111111111111111
11111111111111111113799811893333399399399939999999377777799337739111111111111111111111111
11111111111111111111333338333333339118989999333333399937777333977381111111111111111111111
11111111111111111119887739338881111888811111111188893738189778877771111111111111111111111
11111111111111111118897199881118888888888888888881111113381173377311111111111111111111111
11111111111111111113377111111111111111111111111111111897777818739111111111111111111111111
11111111111111111118731111183777777777739988811188939339813771931111111111111111111111111
11111111111111111111118777777777777777777777777773398898398877111111111111111111111111111
11111111111111111111937799993393333933373337333399899991117789711111111111111111111111111
11111111111111111111111878877777773373937777399999999899819988111111111111111111111111111
11111111111111111111111189999899999999998893333399998899911177911111111111111111111111111
11111111111111111111111183378999999999998939888888899988981197711111111111111111111111111
11111111111111111111111119998399999999998899388888998999931133311111111111111111111111111
11111111111111111111111119898333333399988791893933399989899999111111111111111111111111111
11111111111111111111111113779989999999977777789339939889899738111111111111111111111111111
11111111111111111111111119799377777777777777773189399889371881111111111111111111111111111
11111111111111111111111111398777399399981888977388988893311111111111111111111111111111111
11111111111111111111111111339338889999999998818998998899111111111111111111111111111111111
11111111111111111111111111199988999999988899998833998931111111111111111111111111111111111
11111111111111111111111111119998889398998938893337398991111111111111111111111111111111111
11111111111111111111111111137373889999993999999933889983731111111111111111111111111111111
11111111111111111111111187773377798937773377798199898817777778111111111111111111111111111
11111111111111111111111777333337777999377737777889988897997777771111111111111111111111111
11111111111111111111137733333333777773993399897789998877399777777791111111111111111111111
11111111111111119337773999333333333777799999999738899373339973777777781111111111111111111
11111111897777777773333333333333333337773999998373933777339977997777777731111111111111111
11189993333999999393333333333333333337377373339881899339997737799377773377711111111111111
89339888393933393333333333333333333337993777777777118377777797739937777933777911111111111
98881181889888883333333333333337333373999377777777737773777793733993777333337777338111111
98888888889888999933333333333333333339999933333337333333773773773393377333333333340004297

Jonas Mekas in clown hat and clown nose (squint and you can see it!), primified



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *