Ras-Stack

Dashboard

77

Share this post

Equations, Code, and Salvador Dali for Pi Day

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

Equations, Code, and Salvador Dali for Pi Day

Pi, Part II

Mar 14, 2024

Share this post

Equations, Code, and Salvador Dali for Pi Day

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

3

1

Share

A Jaunty Pi (from Wikipedia)

In Part I of this essay, I talked about Pi’s value and its irrationality. Does that also make Pi Day valuable and irrational?1 How about learning more than the 15 digits needed by NASA? Or worthless but rational? Whichever, highly intelligent people are drawn to memorizing digits, just as they are drawn to chess. Think of the celebrated 55-Digit Pi March, by Coach Tom and his teenage computers, or how Bruce Dan (see Wikipedia) recited 144 digits of Pi at a frat party.2 Or think of the many mathematicians over the ages who have devoted time to computing Pi to more and more digits. Even before calculus was invented, Van Ceulen got up to 35 digits in 1610 (see Peter Borwein, “The Amazing Number Pi” (2000)).

As we talked about last week, Pi is irrational, so there is no end to computations. Unless, that is, you expand your horizons. There are circumstances in which Pi is indeed a rational number, with a finite number of decimal places. In fact, sometimes Pi equals exactly 3.

When I had my students go home and try to measure Pi using a string and a ruler as I described last week, they naturally assumed I meant for them to draw their circles on a flat surface. But suppose they didn’t. Suppose they drew their circles on the coach, or on a garbage can. In class, I had Jonathan go find a ball from the Resource Room. Then I drew a circle on it. The definition of a circle drawn on a ball is the same as always: pick a center (the North Pole will do) and go equal distances—on the ball’s surface, no cheating by cutting corners and digging tunnels. There are lots of diameter circles you could draw, but go all the way to the equator, which is a circle.

A Sphere (from Wikipedia)

When I did this in class, I asked if Pi would be bigger or smaller than 3.14 if the circle was drawn on a sphere. Smaller, Lyndon said, because the diameter in Pi = C/d is bigger if you have to go all the way around the curve of the sphere. Then I asked if Pi would be bigger than 2, or less.

I drew a picture, as the first step in solving any problem. I can’t draw a good sphere, so I drew a line with a semicircle above it. The line is the flat-circle diameter. The semicircle is the ball-circle diameter, the unknown we're trying to find.

I had them eyeball it and write their estimates on lapboards. 1.1, 2.0, 2.5, 3.0, 2.5. Reasonable guesses, but mostly too big. I asked how to find it more accurately. "Use string" was the good scientific answer, from Emma, I think. I said they could do much better mathematically, with no more information than they had already.

They were stumped. I said I'd give them a couple of minutes. I should have had them discuss it together too. Then Zoe suggested 3.14. "The right idea," I said, "but wrong." even just eyeballing the diagram, 3 is too big.

For the two dimensional circle, Pi = C/d0. For our equatorial circle, the circumference is the same, C. The diameter, though, is the half-circle going through the north pole. Thus, Pi = C/ (.5C) = 2.

Pi = 2 is the smallest value of Pi we get on the sphere, and we got it by using the biggest circle that you can draw on a sphere. Consider the Polar Circle, which would have diameter d2 if you could cut through the globe. I’ve magnified it in the little picture on the right. The spherical diameter from a2 to b2 is still bigger than 2, but not by much. Thus, the Pi we’d calculate for circle 2 would be close to 3.14. In fact, the closer we got to the North Pole, the closer spherical Pi would get to 3.14159. . . If we had an infinitesimally small circle at the North Pole, Pi would take the same value as a flat circle.

How do we get Pi = 3? Since we have Pi = 2 for the equatorial circle, and Pi = 3.14 near the North Pole, we’d have Pi = 3 somewhere in between. So sometimes Pi = 3. Or, another way to get it would be by keeping the circle the same size as on the equator of this circle, but blowing up the sphere so it has less curvature for a circle of that size— sort of sliding the circle north.

You can think about other drawing shapes on other objects besides flat paper and spheres. Salvador Dali famously drew them on a box, draped from a tree, and on a piece of cloth.

“The Persistence of Memory,” Dali (Wikimedia Commons)

