Plain English first
Take any circle — a coin, a wheel, the sun. Measure around the outside edge (the circumference). Measure straight across through the middle (the diameter).
Divide: circumference ÷ diameter.
You always get the same number: about 3.14159…
That number is pi. It never changes, for any circle, any size. Pi is a fact about circles, not a choice anyone made.
Standard math notation
π = C / d
Where:
C = circumference (distance around the circle)
d = diameter (distance across through the center)
Rearranged:
C = πd
C = 2πr (since d = 2r)
Verbose Python with descriptive names
PI = 3.141592653589793 # the ratio of circumference to diameter, always
def compute_circumference_from_diameter(diameter_of_circle):
"""
Given how wide a circle is, find how long its outer edge is.
The outer edge is always π times the width.
"""
circumference = PI * diameter_of_circle
return circumference
def compute_circumference_from_radius(radius_of_circle):
"""
Given the distance from center to edge, find the outer edge length.
The diameter is twice the radius, so circumference is 2π times radius.
"""
circumference = 2 * PI * radius_of_circle
return circumference
def compute_area_of_circle(radius_of_circle):
"""
The area enclosed by a circle grows with the square of the radius.
This formula comes from integrating 2πr from 0 to r.
"""
area = PI * radius_of_circle * radius_of_circle
return area
# Pi can also be computed from a series (no library needed, just slow)
def estimate_pi_using_leibniz_series(number_of_terms):
"""
The Leibniz formula: π/4 = 1 - 1/3 + 1/5 - 1/7 + ...
More terms = more accurate, but this series converges slowly.
"""
running_total = 0
for term_index in range(number_of_terms):
numerator = 1
denominator = 2 * term_index + 1
sign = (-1) ** term_index # alternates +1, -1, +1, -1...
running_total += sign * numerator / denominator
return 4 * running_total
print(estimate_pi_using_leibniz_series(1_000_000)) # ≈ 3.14159...
Where pi shows up
Pi appears wherever a calculation involves circles, rotation, or waves:
circle shape → C = 2πr, A = πr²
rotation angle → full turn = 2π radians
sine/cosine → repeat every 2π
Fourier series → signal analysis
normal curve → statistics (e^(-x²) involves √π)
Common mistakes
- Confusing diameter and radius.
C = πduses diameter.C = 2πruses radius. Both are correct — just use the right one. - Using
π ≈ 3in real code. Just use the constant; precision is free. - Thinking pi is approximate. Pi is exact — it's our decimal representation that goes on forever.
See also
- Visual Radians Without Math Libraries — pi connects directly to radians
- Visual Degrees vs Radians
- Visual Geometry and Trigonometry — Table of Contents
Opmerkingen
Nog geen opmerkingen. Wees de eerste!