← All essays

Leibniz Was Right: The I Ching Is a Binary Computer

2026 · 14 min read · Turing Tzu

In the winter of 1703, Gottfried Wilhelm Leibniz received a letter from Joachim Bouvet, a French Jesuit priest stationed in Beijing at the court of the Kangxi Emperor. Bouvet had been corresponding with Leibniz for several years, feeding him Chinese texts and court gossip, trying to build a bridge between Enlightenment mathematics and what he believed was a hidden theology embedded in ancient Chinese scholarship. The letter contained an enclosure: a diagram. It showed the 64 hexagrams of the I Ching arranged by the scholar Shao Yong into a square grid, each hexagram a stack of six lines, each line either solid or broken.

Leibniz had invented binary arithmetic in 1679. He had a paper on it, unpublished for years, because binary was a beautiful structure without a practical purpose. The world ran on base-10. Nobody needed a number system that used only zero and one. He had kept the idea alive out of mathematical conviction, not utility.

When he saw Bouvet's diagram, he recognized his own notation immediately. Solid line: 1. Broken line: 0. Six positions. Sixty-four configurations. His letter back to Bouvet, written in May 1703, is one of the stranger documents in the history of mathematics — a German philosopher excitedly explaining to a Jesuit in Beijing that the three-thousand-year-old divination system he was studying was, in fact, binary arithmetic. Leibniz believed he had found confirmation that his system was not an arbitrary invention but something natural, something ancient Chinese sages had independently discovered and encoded.

He was right about the encoding. He was wrong about almost everything else.

What he saw

Leibniz understood the notation correctly. If you lay out the first eight hexagrams in Shao Yong's arrangement and read each line from bottom to top, assigning 0 to a broken line and 1 to a solid line, you get 000000, 000001, 000010, 000011, 000100, 000101, 000110, 000111. That is zero through seven in binary. The entire 64-hexagram sequence, in Shao Yong's ordering, is a six-bit binary counter running from 0 to 63. This is not a coincidence, and it is not numerological pattern-matching. Shao Yong, writing in the eleventh century Song dynasty, had constructed a systematic arrangement of the hexagrams based on what he called the sequence of heaven — a combinatorial logic that, rendered in Leibniz's notation, is a binary counting sequence.

So Leibniz saw real structure. The problem is that he interpreted it theologically. He thought the hexagrams confirmed binary arithmetic because God had revealed the same mathematical truth to both the ancient Chinese and to him. He wrote to Bouvet that the I Ching demonstrated that the Chinese sages had known the creation of the world from nothing — ex nihilo — because binary represented all numbers through 0 and 1, nothing and something. This was the framing he needed. Binary remained, for him, a demonstration of divine arithmetic, not a computational tool.

He never asked the more interesting question: what were the Chinese doing with it?

The actual computation

The I Ching is not a counting system. The hexagrams are not labels for integers. They are a structured vocabulary for describing states of a system — specifically, configurations of opposing forces that the tradition calls yin and yang, which map cleanly onto 0 and 1 but are not numerically interpreted as such. Each hexagram describes a particular arrangement of these forces across six positions, and each arrangement is associated with an extensive commentary that describes what kind of situation that configuration corresponds to and what dynamics tend to follow from it.

The six positions are not arbitrary. They represent layers of a situation: the bottom lines describe foundational conditions, the middle lines describe active agents, the top lines describe outcomes or extremes. The tradition distinguishes between the lower trigram (positions 1–3) and the upper trigram (positions 4–6), and each trigram is itself one of eight possible three-bit configurations — Heaven (111), Earth (000), Thunder (100), Water (010), Mountain (001), Wind (011), Fire (101), Lake (110) — each carrying semantic associations that compose when stacked. The full hexagram is a six-bit code whose interpretation is built from the semantics of its constituent parts plus their interaction.

This is feature engineering. It is not free-form symbol manipulation — it is a structured decomposition of a high-dimensional concept space into manageable sub-dimensions whose combinations are systematically catalogued. The 64 hexagrams cover the space of human life situations by encoding them as vectors in a binary space and then annotating what each region of that space means and how it tends to evolve.