Consider the clock on the box. Suppose we smooth it out so it’s a neat circle instead of being wrinkled. What is the value of Pi?

Well, the circumference is no different than if the watch was flat on the top of the box. Bending the circle over the edge doesn’t change the shape. How about the diameter? Oddly enough, that doesn’t change either. Where the hands meet is the center, and the distance to any edge point is the same as if the watch were flat. So the Dali-Pi is our old friend 3.14.159. . .

Notice that we can lay the watch flat on Dali’s box, with a bend. That’s crucial. You couldn’t do that on a sphere. In fact, you can’t do that just anywhere on a box. You can go over long edges like Dali did, but you can’t paste a circle onto a corner of the box. There, we could draw a circle, as we did on the sphere, by picking a center— the corner itself, for example— and then finding the points equally distant from it. But the value of Pi would depend on the exact point. If I want to finish this while it’s still Pi Day, though, I’d better not go down that rabbit hole. I will note, however, that on the sphere it doesn’t matter where your center is, even though it does depend on the size of your circle. That’s because a sphere has constant curvature. On an ellipsoid or a box it does matter.

Subscribed

Let’s return to flat space, also called Euclidean space. (Did you know you were just doing Non-Euclidean geometry?) But let’s use equations, now. Here’s one by Leibniz, who got it with the help of calculus, which he invented simultaneously with Newton.

π=4(1−13+15−17+19−⋯)(Leibniz′s formula for π)

I won’t try to explain why Leibniz’s formula is true, since that requires calculus, I think (is there any other way, readers?). It also requires trigonometry, which my 7th graders haven’t had yet. But you should be able to see the pattern. I’ll use it later in a computer program that demonstrates it gets close to Pi, though that’s not a proof it gets all the way.

In class, I gave my students a three-page handout with lots of Pi formulas, most of them too advanced for 7th graders to understand because of the notation. I asked them to pick one each for me to try to explain. Three students picked Euler’s formula and two picked the Normal density formula. Here is Euler’s formula:

π=∑k=1∞k2kk!2(2k)!−3(Euler)

Euler’s formula is actually written in symbols my 7th graders do learn. It is not that hard to understand, it just needs slow thinking. Suppose k = 4. Then k! means 4x3x2x1, which equals 24. The big Sigma means sum, and it means we add the formula that comes right after it for every k from 1 to infinity. So this formula isn’t as bad as it looks.

My students also picked the formula derived from the Normal probability density, the bell-shaped curve. The formula is:

π=12(∫−∞∞e−x2/2dx)2 (from the Normal density)

This formula is harder to explain, because it is a calculus formula and the special number e (from Euler) an irrational number that equals about 2.7. The fancy symbols is an integral sign, which is a continuous version of the Sigma summation sign in Euler’s formula. Euler summed for k = 1, 2, 3, . . . The integral sums up for all values of x start from -infinity up to +infinity. It doesn’s sum to infinity, because, like the 1/k fractions in Euler’s formula, the exponent here gets smaller and smaller.

Rearranged so the integral (the fancy sign) equals 1, that gives the normal density, which can be graphed as in the German diagram below if we also put in a parameter to make the midde number 100 instead of 0. Maybe I’ll revise this essay to do that some time. I use this example because it’s one I’m often having to recalculate to figure out which IQ’s are which percentiles of the population— for example, 2.2% of people have IQ greater than 130.

The Bell Curve, Centered at 100 (IHVO Handbook)

Why should the formula for the Bell Curve also be a formula for Pi? It’s a testament to God’s glory. The reason involves trigonometry, wave formulas, and something called the Fourier transform and spectral analysis, which I have never got round to learning.

