Pi calculation by hand #
1. Introduction #
Consider a situation where you are reincarnated in a medieval-like alternate world, armed only with your knowledge1.
In this article, we will think about how to actually calculate pi, and how to derive or prove it as one example. Of course, since numbers and characters are likely to be different in the reincarnation destination, do not forget to convert them into the corresponding numerals and symbols there.
The world records for the number of digits of pi throughout human history are as follows2:
- Before 1500 CE: 3-5 digits (using polygons)
- Around 1500 CE: 9 digits (using polygons)
- Around 1600 CE: 20-35 digits (using polygons)
- Around 1700 CE: 100 digits (using the atan formula)
We are targeting a reincarnation destination with a civilization level around 1700 CE. The calculation of pi aims for a method where 20-30 digits can be obtained by spending several days.
The reason for aiming for this is that before the discovery of the method using atan, the main calculation was done using polygons, and it was common to spend a year to achieve only 20 digits3. Therefore, 20-30 digits in a few days will certainly impress.
Even if you were reincarnated after 1700 CE, the possibility is still very real. This is because the digits mentioned above were determined later or could have been kept secret, among other reasons. Also, information would not have spread so quickly, so just because it was discovered in one country doesn’t mean it would spread worldwide.
For those who want to know more about the historical background of pi, please refer to the book “The Hand Calculation History of Pi” 4 (in Japanese).
2. Settings for the Reincarnation Destination #
- Computers do not exist
- Even if they existed in the world line, you might be recognized as an excellent talent if you can demonstrate calculation methods.
- A world with some understanding of academics
- Going back too far in time won’t work. However, there might still be a possibility if you were to pinpoint reincarnate in places like ancient Greece, even in BCE. However, since pi is irrational number, insisting on this might lead to being persecuted or even executed5.
- If your reincarnation destination is Sparta, there’s not much you can do. You should either flee, give up, or “When in Rome, do as the Romans do”.
2.1. Preparations #
- Procure something to write with and something to write on
- This might be extremely challenging.
- Anything will do, such as chalk and slate, brush and Japanese paper, quill and parchment.
- Find a mentor or a place to present your work
- Even if you manage to derive the calculation, it will be a wasted effort if there’s no environment to understand it.
If there’s nothing to write with or on, or if it’s very expensive, making it yourself is also an option6.
3. About Pi #
- Pi is irrational
- Pi is transcendental
3.1. Ingenuity of Hand Calculation #
- Choose a method with less computation
- Since there are no computers, the computation cost of multiplying and dividing large numbers is high. If you need to perform these operations, keep them to a multiplication or division with large numbers and 1-2 digit numbers.
- Avoid division as much as possible
- Division has a very high computation cost. Dividing by a small number isn’t too difficult, but dividing by a large number is challenging.
4. Calculation Method #
We roughly calculate in this way.
4.1. Trigonometric Functions / Inverse Trigonometric Functions #
Presumably, trigonometric functions are known. In human history, they seem to have been somewhat known around the 1st century BCE7. However, there were no concepts of angles in the Edo period (around 1700 CE), so it might be difficult to explain by translating into local language8.
4.1.1. Trigonometric Functions #
Explain by drawing a unit circle, and at the same time touch on Pythagoras’ theorem. Even if the explanation is somewhat insufficient, you will be pursued for the derivation procedure after
“This guy calculated pi up to 20 digits! That’s awesome!!!”
So even if the explanation is a bit nonsensical, it’s okay. Let’s push through with the fact that it is so because the result is so!
…I hope it doesn’t cause too much trouble.
4.1.2. Concept of Radian #
The radian is a quantity that connects the length of a circumference with an angle, and it is convenient to introduce it. To explain it roughly,
- Consider a unit circle
- At this time, the circumference is $2\pi$
- Adopt this circumference as the radian angle.
If you define radian in a more formal way9,
The radian is a unit of angular measure defined such that an angle of one radian subtended from the center of a unit circle produces an arc with arc length 1.
By defining radian, you can intuitively link the angle with pi. Assuming that the introduction of trigonometric functions is finished, if you adopt measuring angles in radians, you get
\begin{align}\label{tanpi4} \tan\left(\frac{\pi}{4}\right)=\frac{\sin\left(\pi/4\right)}{\cos\left(\pi/4\right)}=1 \end{align}
4.1.3. Inverse Trigonometric Functions #
The concept of inverse trigonometric functions should be easy if you are on a worldline where trigonometric functions are known.
“You define an inverse function that finds the angle when you know the value of a trigonometric function.”
I think this will suffice. Using inverse trigonometric functions, from equation \eqref{tanpi4} you get
\begin{align} \label{atanpi4} \frac{\pi}{4}=\text{atan}\left(1\right) \end{align}
In other words, if you somehow manage to convert the right-hand side’s $\text{atan}$ into a form that is easy to calculate, you only have to multiply it by 4. That’s where the power series expansion comes in.
4.2. Power Series Expansion of $\text{atan}(x)$ #
The history of power series expansion is ancient, explicitly appearing around 500 CE in India in the works of Aryabhata10, developed in the book “Aryabhatiya”11. However, concepts and fundamentals of series were also used around 200 BCE by Archimedes and Apollonius, so it may be slightly more acceptable.
The relationship we want to derive in this section is a power series expansion for $\text{atan}(x)$, and the goal is to derive the following equation12,
\begin{align}\label{atan1} \text{atan}(x) = \sum_{n=0}^{\infty} \frac{(-1)^{n}}{2n+1}x^{2n+1},~~|x|< 1 \end{align}
Now let’s derive equation \eqref{atan1}.
To most easily obtain the power series expansion of $\text{atan}(x)$, we will use geometric series and differentiation and integration. The derivation will be done in the following order:
- Differentiate $\text{atan}(x)$ to obtain the form of a geometric series
- Integrate the expression for the derivative of $\text{atan}(x)$ that has become a geometric series
- Obtain $\text{atan}(x)$ in the form of a series
4.2.1. Derivation #
In human history, differentiation and integration have developed in the 17th century by Isaac Newton and Gottfried Leibniz13. I will omit the detailed explanation of differentiation and integration, but for now, it will suffice to understand that they represent the slope of a function and area, respectively.
First, let’s consider the differentiation of $\text{atan}(x)$. We can show that \begin{align} \label{dinvatan} \frac{d}{dx}\text{atan}(x)=\frac{1}{1+x^2} \end{align} This is demonstrated using the derivative of the inverse function.
To briefly explain the derivative of an inverse function, if the inverse function of $y=f(x)$ exists, then \begin{align}\label{finv} \frac{dy}{dx}=\frac{1}{\hspace{0.5em}\frac{dx}{dy}\hspace{0.5em}} \end{align} holds true.
First, we define the function $y$ as follows: \begin{align} y\equiv\text{atan}(x) \to x=\tan(y) \end{align}
Differentiating both sides with respect to $y$, we get \begin{align} \frac{dx}{dy} &=\frac{d}{dy} \tan(y) =\frac{\cos^2{y}+\sin^2{y}}{\cos^2{y}} \nonumber \\ &=\frac{1}{\cos^2{y}} \nonumber \\ &=1+\tan^2(y) \nonumber \\ &=1+x^2 \end{align} Here, we used \begin{align} 1+\tan^2{y}=\frac{1}{\cos^{2}(y)} \end{align} This equation is obtained by dividing both sides of $\sin^2(x)+\cos^2(x)=1$ by $\cos^2(x)$.
Using the derivative of the inverse function \eqref{finv}, we have \begin{align} \frac{d}{dx}\text{atan}(x)=\frac{1}{1+x^2} \end{align} and we obtain equation \eqref{dinvatan}.
4.2.2. Geometric Series and Integration #
The right side of equation \eqref{dinvatan}, $\frac{1}{1+x^2}$, closely resembles the form of a geometric series.
The sum of a geometric sequence, which is a geometric series, is given as \begin{align}\label{geometric} \frac{1}{1-r}=1+r+r^2+r^3+\cdots \end{align} when the first term is $1$ and the common ratio $|r|<1$. To derive this, we can find the difference between a geometric sequence and the same sequence multiplied by $r$.
For the geometric series \eqref{geometric}, let’s adopt $r=-x^2,|x|<1$. \begin{align} \frac{1}{1+x^2}=1-x^2+x^4-x^6+\cdots \end{align} Since the left side is equal to the differentiation of $\text{atan}(x)$ that we derived in equation \eqref{dinvatan}, we have \begin{align} \frac{d}{dx}\text{atan}(x)=1-x^2+x^4-x^6+\cdots \end{align} If we integrate both sides over the interval $[0,s]$ with respect to $x$, we get \begin{gather} \int_{0}^s dx \left[\frac{d}{dx}\text{atan}(x)\right] = \int_{0}^s dx \left(1-x^2+x^4-x^6+\cdots\right) \nonumber \\ \text{atan}(s)-\text{atan}(0) = \left[x-\frac{1}{3}x^3+\frac{1}{5}x^5-\frac{1}{7}x^7+\cdots\right]_{0}^{s} \nonumber \\ \text{atan}(s)=s-\frac{1}{3}s^3+\frac{1}{5}s^5-\frac{1}{7}s^7+\cdots,~ |s|<1 \end{gather}
Thus, we get the series expansion for $\text{atan}(x)$. \begin{align} \text{atan}(x)&=x-\frac{1}{3}x^3+\frac{1}{5}x^5-\frac{1}{7}x^7+\cdots \nonumber \\ &=\sum_{n=0}^{\infty}\frac{(-1)^{n}}{2n+1}x^{2n+1},~ |x|<1 \label{atantaylor} \end{align}
As you can see from the right side of equation \eqref{atantaylor}, the numbers being added become rapidly smaller as the number of terms increases, especially when $x$ is small.
Also, the series expansion \eqref{atantaylor} represents the Taylor expansion of $\text{atan}(x)$ around the point $x=0$. If the concept of Taylor expansion is more familiar to the reincarnated world, you might choose to explain this series expansion in that context.
4.2.3. Madhava-Leibniz Series #
Now, in the case of $x=1$, we conclude that the series expansion \eqref{atantaylor} cannot be used. However, it is known that it can still be used at $x=1$ thanks to Abel’s continuity theorem14.
In actual computation, we avoid the problem at $x=1$ by employing an extra step, so there’s no need to discuss this matter.
However, for $x=1$, it is known as the Madhava-Leibniz series, and it results in the following beautiful formula that ties a simple series to $\pi$:
\begin{align}\label{ML} \frac{\pi}{4}=\text{atan}(1)&=1-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\cdots \\ \end{align}
4.3. Creation of $\text{atan}$-related Formulas #
Now, if the series expansion can be used at $x=1$,
\begin{align} \frac{\pi}{4}&=\text{atan}\left(1\right)\nonumber \\ &=1-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\cdots \label{pi_ML} \end{align}
we can obtain an approximation of $\pi$ by truncating the right-hand side at an appropriate term. However, even if we compute up to the 500th term of the right-hand side of \eqref{pi_ML}, the 501st term is $\frac{1}{1003}\approx 0.001$, affecting up to the second decimal place. That means that calculating 500 terms only gives $\pi\approx 3.1$, which is of no use.
Therefore, we will somehow write $\text{atan}\left(1\right)$ as a sum of numbers less than 1.
4.3.1. Addition Formula for $\text{atan}$ #
For $\text{atan}$, the following addition formula exists:
\begin{align} \text{atan}(a)+\text{atan}(b)=\text{atan}\left(\frac{a+b}{1-ab}\right) \end{align}
If the argument of the right side is 1, and $a, b < 1$, then the series converges quickly, and the calculation can be significantly reduced.
Let’s first derive this addition formula.
From the addition formulas for trigonometric functions, we have15 \begin{align} \sin(\alpha+\beta)&=\sin\alpha\cos\beta+\cos\alpha\sin\beta \label{sinadd}\\ \cos(\alpha+\beta)&=\cos\alpha\cos\beta-\sin\alpha\sin\beta \label{cosadd}\\ \end{align}
By dividing equation \eqref{sinadd} by \eqref{cosadd}, we get
\begin{align} \tan(\alpha+\beta)&=\frac{\sin(\alpha+\beta)}{\cos(\alpha+\beta)} \nonumber \\ &=\frac{\sin\alpha\cos\beta+\cos\alpha\sin\beta}{\cos\alpha\cos\beta-\sin\alpha\sin\beta} \end{align} If we multiply both the numerator and denominator by $1/(\cos\alpha\cos\beta)$, we obtain the addition formula for $\tan$ \begin{align}\label{tanadd} \tan(\alpha+\beta)&=\frac{\tan\alpha+\tan\beta}{1-\tan\alpha\tan\beta} \end{align}
Considering the inverse function of \eqref{tanadd}, we get \begin{align} \alpha+\beta=\text{atan}\left[\frac{\tan\alpha+\tan\beta}{1-\tan\alpha\tan\beta}\right] \end{align} So, if we introduce $a=\tan\alpha, b=\tan\beta$, we arrive at the addition formula for $\text{atan}$ \begin{align} \text{atan}(a)+\text{atan}(b)=\text{atan}\left(\frac{a+b}{1-ab}\right) \label{atanadd} \end{align}
4.3.2. Division of $\text{atan}(1)$ #
If we momentarily consider the right-hand side of equation \eqref{atanadd} when the argument is $1$, how might it be divided? This problem equates to searching for such $a, b < 1$, with $a, b$ being real numbers, that:
\begin{gather} \frac{a+b}{1-ab}=1 \end{gather}
Even though you may randomly search for the final relational expression, let us devise a little strategy to find an addition theorem with numbers that are efficiently computable.
Let’s seek the addition theorem in the following form:
\begin{gather} \text{atan}\left(\frac{1}{l}\right)=\text{atan}\left(\frac{1}{n}\right)+\text{atan}\left(\frac{1}{m}\right) \end{gather}
Here, $l, m, n$ are integers, and we assume the relation $l < m, n$. In other words, we will transform the problem into searching for integers $l, m, n$ that satisfy: \begin{gather} \frac{a+b}{1-ab}=\frac{1}{l},\hspace{1em}a=\frac{1}{m},\hspace{1em}b=\frac{1}{n} \end{gather} By eliminating $a, b$ and transforming into an equation to solve for $n$, we obtain: \begin{gather} n=\frac{1+ml}{m-l} \end{gather} From the shape of the denominator on the right-hand side, it can be seen that if we choose $m=l+1$, then $n$ is always an integer.
For example, if $l=1$, expressing the solution set as $(l, m, n)$, and solving for $l, m, n (l < m, n)$, we find: \begin{gather} n=\frac{1+m}{m-1} \hspace{1em}\to\hspace{1em} (l, m, n)=(1, 2, 3) \end{gather} This leads to the addition theorem for $\text{atan}$: \begin{gather} \text{atan}\left(1\right)=\text{atan}\left(\frac{1}{2}\right)+\text{atan}\left(\frac{1}{3}\right) \end{gather}
By further applying the addition theorem to the right-hand side for $k=2, k=3$, we can significantly aid the convergence of approximation calculations.
In anticipation of performing manual calculations, and hoping to represent it in decimals with easily divisible $m=2, 5$, we will conduct various examinations. Consequently, we can discover the following addition theorems:
$(l, m, n)$ | Addition theorem for $\text{atan}$ |
---|---|
$(1, 2, 3)$ | $\text{atan}(1)=\text{atan}(1/2)+\text{atan}(1/3)$ |
$(2, 3, 7)$ | $\text{atan}(1/2)=\text{atan}(1/3)+\text{atan}(1/7)$ |
$(3, 5, 8)$ | $\text{atan}(1/3)=\text{atan}(1/5)+\text{atan}(1/8)$ |
$(7, 8, 57)$ | $\text{atan}(1/7)=\text{atan}(1/8)+\text{atan}(1/57)$ |
Thus, we find the following formulas for $\text{atan}(1)$ that seem suitable for manual calculations: \begin{align} \text{atan}(1)&=2~\text{atan}(1/5)+3~\text{atan}(1/8)+\text{atan}(1/57) \label{atanmy}\\ \text{atan}(1)&=2~\text{atan}(1/5)+\text{atan}(1/7)+2~\text{atan}(1/8)\label{atanmysub} \end{align}
4.4. Specific Calculations #
Through the discussions thus far, we have obtained relations \eqref{atanmy} and \eqref{atanmysub}, and we will consider the following based on \eqref{atanmy}: \begin{align} \frac{\pi}{4}=2~\text{atan}(1/5)+3~\text{atan}(1/8)+\text{atan}(1/57) \end{align} Multiplying both sides by 4, we arrive at: \begin{align} \pi=8~\text{atan}(1/5)+12~\text{atan}(1/8)+4~\text{atan}(1/57) \end{align}
The approximation can be obtained by calculating the right-hand side’s $\text{atan}$ series expansion to finite terms: \begin{align}\label{pitaylor} \pi\approx 8\sum_{i=0}^{N_i}\frac{(-1)^i}{2i+1}\frac{1}{5^{2i+1}}+12\sum_{j=0}^{N_j}\frac{(-1)^j}{2j+1}\frac{1}{8^{2j+1}}+4\sum_{k=0}^{N_k}\frac{(-1)^k}{2k+1}\frac{1}{57^{2k+1}} \end{align} By choosing sufficiently large $N$ and $M$, you can approach $\pi$ as closely as desired. Thus, you may compute to your satisfaction.
For actual calculations, it would be wise to first create a numerical table. Then, by multiplying and subtracting coefficients, you can determine the value of $\pi$.
Since we are not actually reincarnating at this moment, let’s aim to find π to 10 decimal places.
What follows is mere tedious calculation, and the sections below are items that can be managed with time and effort, even if they are not known in advance.
4.4.1. Creation of the Numerical Table #
First, perform some simple calculations in advance. This time, we aim to find about 10 digits, so we create and calculate until about 10 zeros line up.
$n$ | $(1/5)^{n}$ | $(1/7)^{n}$ | $(1/8)^{n} = (1/2)^{3n}$ | $(1/57)^{n}$ |
---|---|---|---|---|
0 | 1 | 1 | 1 | 1 |
1 | 0.2 | 0.142 857 142 857 | 0.125 | 0.017 543 859 649 |
2 | 0.04 | 0.020 408 163 265 | 0.015 625 | 0.000 307 787 011 |
3 | 0.008 | 0.002 915 451 895 | 0.001 953 125 | 0.000 005 399 772 |
4 | 0.001 6 | 0.000 416 493 128 | 0.000 244 140 625 | 0.000 000 094 733 |
5 | 0.000 32 | 0.000 059 499 018 | 0.000 030 517 578 | 0.000 000 001 662 |
6 | 0.000 064 | 0.000 008 499 860 | 0.000 003 814 697 | 0.000 000 000 029 |
7 | 0.000 012 8 | 0.000 001 214 266 | 0.000 000 476 837 | 0.000 000 000 001 |
8 | 0.000 002 56 | 0.000 000 173 467 | 0.000 000 059 605 | |
9 | 0.000 000 512 | 0.000 000 024 781 | 0.000 000 007 451 | |
10 | 0.000 000 102 4 | 0.000 000 003 540 | 0.000 000 000 931 | |
11 | 0.000 000 020 48 | 0.000 000 000 506 | 0.000 000 000 116 | |
12 | 0.000 000 004 096 | 0.000 000 000 072 | ||
13 | 0.000 000 000 819 | 0.000 000 000 010 | ||
14 | 0.000 000 000 164 | |||
15 | 0.000 000 000 033 |
When creating a numerical table, division might lead to mistakes. Therefore, if it becomes simpler when multiplying by an appropriate multiple, it might be a good idea to adopt it. In other words, \begin{align} \frac{1}{8} = \frac{125}{1000} \end{align} So dividing by 8 is the same operation as multiplying by 125 and shifting the decimal point by three places. You can think of it this way and proceed with the calculation.
You can also express $1/57=(1/3)\cdot(1/19)$, but I think it’s better to calculate it straightforwardly. Alternatively, you can change the formula you use to Equation \eqref{atanmysub}. This only involves one-digit division.
4.4.2. Approximate Value of $\text{atan}(1/n)$ #
Excluding the sign of each term included in the series expansion and calculating each term, we get the following table.
The table below shows the values of $a_n$ when $a_n$ is defined as \begin{gather} \label{an} \text{atan}(x) = \sum_{n=0}^{\infty} (-1)^{n}a_n,\hspace{2em} a_n = \frac{1}{2n+1}\left(\frac{1}{x}\right)^{2n+1} \end{gather} We calculate $a_n$ based on the numerical table we created earlier.
$n$ | $\frac{1}{2n+1}(\frac{1}{5})^{2n+1}$ | $\frac{1}{2n+1}(\frac{1}{7})^{2n+1}$ | $\frac{1}{2n+1}(\frac{1}{8})^{-(2n+1)}$ | $\frac{1}{2n+1}(\frac{1}{57})^{-(2n+1)}$ |
---|---|---|---|---|
0 | 0.200 000 000 000 | 0.142 857 142 857 | 0.125 000 000 000 | 0.017 543 859 649 |
1 | 0.002 666 666 667 | 0.000 971 817 298 | 0.000 651 041 667 | 0.000 001 799 924 |
2 | 0.000 064 000 000 | 0.000 011 899 804 | 0.000 006 103 516 | 0.000 000 000 332 |
3 | 0.000 001 828 571 | 0.000 000 173 467 | 0.000 000 068 120 | |
4 | 0.000 000 056 889 | 0.000 000 002 753 | 0.000 000 000 828 | |
5 | 0.000 000 001 862 | 0.000 000 000 046 | 0.000 000 000 011 | |
6 | 0.000 000 000 063 | 0.000 000 000 001 | ||
7 | 0.000 000 000 002 |
These results are substituted into Equation \eqref{an} to obtain the following approximate values.
\begin{align} \text{atan}(1/5) &\approx 0.197~395~559~852 \\ \text{atan}(1/7) &\approx 0.141~897~054~604 \\ \text{atan}(1/8) &\approx 0.124~354~994~546 \\ \text{atan}(1/57) &\approx 0.017~542~060~057 \end{align}
4.4.3. Comparison with the Approximate Value of $\pi$ #
Finally, we add each according to Equation \eqref{pitaylor}. Then,
\begin{align} \pi &= 8~\text{atan}(1/5)+12~\text{atan}(1/8)+4~\text{atan}(1/57) &\approx \underline{3.141~592~653~5}80 \end{align}
Or,
\begin{align} \pi &= 8~\text{atan}(1/5)+4~\text{atan}(1/7)+8~\text{atan}(1/8) &\approx \underline{3.141~592~653~5}84 \end{align}
The actual answer is
\begin{align} \pi = \underline{3.141~592~653~5}89 … \end{align}
So, it matches up to the target 10 digits. 8 is also correct, but it is not included because it differs from the true value when rounded off. Just in case, if you want to match up to 10 digits, you calculate up to 11~12 digits and throw away the last digit.
Indeed, I also worked hard on hand calculations from creating a numerical table, but it took me half a day to get 10 digits. Calculation errors are frequent, and stress also builds up. I understand the greatness of calculators.
4.5. Further development #
The series expansion is a Taylor expansion at $x=0$, and due to its properties, it becomes more accurate as the argument value of $\text{atan}$ approaches zero. When considering ease of calculation, the well-known Machin’s formula16 might be a good choice.
Machin’s formula is as follows.
\begin{align} \frac{\pi}{4}=4~\text{atan}(1/5)-\text{atan}(1/239) \end{align}
When you expand the series, division by 5 is very easy. Also, the other terms are quite large, $239$, so the calculation of one term is heavy, but you don’t have to calculate that much.
If you want to know more details, it would be good to refer to the chained exploration method17 or the method using the Taylor expansion of the inverse trigonometric function18.
5. Conclusion #
Ladies and Gentlemen, with this, the course “Introduction to Reincarnation in Another World” comes to an end.
If you are fortunate enough to be reincarnated into a parallel universe that’s knowledgeable about science, be sure to declare the value of pi and say the following line:
Oh, did I just do something?
Enjoy your new life!
6. Revision History #
2023/08/02: Published
7. Appendix #
When choosing an integer $n$ that satisfies $ab=n^2+1$, the addition theorem for atan can be transformed as follows17: \begin{align} \text{atan}\left(\frac{1}{n}\right)=\text{atan}\left(\frac{1}{n+a}\right)+\text{atan}\left(\frac{1}{n+b}\right) \end{align}