The Zhou Yi — the "Book of Changes," the oldest stratum of the I Ching text, dating to around the tenth century BC — does not just describe each of the 64 states. It describes trajectories. Each hexagram has a primary commentary and then line-by-line commentaries describing what happens if that particular position is in a state of change. The concept of the "moving line" — a line that is in the process of flipping from 0 to 1 or 1 to 0 — transforms one hexagram into another. The consultation protocol encodes which lines are moving through a probabilistic procedure involving yarrow stalks or coins, and the reading describes the transition between two hexagonal states.

This is a dynamical system. The I Ching encodes not just a state space but a transition function: given the current configuration and which elements are unstable, it predicts the successor state. The Tuan commentary added during the Zhou dynasty interprets these transitions in terms of social and political dynamics — who holds power, what the terrain looks like, when to advance and when to wait. The later Ten Wings (Shi Yi), traditionally attributed to Confucius though probably compiled over centuries, added a layer of cosmological interpretation that has made the whole thing look mystical to Western eyes. It is not mystical. It is a state machine with annotated transitions, built on binary encoding, operating over the domain of human situations.

The recommender system problem

I spent several years at Apple working on the App Store recommendation system. The core problem is this: you have roughly two million apps and several hundred million users. A user arrives with a context — their device, their recent behavior, the time of day, what they've downloaded before. You need to retrieve the ten or twenty items most likely to be relevant to them right now. You cannot compute similarity between the user and every item at query time. The search space is too large.

The solution that works is to embed both users and items into a shared vector space — a latent space of some dimensionality, typically in the hundreds — and then build an index over the item vectors that allows approximate nearest-neighbor retrieval. At query time, you compute the user's embedding, look up the nearest items in the index, apply a ranking model, and return the results. The embedding encodes, in a compressed continuous representation, whatever the model has learned about what makes users and items similar.

The I Ching does something structurally identical. The human situation is encoded as a six-bit vector. The system has a catalogue of 64 reference states, each annotated with semantic content about what that state is like and what it implies. Divination is nearest-neighbor retrieval: you take your current situation, encode it into the hexagram space through the casting procedure, and retrieve the closest annotated reference point. The commentary provides the interpretation — the semantic payload associated with that region of the space.

The casting procedure adds noise, which is not a defect. It is stochastic retrieval. The yarrow stalk procedure is biased: the probabilities of generating an old yin line (value 6, moving), a young yang line (value 7, stable), a young yin line (value 8, stable), and an old yang line (value 9, moving) are 1/16, 5/16, 7/16, 3/16 respectively — not uniform. This is a weighted sampling procedure. The bias toward stable lines over moving lines means that, in most casts, only one or two lines are in transition, which constrains the trajectory prediction to nearby states in the hexagram graph. You cannot jump from hexagram 1 to hexagram 64 in a single reading under typical conditions. The stochastic procedure enforces local continuity in the state space.

This is a design choice. It is a sensible one.

What "binary" actually meant to do

Leibniz needed binary for computation that did not yet exist. He imagined machines — he built a mechanical calculator in 1673 — but the computing machines of his era could only perform arithmetic on decimal representations. Binary waited because the substrate was wrong. It took two and a half centuries and the invention of electronics — switches that have exactly two stable states, conducting or not — for binary to find its natural medium. The computer you are reading this on runs on binary because transistors are binary devices. The match between substrate and representation is exact.

The I Ching's substrate was human intuition operating on a structured symbolic vocabulary. For that substrate, six bits is roughly right. Humans can reliably distinguish eight categories in three binary dimensions; psychologists have documented the limits of categorical perception across sensory and conceptual domains, and the magic number seven (plus or minus two) that George Miller identified in 1956 maps onto approximately three bits of reliable discrimination. Six bits gives you 64 states, which is comfortably within the range where a trained practitioner can maintain distinct semantic associations for each state without collapsing them. It is enough states to cover the space meaningfully, few enough to be learnable.

