# A World So Phi-ne

My last posts have been practical and concrete, aiming to take the mind-boggling and make it evident. This time around, I wanted to choose something more abstract, theoretical — to take something evident and make it mind-boggling. Enter the Golden Ratio.

If you’re any kind of nerd, you’ve probably already heard of the Golden Ratio. This intriguing number has so many curious qualities and appears in so many aspects of life that it comes to seem almost mystical.

In physics, biology, mathematics, music, art — all disciplines concerned with making sense of and finding order in the universe — there is a hidden constant, a single variable that repeatedly asserts itself. That constant is *phi*, or the “Golden Ratio.” The number itself — 1.61803339… — is an irrational number, like *pi*, which means that it can’t be expressed in a fraction. That, aside from that fact that it sounds cool, isn’t particularly interesting. What *is *interesting is that phi* *can be expressed in a fractal: an indefinitely repeating pattern that contains itself.

The Golden Ratio can be expressed as a fractal.

Phi (φ)* *equals 1 + 1/φ. Which is the same as saying φ = 1 + 1/(1 + 1/φ). And on and on and on.

It’s another infinite recursion no matter how you play with the equation. Multiply both sides by φ, and you get φ² = 1 + φ. This means φ = √(1 + φ), which is the same as φ = √(1 + √(1 + φ)), and on and on and on:

Now, we see that phi is a pretty unique and curious number. It reaches a level of near-mysticism when we see how often it crops up in the world around us.

The golden ratio is a number found in the count and arrangement of petals on a flower, the breeding patterns of rabbits and bees, the spread of branches on a tree, the curve of the galaxy. The natural world intrinsically organizes itself around this number.

This *bit* of *information* is in everything around us (see where I’m going with this?). And that includes, naturally, computer and information science, where the Golden Ratio is a long-standing locus of study and theorizing.

How does the golden ratio crop up in computer programming?

1) You may have heard of binary search (bsearch in Ruby), a search algorithm that’s exponentially faster than a regular search. But you probably haven’t heard of the **golden section search** or its close cousin, the **Fibonacci search**. Instead of searching data by segmenting it in halves, these search algorithms segment data according to the golden mean.

With normal data, the Fibonacci search is just as fast as binary search, but it’s even better with more complex information — like datasets that are too large to load into the CPU cache at once, or for finding the minimum/maximum point on the chart of a complicated function. It’s particularly useful in data science.

2) Life is full of complexities, branching logic and weighted decision-making. In programming, this is reflected as priority queues: data organized not just by location (like an array or hash), but also by priority. Imagine a triage doctor, deciding which patient has the greatest need for immediate attention. **Heaps** are the tree-like data structures that implement priority queues, in fields like statistics, number theory, operating systems, artificial intelligence and on.

Fibonacci numbers and the golden ratio are the cornerstone of the most efficient structure for organizing this data: the **Fibonacci heap**.

3) The golden ratio is useful not only for sorting data, but also for concealing it, with *phi* as the constant value at the root of encryption algorithms.

4) And finally: web design. Just as the golden ratio appears in art and architecture, it also appears online, in the sites we interact with every day.

*This article is a stub. You can improve it by teaching Anna about information theory, computer science, Fibonacci numbers, and the Theory of Everything, so she could write more about it.*