So let’s leave formulas now and go to something much less intellectually taxing: computer coding. Below is a Python program that calculates Pi. The program asks the user to tell it how many microseconds of computer time to use (the more you use, the better the estimate of Pi, roughly speaking, or maybe even exactly. Then it prints out two estimates of Pi for you, one using Leibniz’s formula and one using Euler’s. If you delete some of the pound signs (#), which “comment out” some of the lines, the program will also show its work along the way—its estimates or how much computer time it’s used so far.

#March 14, 2024. A pi estimator
# Eric Rasmusen, [email-masked], Python 3

import time
import math

print(f"How many microseconds do you want the computer to use for each estimate? (e.g. 10, 20000)?")
microseconds = input()
microseconds = int(microseconds)
print("###################################### ")
print(f"The first method uses Leibniz's formula. ")
start = time.time()

pi = 4
for item in range(1,10000000000):
if item % 2 == 1: #This means if the remainder from item/2 is 1.
pi = pi - 4/(2*item+1)
else: #If the remainder is NOT 1, then item is even.
pi = pi + 4/(2*item+1)
end = time.time()
elapsed = 100000*(end-start)#To measure in microseconds
# print(f"Computer time used was {elapsed:0.2f} microseconds.")
if elapsed >microseconds:
break

# print(f"Item is {item} and pi is {pi:0.2f}")

print(f"Pi = {pi:0.15f} using Leibniz.")
print(f"CPU time: { elapsed:0.2f} microseconds.")
print("###################################### ")

print(f"The second method is Pfouffe's series. ")
start = time.time()

pi = -3
for item in range(1,100000000000):
pi = pi + item*2**item*(math.factorial(item))**2/math.factorial(2*item)
# print(f"Iteration {item}: pi is {pi:0.2f}.")

end = time.time()
elapsed = 100000*(end-start)#To measure in microseconds
# print(f"Computer time used was {elapsed:0.2f} microseconds.")
if elapsed > microseconds:
break

print(f"Pi = {pi:0.15f} using Euler.")
print(f"CPU time: {elapsed:0.2f} microseconds.")
print("###################################### ")
print(f"That is all.")
print("###################################### ")
#I erased the normal distirbution method by accident.
#It was fun, but I did need to do an approx of an integral
#Maybe for fun I will try it later.

The output looks like this:

How many microseconds do you want the computer to use for each estimate? (e.g. 10, 20000)?
16
######################################
The first method uses Leibniz's formula.
Pi = 3.146243791226152 using Leibniz.
CPU time: 16.09 microseconds.
######################################
The second method is Euler's series.
Pi = 3.141592653471791 using Euler.
CPU time: 16.12 microseconds.
######################################
That is all.
######################################

As you see, Euler’s formula works more quickly (“converges faster”).

If you’d like to try the program out, go to Codabrainy.com’s free Python page. Find the box for writing your code in, and clear it out by deleting everything there. Then paste in the program in the first grey box above. Click the sideways triangle at the top to run the program, and you will see the output in the window to the right of the code input window. The program does have a problem, though. It isn’t set to print more than about 16 digits of Pi. Later maybe I’ll find how Python can be made to calculate and print with more digits.

That is all.

1

How interesting that “value'“ and ‘irrational” have so many different meaning! (so many values?) Even “irrational values” has a couple.

2

In my fraternity back in the 1960s we probably had the world champion memorizer of Pi digits, Bruce Dan. He had memorized over 500 digits; alas there was no official record back then.

But 30-odd years later we had a reprise at my home where we all pledged X dollars to our pre-DEI Alma Mater for each digit he could still do, which turned out to be about 144. This event was memorialized here, with the actual recitation of digits starting at about 9:45.

[personal communication, 2024]

Share this post

Equations, Code, and Salvador Dali for Pi Day

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

3

1

Share

Previous

3 Comments

Share this discussion

Equations, Code, and Salvador Dali for Pi Day

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

Joe Horton

4 hrs ago

Very cool, Eric. I don't know Python, but since you do, how about throwing in a bit of code that counts cycles? It would be interesting to know how fast the series reach arbitrary degrees of accuracy.

***********

The pi = f(shape of surface) reminds me of my introduction to non-Euclidean geometry. It was a charming little Dover book entitled "Taxicab geometry." Distances were measured n to by taking sqrt[(x2-x1)^2 + (y2-y1)^2] but just by (x2-x1) + (y2-y1)--in other words, the way a cab would drive in a city whose streets are laid out on an infinite square grid. The results are interesting, too. For example, what does a circle look like? An ellipse? A hyperbola? The answers weren't intuitive to me until I started calculating them. Then the patterns became obvious. And fun.

I don't recall whether I mentioned how (or that) pi figures heavily into Sagan's love, Contact. But it does, and it's central to what, to me, was a central message in the book. Cannot recommend it highly enough.

Expand full comment

Like

Reply

Share

2 replies by Eric Rasmusen

2 more comments...

Top

New

Community

(a+b^n)/n = x. Therefore, God Exists.

(Part i) “ (a+bn)/n = x. Therefore, God exists…” is a joke and a joke with multiple layers. From it we can learn about theology, humor, and even…

Mar 29, 2023 •
Eric Rasmusen

2

Share this post

(a+b^n)/n = x. Therefore, God Exists.

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

5

"I Am the Very Model of a Modern Major-General," Part II

A Math Commentary

Apr 11, 2023 •
Eric Rasmusen

1

Share this post

"I Am the Very Model of a Modern Major-General," Part II

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

The Text of the Leaked Alito Abortion Draft Opinion for Dobbs

This document was cleaned up by Professor Eric Rasmusen, [email-masked] from a machine scan of the pdf that was leaked in May 2022. I have tried…

May 10, 2022 •
Eric Rasmusen

Share this post

The Text of the Leaked Alito Abortion Draft Opinion for Dobbs

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

Part I of "Hunter Was Too Clever by Half": The Plea Bargain

(Part I and Part II and Part III) When I say “Hunter”, I mean his lawyers, of course, not Hunter Biden. He may have a Yale law degree, courtesy of his…

Aug 12, 2023 •
Eric Rasmusen

5

Share this post

Part I of "Hunter Was Too Clever by Half": The Plea Bargain

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

My Testimony to the Indiana House of Representatives

S.B. 202, Part II

Feb 19 •
Eric Rasmusen

4

Share this post

My Testimony to the Indiana House of Representatives

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

1

Harvard's Claudine Gay Pledges To Die In Her Boots

It's Gotterdammerung Time!

Dec 18, 2023 •
Eric Rasmusen

4

Share this post

Harvard's Claudine Gay Pledges To Die In Her Boots

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

The Reichstag Fire and January 6: Part I

Back in January 2021 I wrote an article titled “Remembering the Reichstag Fire,” (The Unz Review (January 17, 2021)). I thought I’d dust it off and…

Aug 4, 2023 •
Eric Rasmusen

4

Share this post

The Reichstag Fire and January 6: Part I

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

Sam, Sin, Salvation

The Securities and Exchange Commission just issued a criminal complaint against Caroline Ellison and Gary Wang, but the complaint’s main character is…

Dec 24, 2022 •
Eric Rasmusen

2

Share this post

Sam, Sin, Salvation

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

1

Students for Fair Admissions v. Harvard: The "Asians Have Bad Personalities" Case

The issue in Students for Fair Admissions v. Harvard is whether Harvard could discriminate against Asian Americans and put a quota on how many were…

Jul 1, 2023 •
Eric Rasmusen

3

Share this post

Students for Fair Admissions v. Harvard: The "Asians Have Bad Personalities" Case

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

2

The Bloomington Fourth of July Parade, with Particular Attention to Candy-Throwing Technique and the Toleration of Opposing Views

I had an exhausting but satisfying Fourth of July. From 9:30 to 11:30, I was walking downtown, as part of the Monroe Republican Party group in the…

Jul 5, 2023 •
Eric Rasmusen

2

Share this post

The Bloomington Fourth of July Parade, with Particular Attention to Candy-Throwing Technique and the Toleration of Opposing Views

ericrasmusen.substack.com

Copy link

Facebook

Email

Note

Other

See all

© 2024 Eric Rasmusen

Privacy ∙ Terms ∙ Collection notice

Start WritingGet the app

Substack is the home for great writing

Update your profile

Name (Required)HandleBio

undefined subscriptions will be displayed on your profile (edit)

Skip for now
Save & Post Comment

Hi [email-masked]

Only paid subscribers can comment on this post

Already a paid subscriber? Switch accounts

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to [email-masked], or click here to sign in.

Eric Rasmusen

[email-masked]

Home

Inbox

Chat

Activity

77

Explore

Writer dashboard

Manage subscription

Settings

Support

Sign out

Get the app

About

Privacy

Terms

Collection notice

Create Post

Save For Later

Open With Pablo