Golden Ratio & Fibonacci: Phyllotaxis, Continued Fractions & Optimal Spirals
The golden ratio φ ≈ 1.618 appears throughout mathematics, nature, and visual art — not because of mystical properties, but because it is the most irrational number, and irrationality turns out to be exactly what plants need to maximise seed packing. This article explains the deep connections between Fibonacci numbers, continued fractions, phyllotaxis, and logarithmic spirals — and builds an interactive sunflower seed generator.
1. The Fibonacci Sequence
The Fibonacci sequence is defined by the linear recurrence:
Leonardo of Pisa ("Fibonacci") introduced the sequence in 1202 through a rabbit-breeding problem, but the sequence appears in Sanskrit prosody (Virahanka, c. 700 AD) and Pingala's combinatorial analysis (c. 200 BC) more than a millennium earlier. The West rediscovered a pattern that nature had been exploiting for hundreds of millions of years.
Growth Rate
The ratio of consecutive terms converges to φ:
The convergents are alternately above and below φ, oscillating closer with each step. The error is bounded by:
This exponential convergence — and the specific error formula — follows directly from the theory of continued fractions developed in the next section.
Identities
- Cassini's identity: F(n−1)·F(n+1) − F(n)² = (−1)ⁿ
- Addition rule: F(m+n) = F(m)·F(n+1) + F(m−1)·F(n)
- Doubling rule: F(2n) = F(n)·(2F(n+1) − F(n))
- GCD property: gcd(F(m), F(n)) = F(gcd(m, n))
- Sum of squares: F(1)² + F(2)² + ... + F(n)² = F(n)·F(n+1)
Cassini's identity has a beautiful geometric proof via the Fibonacci rectangle dissection: cut a square off a (n+1)×n rectangle, leaving an n×(n−1) rectangle. The identity measures the area mismatch in a 2×2 determinant, and the (−1)ⁿ alternating sign corresponds to the alternating-chirality spiral constructed this way.
2. The Golden Ratio: Algebraic Definition
The golden ratio φ is defined as the positive root of the equation:
This equation says that a rectangle with sides φ and 1 remains "golden" (same aspect ratio) after removing a unit square — the defining property of self-similarity. The conjugate root is ψ = (1 − √5)/2 ≈ −0.618, which satisfies ψ² = ψ + 1 as well.
Useful algebraic identities following from φ² = φ + 1:
Geometric Mean / Ratio Partition
Dividing a line segment of length 1 + φ into segments of length φ and 1 gives:
This is the "extreme and mean ratio" known to Euclid: the whole is to the larger part as the larger part is to the smaller. This self-referential definition is the key to φ's appearance wherever self-similar growth occurs.
3. Continued Fractions & the Most Irrational Number
Every real number can be represented as a continued fraction:
Rational numbers have finite continued fractions. Irrational numbers have infinite ones. The convergents (truncated approximations) are the best rational approximations to x with denominator ≤ qₙ.
The golden ratio has the simplest possible continued fraction:
This follows directly from φ = 1 + 1/φ. Since all partial quotients are 1 (the smallest possible integer > 0), the convergents F(n+1)/F(n) improve as slowly as possible — φ is the hardest real number to approximate by rationals. This is the formal meaning of "most irrational".
Hurwitz's Theorem and Proximity Bound
Hurwitz's theorem states that for any irrational x, infinitely many rational fractions p/q satisfy:
The constant √5 is tight — it cannot be replaced by anything larger while still holding for all irrationals. The only number for which √5 is the precise best constant is φ (and related equivalents). Every other irrational can be approximated to a better constant. This is why φ is the worst case for rational approximation, and why rotation by 1/φ revolutions is the ideal angle for distributing growth on a spiral — no rational sub-harmonics can concentrate density.
4. Binet's Formula & Fast Fibonacci
The closed-form expression for F(n) (Binet 1843, though known to Euler and de Moivre earlier):
Since |ψ| < 1, ψⁿ → 0, and F(n) is simply the nearest integer to φⁿ/√5:
This allows direct O(1) computation — but only in exact arithmetic. In IEEE 754 double precision the rounding trick fails around n ≈ 75 (when F(75) ≈ 2.1 × 10¹⁵ exceeds the 53-bit mantissa). For large n, the matrix-exponentiation method is exact:
JavaScript Fast Fibonacci (BigInt)
// Fast Fibonacci via doubling identity (O(log n), exact integers)
// F(2n) = F(n) * (2*F(n+1) - F(n))
// F(2n+1) = F(n)^2 + F(n+1)^2
function fibBig(n) {
if (n == 0n) return [0n, 1n]; // returns [F(n), F(n+1)]
const [a, b] = fibBig(n >> 1n);
const c = a * (2n * b - a);
const d = a * a + b * b;
return (n & 1n) === 0n ? [c, d] : [d, c + d];
}
// Usage:
const [f100, _] = fibBig(100n);
console.log(f100.toString()); // 354224848179261915075 (exact)
5. Phyllotaxis: Why Plants Count in Fibonacci
Phyllotaxis is the study of the arrangement of leaves, seeds, and petals on a plant. In a sunflower head, seeds are arranged in interlocking spirals. Counting the spirals going clockwise and counterclockwise invariably yields consecutive Fibonacci numbers — typically 34 and 55, or 55 and 89 for large heads.
Why? Each new seed primordia emerges at the tip of the growing meristem and is positioned at an angle from the previous one determined by the divergence angle. The optimal angle — which maximises the minimum distance between any two seeds for all n — turns out to be the golden angle:
This is not biological speculation: it is a consequence of Hurwitz's theorem. Any rational fraction p/q as a divergence angle would clump seeds into q straight lines (q-fold symmetry). The most irrational angle (1/φ of a full turn) avoids all rational resonances and produces the most uniform filling.
Hofmeister's Hypothesis
The simplest mechanism that produces the golden angle is Hofmeister's rule (1868): each new primordium forms in the largest gap available in the current configuration. Computer simulations (Douady & Couder, 1992) show that this rule, applied iteratively to a disc with radially expanding elements, spontaneously generates the Fibonacci spiral pattern without any pre-programming of Fibonacci numbers — the sequence emerges from the physics of packing.
Fibonacci Spirals in Nature
- Sunflower: 34/55, 55/89, or 89/144 spirals depending on cultivar size
- Pine cone: 8/13 spirals (two perpendicular helices)
- Pineapple: 8/13/21 — three families of helices
- Cauliflower romanesco: approximate self-similar spiral — each floret is itself a smaller spiral
- Daisy petals: petal count is almost always a Fibonacci number (13, 21, 34)
- Nautilus shell: logarithmic spiral, but not precisely golden — the popular claim of φ is a myth
6. The Golden Angle & Sunflower Generator
The canonical sunflower seed arrangement: seed n is placed at angle n × 137.508° and radius proportional to √n (uniform area per seed):
// Sunflower phyllotaxis — Canvas 2D
function drawSunflower(canvas, N = 1000) {
const ctx = canvas.getContext('2d');
const cx = canvas.width / 2;
const cy = canvas.height / 2;
const c = canvas.width / (2.2 * Math.sqrt(N));
const PHI = (1 + Math.sqrt(5)) / 2;
const angle = 2 * Math.PI / (PHI * PHI); // golden angle ≈ 2.399 rad
ctx.fillStyle = '#0a0a14';
ctx.fillRect(0, 0, canvas.width, canvas.height);
for (let n = 0; n < N; n++) {
const theta = n * angle;
const r = c * Math.sqrt(n);
const x = cx + r * Math.cos(theta);
const y = cy + r * Math.sin(theta);
// Colour by angle fraction for visual spiral reveal
const hue = (n / N * 360 + 200) % 360;
ctx.beginPath();
ctx.arc(x, y, Math.max(1, c * 0.45), 0, Math.PI * 2);
ctx.fillStyle = `hsl(${hue}, 75%, 60%)`;
ctx.fill();
}
}
Effect of Divergence Angle
Changing the angle away from 137.508° reveals why it is optimal:
- 135° (3/8 of 360°): seeds align in 8 straight spokes — very non-uniform
- 138.46° (approximately 5/13 of 360°): 13 visible spokes
- 137.508°: no visible spokes at any scale — maximum uniformity
- 137.6°: already slightly worse — faint structure begins to appear
This sensitivity illustrates the extremal property: the golden angle is a narrow optimum, and biological selection pressure has found it reliably across hundreds of millions of years of plant evolution.
7. Logarithmic Spirals & Self-Similarity
A logarithmic spiral (also: equiangular spiral) has the polar equation:
Its defining property: the angle between the tangent at any point and the radial line is constant (the "equiangular" property). This angle α satisfies tan(α) = 1/b.
The Golden Spiral
The golden spiral grows by a factor of φ per quarter turn (90°). It arises from the Fibonacci rectangle dissection: each rectangle can be split into a square and a smaller golden rectangle, and a quarter-circle arc in each square approximates the spiral. The exact spiral has:
Each complete revolution multiplies the radius by e^(2πb) = φ⁴ ≈ 6.854. A half-revolution multiplies it by φ² ≈ 2.618. A quarter-revolution multiplies it by φ ≈ 1.618 — hence "golden".
Self-Similarity
The logarithmic spiral is the only planar curve that is self-similar under rotation. Rotating by angle θ₀ is identical to scaling by e^(b·θ₀). This means zooming into a logarithmic spiral at the origin while simultaneously rotating produces a stationary image — a property exploited in computer graphics for infinite-zoom fractal animations.
The golden spiral's self-similarity under 90° rotation (scaling by φ per quarter turn) is the reason the Fibonacci rectangle dissection works: each nested square contributes a quarter-turn of the spiral, and the rectangles tile perfectly because consecutive Fibonacci ratios converge to φ.
8. Zeckendorf's Theorem & Fibonacci Coding
Zeckendorf's Theorem
Every positive integer has a unique representation as a sum of non-consecutive Fibonacci numbers (Zeckendorf, 1972):
The proof of uniqueness relies on the Fibonacci identity F(n) = F(n−1) + F(n−2): if two consecutive F numbers appear in a representation, they can always be merged into the next F — so any representation with consecutive terms can be simplified to one without. Existence follows by induction using the greedy algorithm.
Fibonacci Coding (Data Compression)
Zeckendorf representations enable a universal code for integers:
Fibonacci coding has the property that it is a self-synchronising code: any occurrence of "11" in the bit stream marks either a codeword boundary or the terminator sequence. After a single bit error, the decoder resynchronises at the next "11" occurrence — a fault-tolerance property not shared by Huffman or arithmetic coding. This makes Fibonacci codes useful for database index compression (used in some versions of PostgreSQL's TOAST compression) and network protocol headers where stream synchronisation matters.
Fibonacci Search
The Fibonacci search algorithm is an alternative to binary search that uses Fibonacci numbers to partition the array, avoiding division and working better on media with non-uniform access costs (e.g. magnetic tape, some SSD layouts):
// Fibonacci search (sorted array arr, target value)
function fibSearch(arr, target) {
const n = arr.length;
let fibM2 = 0, fibM1 = 1, fib = 1; // F(k-2), F(k-1), F(k)
while (fib < n) { fibM2 = fibM1; fibM1 = fib; fib = fibM1 + fibM2; }
let offset = -1;
while (fib > 1) {
const i = Math.min(offset + fibM2, n - 1);
if (arr[i] < target) { fib = fibM1; fibM1 = fibM2; fibM2 = fib - fibM1; offset = i; }
else if (arr[i] > target) { fib = fibM2; fibM1 -= fibM2; fibM2 = fib - fibM1; }
else return i;
}
if (fibM1 && arr[offset + 1] === target) return offset + 1;
return -1;
}