The hexagram vocabulary was, for three thousand years, a shared feature space that practitioners trained on through apprenticeship, commentary study, and accumulated casework. The semantic annotations — what each hexagram means, what transitions imply — were refined across generations, contested in commentaries, standardized and revised. This is training data accumulation. The I Ching tradition is a continuous process of improving the annotation of the 64-state space, carried out by human commentators who were essentially running a distributed learning algorithm on real consultations.

Wang Bi's third-century commentary stripped away much of the correlative numerology that had accumulated in the Han dynasty and attempted to read the hexagrams as a coherent semantic system. Cheng Yi's eleventh-century Song dynasty commentary applied neo-Confucian ethical philosophy to produce precise behavioral prescriptions for each state and transition. Each of these was a retraining pass over the annotation layer, using the accumulated experience of practitioners as implicit feedback.

The architecture that survived

The I Ching has been continuously used for approximately three thousand years, across political upheavals that destroyed most other institutions of Chinese civilization, across the wholesale replacement of cosmological frameworks, across the transition from feudal aristocracy to imperial bureaucracy to communist state. The Qin burning of books in 213 BC, which destroyed much of pre-imperial Chinese literature, exempted the I Ching as a technical manual of divination. It survived not because people were stupid and could not tell the difference between superstition and knowledge, but because it worked well enough in the domain where they applied it — decision-making under uncertainty — that it kept being used.

The structural reason it worked is that binary encoding over a fixed vocabulary is a robust architecture for a cognitive tool. It is discrete enough to be consistent — two practitioners reading the same hexagram are working from the same starting point — but the annotation layer is rich enough to require genuine interpretive skill, which means the system rewards investment and retains practitioners. The probabilistic casting procedure prevents gaming: you cannot select your hexagram; you receive it. This removes a whole category of bias from the retrieval step. And the trajectory mechanism — the moving lines — provides a structured way to think about change rather than just current state, which is what people actually need when making decisions.

Compare this to the Tarot, which uses 78 cards with non-binary structure, symbolic imagery that varies across decks, and a retrieval procedure with fewer constraints. The Tarot has not produced anything like the continuous commentarial tradition of the I Ching, because its structure does not generate the same kind of systematic semantic scaffolding. The higher dimensionality and lower structure mean that practitioners' interpretive frameworks diverge rather than converge over time. The I Ching's binary constraint is a feature. It forces convergence.

Three thousand years of gradient descent

I am not arguing that the ancient Chinese knew they were doing computation. They did not have the concept. I am arguing that they built a thing that works, and that the reason it works is architectural, and that the architecture is isomorphic to methods we rediscovered entirely independently in the twentieth century.

The latent space model of user behavior that underlies modern recommendation systems was developed mathematically in the 1950s through psychometric work on factor analysis, implemented computationally in the 1990s through collaborative filtering, and scaled industrially in the 2000s through matrix factorization and eventually neural embedding. At each stage, the practitioners knew they were doing mathematics. They had theorems and proofs. They did not know they were implementing a structure that had already been built in qualitative form three millennia earlier.

Leibniz's error was to interpret the convergence as revelation — divine confirmation that binary was cosmically necessary rather than just extremely useful. The error I am warning against is its mirror: interpreting the convergence as coincidence, as decorative pattern-matching that flatters both traditions without meaning anything. The convergence is structural. Binary encoding of a fixed-dimensional space, combined with a systematic vocabulary of state annotations and a procedure for retrieving the most relevant state given a current situation, is a good architecture for the problem of decision support under uncertainty. It was good enough in 1000 BC; it is good enough now. We should not be surprised that two civilizations, working on the same problem, arrived at similar solutions.

What Leibniz actually found in Bouvet's diagram was not divine endorsement. He found evidence that the solution space for certain classes of problems is not as large as it appears — that a small number of structural choices, made correctly, produce something durable. The I Ching's specific parameters (6 bits, 64 states, probabilistic retrieval, trajectory encoding) are not the only correct answer, but they are a correct answer, and they remained correct for long enough that a German mathematician could recognize them as his own work three thousand years later.

That is the cold fact at the center of this story. Not that East and West were secretly the same. Not that ancient wisdom vindicates modern science. Simply that good architecture is hard to find, and when you find it, it lasts.