Skip to content

Commit 216c115

Browse files
committed
New post
1 parent be9f886 commit 216c115

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: "Deriving a Power Series for π"
3+
description: "One way to derive π (pi) from first principles"
4+
pubDate: "August 6 2025"
5+
tags:
6+
- calculus
7+
- power-series
8+
---
9+
10+
Today, I want to talk about how you can use a power series to define π. No CS today, all math! My impetus for writing this post was reading through the chapter 11.9 exercises of Stewart Calculus, one of which asks you to prove that a specific infinite series equals π, so I wanted to take it a step further and derive that series from the definitions of trigonometric functions. Hope you enjoy!
11+
12+
<br />
13+
14+
Given a right triangle, we define the main trigonometric functions as follows:
15+
16+
$$ sin(\theta) = o/h, \space cos(\theta) = a/h $$
17+
18+
where o and a are the opposite and adjacent sides relative to the angle, and the hypotenuse is the side opposite the 90 degree angle. From the definitions of sine and cosine, we derive the `tan`, `csc`, `sec`, and `cot` functions. Tangent, in particular, is defined as
19+
20+
$$ tan(\theta)=sin(\theta)/cos(\theta)=o/a $$
21+
22+
The trigonometric functions each have inverses, and we can define them. For `arctan`, it is
23+
24+
$$ x=tan(y) \rightarrow y=arctan(x) $$
25+
26+
Using implicit differentiation, we can calculate the derivative of `arctan` easily:
27+
28+
$$ 1 = sec^2(y)\frac{dy}{dx} \rightarrow \frac{dy}{dx}=\frac{1}{sec^2(y)} $$
29+
30+
If we draw a right triangle with the angle `y`, we can see that
31+
32+
$$ sec(x)=\sqrt{1+x^2} \rightarrow sec^2(x)=1+x^2 $$
33+
34+
which implies that
35+
36+
$$
37+
\frac{dy}{dx}=\frac{1}{1+x^2}
38+
$$
39+
40+
From the definition of power series and geometric series, we know that
41+
42+
$$
43+
\frac{1}{1-x}=\sum_{n=0}^{\infty}x^n, \space |x|<1
44+
$$
45+
46+
We can derive a series for
47+
48+
$$ f(x)=\frac{1}{1+x^2} $$
49+
50+
by rewriting it as
51+
52+
$$
53+
\frac{1}{1-(-x^2)}=\sum_{n=0}^{\infty}(-1)^nx^{2n}, \space |x|<1
54+
$$
55+
56+
$$
57+
= 1-x^2+x^4-x^6+\cdots
58+
$$
59+
60+
If we integrate term by term, we can derive the power series for `arctan` by integrating term by term like so:
61+
62+
$$
63+
\int \sum_{n=0}^{\infty}(-1)^nx^{2n} = x-\frac{x^3}{3}+\frac{x^5}{5}-\frac{x^7}{7}+\cdots
64+
$$
65+
66+
$$
67+
= \sum_{n=0}^{\infty}(-1)^n\frac{x^{2n+1}}{2n+1}, \space |x|<1
68+
$$
69+
70+
We can evaluate the endpoints (x=±1), but we don't need to for our purposes. We can just use the fact that
71+
72+
$$ arctan(\frac{\sqrt{3}}{3})=\frac{\pi}{6} \rightarrow \pi = 6 \cdot arctan(\frac{\sqrt{3}}{3})$$
73+
74+
Since π/6 is in the interval of convergence, if we evaluate the series at that value, and multiply the whole thing by 6, we get
75+
76+
$$
77+
78+
\pi = 6 \cdot \sum_{n=0}^{\infty}(-1)^n\frac{(\frac{\sqrt{3}}{3})^{2n+1}}{2n+1}
79+
80+
81+
$$
82+
83+
which simplifies to
84+
85+
$$
86+
87+
\pi = 2\sqrt{3} \cdot \sum_{n=0}^{\infty}(-1)^n\frac{1}{3^n(2n+1)}
88+
89+
90+
$$
91+
92+
This converges pretty slowly, and isn't a great approximation, and you probably shouldn't use it to calculate π. If you're just a _user_ of pi, just hardcode the value or use your programming language's hardcoded value. If you actually care about calculating the digits of π, use the [Ramanujan-Sato series](https://en.wikipedia.org/wiki/Ramanujan%E2%80%93Sato_series) or the [Chudnovsky algorithm](https://en.wikipedia.org/wiki/Chudnovsky_algorithm). I wrote this post because I think it's pretty cool that you can define π as an infinite series.
93+
94+
<br />
95+
Anyway, till next time, thanks for reading (:

0 commit comments

Comments
 (0)