Tikalon Header Blog Logo

Shakespearean Monkeys

September 20, 2021

Since the middle of the 19th century, English playwright, poet, and actor, William Shakespeare (1564-1616) is regarded as the greatest writer in the English language. His authorship of plays is easily explained as a means to secure steady employment as an actor. However, the idea that a mere actor could be such a great author wasn't accepted by the academic elite, who thought his plays were written by a more skilled author, possibly an educated nobleman or courtier who desired anonymity. I'm in good company with the vast majority of Shakespeare scholars who reject this theory. We also have the example of a mere teacher, J. K. Rowling (b. 1965), who wrote the highly successful Harry Potter books.

Among the possible authors of Shakespeare's works are Francis Bacon (1561-1626), one of the developers of the scientific method about whom I've written in this blog (400 Years of the Novum Organum, July 6, 2020). Another is English playwright, Christopher Marlowe (1564-1593). Mark Twain, as revealed in his 1909 book, Is Shakespeare Dead?, agreed with the theory that Bacon was the author of Shakespeare's works.

Cobbe portrait of William Shakespeare

The Cobbe portrait of William Shakespeare (1564-1616), thought to have been painted circa 1610, during his lifetime.

The Cobbe portrait is similar in likeness to the Droeshout engraving of Shakespeare that appears in the First Folio of 1623, albeit with a little more hair.

In 2016, BBC television produced a satirical television sitcom about Shakespeare's life called the Upstart Crow to commemorate the 400th anniversary of his death.[1] Christopher Marlowe was a character in this series, which jokes about Shakespeare being the actual author of some of Marlowe's plays.

The Upstart Crow title comes from its use by playwright and poet, Robert Greene, in a 1592 pamphlet that marks Shakespeare as "an upstart Crow, beautified with our feathers."

(Via Wikimedia Commons.)

Most people are familiar with the infinite monkey theorem that proposes that a monkey hitting keys at random on a typewriter for an infinite amount of time would reproduce the complete works of Shakespeare. Although the text of Hamlet has 132680 alphabetic characters,[2] infinity makes many things mathematically possible, and this theorem is mathematically proven. However, reality is working against the infinite time postulate of this theorem, since the universe appears to have a finite lifetime, and even a slight probability of a monkey's success would require a time many hundreds of thousands of orders of magnitude longer than the age of the universe.

The Shakespearean monkey acts as a physical source of randomness, but computers can generate randomness much more quickly at a cost of far fewer bananas. An average banana is a source of 105 food calories, or 105 physics kilocalories. Since a kcal is equivalent to 1.162 watt-hour, this is 122 watt-hours, which is enough to fuel a desktop computer for about half an hour. The mathematical constant, pi, has been computed to tens of trillions of digits through the aid of rapidly convergent series. While the digits of the pi have not been proven to be normally distributed, statistical analysis shows that they are random to a high degree. We can use the digits of pi as our source of randomness, but the problem remains as to how to convert pi to alphabet characters.

Digits of pi are found at many places on the Internet in either its decimal (radix 10) or hexadecimal (radix 16) form. The first few decimal and hexadecimal digits of pi are as follow:


If we limit ourselves to just lowercase letters, our problem becomes the conversion of a list of radix 10 digits of pi to radix 26. While this operation is mathematically quite simple, most computer programming languages calculate with limited precision and the simple operation will fail after just a few digits. Fortunately, there are arbitrary precision code libraries that allow complete conversion. I used the GNU Multiple Precision Floating-Point Reliable Library (GNU MPFR) in a simple C language program to accomplish this conversion for the first million decimal digits of pi.

While this can be done in many operating systems, in my Linux system I used the gcc compiler with the libgmp3-dev and libmpfr-dev packages, and I compiled the code using the command, gcc -o pi-26 pi-26.c -lmpfr -lgmp -lm. The source code and a file of the first million decimal digits of pi can be found as a zip file here.

More powerful computers with more memory than my desktop computer could convert from more than a million decimal digits. Likewise, a spigot algorithm would give many more. Alas, my main experience with spigots involves the kitchen sink. I checked the result of this computation using data from Michael Keith's 1999 paper on the radix 26 encoding of pi.[3] To search for positions of words in the alphabetic file, I used the PHP code below (Click image for a text file of the source code). The computation matches his results as shown in the following table.

PHP search code

Word Position       Word Position
zero 389,247       six 14,295
one 10,087       seven ---
two 13,463       eight ---
three ---       nine 175,372
four 11,324       ten 15,276
five 64,838      

Keith writes that "seven" appears at position 786,958. My computation, which starts with a million decimal digits of pi, could only give about 638,200 radix 26 digits of pi, so that number was outside my range. Keith writes that Hans Haverman extracted 5 million radix 26 digits of pi and discovered the word three at position 1,556,763, and fifty at 2,300,987 and 4,896,456.[3]


  1. The Upstart Crow (2016, Matt Lipsey and Richard Boden, Directors) at the Internet Movie Database.
  2. William Shakespeare, "Hamlet, Prince of Denmark, via Project Gutenberg.
  3. Michael Keith, "The Pi Code," April, 1999. Also available here.

Linked Keywords: 19th century; English; playwright; poet; actor; William Shakespeare (1564-1616); writer; English language; authorship; play (theater); employment; academia; academic; elite; Shakespeare authorship question; education; educated; nobility; nobleman; courtier; anonymity; collegiality; good company; scholarly method; scholar; theory; teacher; J. K. Rowling (b. 1965); Harry Potter books; Francis Bacon (1561-1626); scientific method; blog; Novum Organum; Christopher Marlowe (1564-1593); Mark Twain; book; Is Shakespeare Dead?; Baconian theory of Shakespeare authorship; Cobbe portrait; oil painting; Droeshout engraving; First Folio; hair; BBC television; satire; satirical; British sitcom; television sitcom; Upstart Crow; memorialization; commemorate; anniversary; death; character (arts); joke; title (publishing); Greene's Groats-Worth of Wit; pamphlet; Wikimedia Commons; infinite monkey theorem; monkey; keyboard; key; randomness; random; typewriter; infinity; infinite; time; written language; text; Hamlet; alphabetic character; mathematics; mathematical; mathematical proof; proven; reality; axiom; postulate; universe; probability; orders of magnitude; age of the universe; physics; physical; computer; cost; banana; average; food calorie; calorie; kilocalorie; watt-hour; desktop computer; mathematical constant; pi; numerical digit; convergent series; normal distribution; normally distributed; statistics; statistical analysis; Internet; decimal; radix; hexadecimal; lowercase; programming language; significand; precision; arbitrary-precision arithmetic; GNU Multiple Precision Floating-Point Reliable Library (GNU MPFR); C (programming language); C language program; operating system; Linux; GNU Compiler Collection; gcc compiler; command-line interface; command; source code; zip file; pi-26.zip; computer memory; spigot algorithm; tap (valve); spigot; kitchen; sink; academic publishing; paper; word; PHP; The Upstart Crow (2016, Matt Lipsey and Richard Boden, Directors).