It's Pi Day And Google Gets In On It With A Doodle
Written by Mike James   
Wednesday, 14 March 2018

Pi Day - that's 3/14/18 to you - has been slowly growing in its impact and now Google has validated it, for the second time, with a doodle. What's it all about and is there a uniquely programmer angle on the whole Pi thing?

 

googlePiday2018

Coded into the doodle is the basic formula:

Cirumference/Diameter = Pi

The key is that the edge of the pie is made of one pastry and the bar across the diameter is made of another and pieces of each are to the left forming the equation. This leaves the apple unexplained.

If you want the recipe for the pie then Google has provided a video and a detailed description of how to make it:

 

Pi Day started small and has now grown to the point where it is blessed by Google:

"Celebrated each year on March 14th (3.14), Pi Day is dedicated to the mathematical constant, Pi. First recognized 30 years ago in 1988 by physicist Larry Shaw, Pi Day observers often celebrate with a slice of their favorite pie in honor of the number’s delicious sounding name."

The first Pi Day, 30 years ago was basically just the staff and public and the San Francisco Exploratorium walking round its circular gallery and eating fruit pies. In 2009 the US House of Representatives passed a non-binding resolution that recognized the celebration. In 2010 Google added to the publicity with a doodle.

googledoodle2010

At this point I could start on about why Pi is such a special quantity, but I have gone over these ideas on previous Pi Days. Today what I'd like to emphasise the the strange position Pi has in the programming world. So first some facts:

Pi is irrational - that is, there is no fraction n/m that represents Pi exactly. If there were it would be a ratio - nal number and this is what the irrational means. It doesn't mean that Pi is some how illogical.

Pi is transcendental - that is, there is no finite polynomial with rational coefficients that it is a root of. This means that Pi isn't a "simple" number like the square root of two  which is also irrational but is the solution of x^2=2.

Of the two properties it is the "transcendental" one that tends make Pi of interest to people who have no idea what math or science is about. However, it is also the property that is of interest to us because it indicates that Pi is a more complex sort of irrational number than roots of a polynomial.

Without being technical, the interesting thing about Pi is that it seems to be one of the few transcendental numbers that has nice algorithms for working it out. We might not be able to write down a finite polynomial for it but we can write down a lot of infinite series that converge reasonably quickly to the value we are looking for. This is one of the reasons why computing Pi to billions of digits a a pastime that many programmers know. You probably should write a Pi program once in your programming lifetime and what could be better than on Pi Day.

We can compute pi to a few digits using the series:

pi=4*(1-1/3+1/5-1/7 ... )

This is very easy to implement, we just need to generate the odd integers but to get pi to a reasonable number of digits you have to compute a lot of terms, so this series is slow to converge.

Here is a simple minded function to implement the sum:

function computePi() {
 var pi = 0;
 var k; 
 for (k = 1; k <= 100000; k++) { 
  pi += 4 * Math.pow(-1, k + 1) / (2 * k – 1); 
  result.innerHTML=pi;
  count.innerHTML=k;
 } }

If you try this out you will find the web page freezes until the computation is complete. A better implementation is to use a timer to interrupt the calculation every so often - if you want to know how to do this then see JavaScript Async: Events, Callbacks, Promises and Async Await by Ian Elliot.

A more interesting question is why the series given above converges to Pi - what is it about 1 divided by odd numbers that relates to Pi?

This is the sort of question that keeps people fascinated by the number.

There is also a general feeling that Pi turns up unreasonably often in important physics formulas. This is often for a very different reason. It is because we also use Pi as a "natural" measure of angle. You can divide up a complete rotation into as many parts as you like - 360 degrees is the usual way to do it. However, if you take the length of the arc that you turn through as a measure, you naturally end up with Pi in the system.

For example, if you turn through half a rotation you have half a circumference and normalizing this by the radius, i.e. 1/2C/r= C/D= Pi, means that half a turn is an angle of Pi radians.

In a complete rotation you trace out the full circumference and the angle is C/r=C/2D=2Pi. Hence there are 2Pi radians in a complete rotation.

For a quater of a turn i.e. 90 degrees we have 1/4C/r=C/2D=Pi/2 radians. Thus there are 1/2Pi radians in 90 degrees, something that seems mysterious until you realize that it's all about the fraction of the circumference you have travelled in rotating.

Have another look at the original Google Pi Day doodle:.

googledoodle2010

As we use Pi to measure angles it isn't suprising that it turns up in a lot of formulae.

Add to this the fact that Pi occurs in the calculation of many areas and volumes of shapes that "contain" circles. For example, a circle has area Pi r^2, a cylinder has volume Pi r^2 h, and a sphere has a volume 4/3 Pi r^3 and so on. You can see that any physical problem involving these shapes is going to have a Pi in it somewhere, if only to fix the volume that we are working with 

This makes Pi no less interesting and, even when you know why, it's still always surprising when a Pi pops up in an equation.googlePiday2018icon

  • Dr Mike James, founder and chief editor of the I Programmer website, is also the author of The Programmer’s Guide To Theory which, as its subtitle "Great ideas explained" suggests, sets out to present the fundamental ideas of computer science in an informal and yet informative way.

More Information

http://www.piday.org/

http://en.wikipedia.org/wiki/Pi_day

Related Articles

Pi Day 2017 - Why Pi?

Pi Day Of The Century 

Happy Pi Day!      

The Life Of Pi - Yes It's Pi Day       

Celebrate Pi Day It Contains All Human Knowledge       

The Irrationals: A Story of the Numbers You Can't Count On 

Normal Numbers - A Video In Rhyme 

Non-computable numbers

Confronting the unprovable

Computability

60 trillionth binary digit of pi-squared calculated

Yahoo! Gets to the 2 Quadrillionth bit of Pi - it's zero

Finding Pi

The Programmer's Guide To The Transfinite 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


Personal Picks For Holiday Gifts
29/11/2024

It's Black Friday, the traditional day to indulge in online shopping. Not every item that is included in my selection of gifts is subject to a promotional offer, but where they aren't you might be poi [ ... ]



Discover PostgreSQL How-Tos
16/12/2024

A veritable treasure trove of assorted how-to recipes for PostgreSQL, stored as a Github repository, has been started by Nikolay Samokhvalov, well known in the PostgreSQL world.


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

 <ASIN:1871962560>


<ASIN:1871962439>

Last Updated ( Sunday, 14 March 2021 )