Back to blog
#Bazi #Qimen Dunjia #Information Theory #Mathematical Metaphysics #I Ching Foundations

The Evolution of the Heavenly Stems and Earthly Branches and the Transformation of Dun Jia: A Unified Mathematical Metaphysical Study of the Information Capacity in Bazi and Qimen Dunjia

This paper systematically investigates the information-carrying capacity of Bazi (Eight Characters) and Qimen Dunjia (Mystical Gates) as divination systems, starting from the mathematical structure of Taiji, Liangyi, Sixiang, and Bagua in the *Book of Changes*. By analyzing the classical mathematical foundations such as Yin-Yang, Five Phases, the River Chart, and the Luo Script, it aims to provide a unified perspective for measuring and comparing the information density of these two divination arts.

Tianwen Editorial Team February 7, 2026 85 min read PDF Markdown
The Evolution of the Heavenly Stems and Earthly Branches and the Transformation of Dun Jia: A Unified Mathematical Metaphysical Study of the Information Capacity in Bazi and Qimen Dunjia

Chapter 1: The Initial Judgment of Heaven and Earth and the Beginning of Mathematical Principles—The Creation of Images and Numbers by the Ancient Sage-Kings

Section 1: Taiji Gives Birth to the Two Modes: Yin and Yang as the Origin of Information

The foundation of all arts of calculation lies in Yin and Yang.

The Book of Changes, Great Treatise (Part I) states:

"The Yi has the Supreme Ultimate (Taiji); this gives birth to the Two Modes (Liangyi); the Two Modes give birth to the Four Images (Sixiang); the Four Images give birth to the Eight Trigrams (Bagua)." (Yì yǒu tàijí, shì shēng liǎngyí, liǎngyí shēng sìxiàng, sìxiàng shēng bāguà.)

These few sentences are the grand outline of Chinese mathematical thinking. Taiji is the undifferentiated "One" of chaos; the Liangyi are the "Two" resulting from the differentiation of Yin and Yang. From "One" to "Two" is the beginning of information. Why is this so$7 Taiji is chaos, undifferentiable, thus there is no information to speak of. When Yin and Yang are distinguished, there is light and dark, hard and soft, movement and stillness; only then can things be "distinguished"—and "distinction" is the essence of information.

Chapter 42 of the Laozi states:

"The Dao produces One; One produces Two; Two produces Three; Three produces all things. The myriad things carry Yin on their back and embrace Yang in their arms; harmony is achieved through the blending of vital energy (chong qì)." (Dào shēng yī, yī shēng èr, èr shēng sān, sān shēng wànwù. Wànwù fù yīn ér bào yáng, chōng qì yǐ wéi hé.)

Laozi's "One produces Two" corresponds to the Xici Zhuan's "Taiji gives birth to the Two Modes." Once Yin and Yang are differentiated, the myriad things can be categorized, named, and inferred—this is the prerequisite for the emergence of information.

Consider deeply: Why can the "Two Modes" give birth to information$8 For Yin and Yang do not merely refer to light/dark or cold/heat; they are the general terms for all complementary opposites. With this opposition comes relationship; with relationship comes distinction; with distinction comes recognition; with recognition comes judgment—the flow of information begins here.

The Guanzi, Inner Cultivation Chapter (Neiye) states:

"The essence (jīng) of all things, this becomes life. Below it gives birth to the five grains; above it becomes the array of stars. Flowing between Heaven and Earth, it is called Ghost and Spirit (guǐshén); hidden within the chest, it is called the Sage." (Fán wù zhī jīng, cǐ zé wéi shēng. Xià shēng wǔ gǔ, shàng wéi liè xīng. Liú yú tiāndì zhī jiāijiān, wèi zhī guǐshén; cáng yú xiōngzhōng, wèi zhī shèngrén.)

This "essence" (jīng) is the subtle matter (jīngwēi) transformed by the interaction of Yin and Yang. Within this subtlety is contained the information of all things under Heaven, thus it can "below give birth to the five grains, above become the array of stars." Without the content of this information, how could the five grains differ$9 How could the stars be distinct$10

When we discuss the information capacity of Bazi and Qimen Dunjia, we must first realize: both take Yin and Yang as their fundamental informational units. The "position" (wèi) of one Yin and one Yang constitutes the smallest unit of information—like the modern "bit" (bǐtè)—a single position can carry two values: Yin or Yang. The complexity of all arcane arts arises from the superposition, combination, and transformation of these Yin and Yang units.

Section 2: The Two Modes Give Birth to the Four Images: The First Expansion of Information

The superposition of the Two Modes gives birth to the Four Images (Sixiang).

The original meaning of "Four Images" in the Xici Zhuan refers to Greater Yang, Lesser Yin, Lesser Yang, and Greater Yin—the dual-position combinations of Yin and Yang. If we denote Yang as "—" and Yin as "--", then:

  • Greater Yang: Yang above, Yang below (— —)
  • Lesser Yin: Yin above, Yang below (-- —)
  • Lesser Yang: Yang above, Yin below (— --)
  • Greater Yin: Yin above, Yin below (-- --)

The Four Images represent all possible arrangements of two Yin/Yang positions. Mathematically, $2^2 = 4$, which is the mathematical basis of the Four Images.

Why are the Four Images important$11 Because the Four Images correspond to the Four Seasons—Spring, Summer, Autumn, Winter—which is the fundamental framework for the operation of the Heavenly Way. The Book of Documents, Canon of Yao (Shangshu: Yao Dian) records:

"He then commanded Xi and He, to respectfully follow the vast Heaven, calculate the ephemerides of the sun, moon, and stars, and diligently present the proper times to the people. Xi Zhong was separately commanded to reside in (Eastern lands), called the Valley of Yang. At sunrise in the Yin position, they regulated the work in the East. At midday, the star Niao (Heart), marking the middle of Spring... Xi Shu was separately commanded to reside in the Southern Border. They regulated the flourishing in the South, showing reverence. When the sun is at its zenith, the star Huǒ (Sharp), marking the middle of Summer... He Zhong was separately commanded to reside in the West, called the Valley of Darkness. At sunset in the Yin position, they regulated the harvest in the West. When the night is at its midpoint, the star Mǎo (Pleiades), marking the middle of Autumn... He Shu was separately commanded to reside in the Northern Quarter, called Yōu Dū. They regulated the transition in the North. When the day is short, the star Mǎo (Pleiades), marking the middle of Winter..."

This records Emperor Yao commanding the four sons of Xi and He to be in charge of the Four Seasons. The Four Seasons constitute the first layer of the framework for the information of the Heavenly Way. The four pillars (Year, Month, Day, Hour) of Bazi are based on the succession of the Four Seasons; the layout of Qimen Dunjia also takes the Four Seasons as the basis for initiating the chart. Thus, the principle of the Four Images is the common mathematical foundation for both arts.

Section 3: The Four Images Give Birth to the Eight Trigrams: The Second Expansion of Information

The superposition of the Four Images, by adding one more line, gives birth to the Eight Trigrams (Bāguà).

The Xici Zhuan states: "The Four Images give birth to the Eight Trigrams." The Eight Trigrams represent all possible arrangements of three Yin/Yang lines. $2^3 = 8$, which is the mathematical basis of the Eight Trigrams.

The names and images of the Eight Trigrams:

Qian is three connected lines (☰), Kun is six broken lines (☷), Zhen is an upturned bowl (☳), Gen is an inverted bowl (☶), Li is hollow in the center (☲), Kan is full in the center (☵), Dui has a gap on top (☱), Xun has a break below (☴).

The Shuogua Zhuan details the images of the Eight Trigrams:

"Qian is Heaven, Kun is Earth, Zhen is Thunder, Xun is Wind, Kan is Water, Li is Fire, Gen is Mountain, Dui is Lake."

"Qian, vigorous. Kun, yielding. Zhen, moving. Xun, entering. Kan, sinking. Li, adhering. Gen, stopping. Dui, pleasing."

"Qian is the horse, Kun is the ox, Zhen is the dragon, Xun is the cock, Kan is the swine, Li is the pheasant, Gen is the dog, Dui is the sheep."

"Qian is the head, Kun is the abdomen, Zhen is the foot, Xun is the thigh, Kan is the ear, Li is the eye, Gen is the hand, Dui is the mouth."

The information capacity of the Eight Trigrams lies not only in their number (eight symbols) but also in their "Images" (Xiàng). Each trigram can be associated with infinite images—this is the core feature of symbolic information encoding in arcane arts: to bear infinite symbolic meaning through a finite set of symbols.

Here we must ask a critical question:

Why is the information capacity of the Eight Trigrams far greater than their mathematical combination number (eight)$12

The answer is: because the Eight Trigrams are not merely numerical symbols but symbols of "Images." An "Image" (Xiàng) is a category (lèi). The Xici Zhuan states: "The Sage perceived the intricacy () of the world below, and modeled it on its forms, symbolizing its suitability for things; therefore, it is called Image." To "model it on its forms, symbolizing its suitability for things" means using the trigram images to "simulate" the forms and laws of all things in Heaven and Earth. The image of one trigram can encompass a category of things—and the capacity of a "category" is far greater than that of an "individual." Therefore, the information capacity of the Eight Trigrams cannot be simply counted as "8," but should be counted as "8 × N," where N is the number of image categories encompassed by each trigram, theoretically tending toward infinity.

This principle is crucial for comparing the information capacities of Bazi and Qimen Dunjia—one must not only count the number of mathematical combinations but also measure the breadth of the symbolic semantic space mapped by each combination.

Section 4: The Eight Trigrams Doubled to Form Sixty-Four Hexagrams: The Third Expansion of Information

The doubling of the Eight Trigrams results in the Sixty-Four Hexagrams (Liùshísì Guà).

The Xici Zhuan states:

"The Eight Trigrams, when made small, are extended and stretched, categorized and enlarged; the matters of the world below are thereby completed." (Bāguà ér xiǎo chéng, yǐn ér shēn zhī, chùlèi ér zhǎng zhī, tiānxià zhī néngshì bìyǐ.)

"And then doubled, the lines (yáo) are contained within. Hardness and softness push and change each other, transformation is contained within. Statements are attached to name them, movement is contained within." (Yīn'ér chóng zhī, yáozài qízhōng yǐ. Gāngróu xiāngtuī, biànzài qízhōng yǐ. Xì cí yān ér mìng zhī, dòngzài qízhōng yǐ.)

The doubling of the Eight Trigrams is the superimposition of the upper and lower primary trigrams. $8 \times 8 = 64$, which is the mathematical basis for the Sixty-Four Hexagrams. And each hexagram has six lines, each line having two values (Yin or Yang), meaning the total number of information positions in the Sixty-Four Hexagrams is $64 \times 6 = 384$ lines.

The Xici Zhuan also states:

"The divination sticks for Qian number two hundred and sixteen, and for Kun one hundred and forty-four; in total three hundred and sixty, corresponding to the days of the year. The sticks of the two sections total eleven thousand five hundred and twenty, corresponding to the number of the myriad things." (Qián zhī cè èrbǎi yīshíyù, kūn zhī cè yīshíwùyù, fán sānbǎi yǒu liùshí, dāng qī zhī rì. Èr piān zhī cè wàn yī qiān wǔbǎi èrshí, dāng wànwù zhī shù yě.)

This refers to the number of sticks used in the divination process. The Qian hexagram has six lines, each line assigned thirty-six sticks, so $6 \times 36 = 216$. The Kun hexagram has six lines, each assigned twenty-four sticks, so $6 \times 24 = 144$. $216 + 144 = 360$, corresponding to the days of the year. This is the unification of mathematical principles and the Heavenly Way. And "the sticks of the two sections total eleven thousand five hundred and twenty," meaning the total information capacity expressed mathematically for the sixty-four hexagrams is 11,520—this "corresponds to the number of the myriad things."

Why does 11,520 "correspond to the number of the myriad things"$13 This requires deep reflection. The 360 days of the year are the cycle of the Heavenly Way; the 11,520 sticks are the mathematical expression of the total information capacity of the sixty-four hexagrams. Looking at $11,520 / 360 = 32$, this happens to be half of the sixty-four hexagrams—which implicitly agrees with the principle that Yin and Yang are balanced. Such a mathematical structure is not accidental; it was established by the Sages after deeply discerning the mathematical laws of the Heavenly Way.

The significance of the Sixty-Four Hexagrams lies in this: they constitute a complete "Cosmic Information Encoding System." What the Xici Zhuan refers to as "vast and fully equipped" (guǎngdà xī bèi) means precisely this. All things under Heaven can be encoded, categorized, and inferred using the framework of the Sixty-Four Hexagrams.

Both Bazi and Qimen Dunjia can be seen as "adaptations" (huàcái) of the Sixty-Four Hexagram System—transforming the cosmic information carried by the sixty-four hexagrams into operational arcane forms through different methods.

Section 5: The Five Numbers of Heaven and Five Numbers of Earth: The Mathematical Foundation of the River Chart and Luo Writing

The Xici Zhuan states:

"Heaven is One, Earth is Two; Heaven is Three, Earth is Four; Heaven is Five, Earth is Six; Heaven is Seven, Earth is Eight; Heaven is Nine, Earth is Ten. The numbers of Heaven are five, the numbers of Earth are five; the five combine in pairs, each having a total. The sum of the numbers of Heaven is twenty-five, the sum of the numbers of Earth is thirty; in total, Heaven and Earth together number fifty-five. This is how change is accomplished and spirits and ghosts are moved." (Tiān yī dì èr, tiān sān dì sì, tiān wǔ dì liù, tiān qī dì bā, tiān jiǔ dì shí. Tiān shù wǔ, dì shù wǔ, wǔ xiāng dé ér gè yǒu hé. Tiān shù èrshíyǒu wǔ, dì shù sānshí, fán tiāndì zhī shù wǔshíyǒu wǔ. Cǐ shì yǐ chéng biànhuà ér xíng guǐshén yě.)

This is the "Numbers of Heaven and Earth." The Heavenly Numbers (odd): 1, 3, 5, 7, 9, summing to 25; the Earthly Numbers (even): 2, 4, 6, 8, 10, summing to 30. The total sum of Heaven and Earth numbers is 55.

These 55 numbers are closely related to the River Chart (Hétú) and Luo Writing (Luòshū).

The numbers of the River Chart:

Heaven generates Water by One, Earth completes it by Six (North). Earth generates Fire by Two, Heaven completes it by Seven (South). Heaven generates Wood by Three, Earth completes it by Eight (East). Earth generates Metal by Four, Heaven completes it by Nine (West). Heaven generates Earth by Five, Earth completes it by Ten (Center).

The Generating Numbers (1, 2, 3, 4, 5) sum to 15; the Completing Numbers (6, 7, 8, 9, 10) sum to 40; the total sum is 55—which is the sum of the Heavenly and Earthly Numbers.

The numbers of the Luo Writing:

Nine on top, One below; Three on the left, Seven on the right; Two and Four form the shoulders, Six and Eight form the feet; Five resides in the center.

The numbers in the Luo Writing sum to fifteen in all rows, columns, and diagonals—this is the mathematical structure of a third-order magic square.

The distinction between the River Chart and Luo Writing corresponds precisely to different facets of the mathematical foundations of Bazi and Qimen Dunjia.

The River Chart governs "Generation" (Shēngchéng)—Heaven One generates Water, Earth Two generates Fire, etc. This represents the sequential generation and completion of the Five Phases in the time series, matching the characteristic of Bazi, which takes the flow of time (Year, Month, Day, Hour) as its main axis. The essence of Bazi is to grasp the pattern of "generation" (shēngchéng) of Yin/Yang and Five Phases at the moment of a person's birth—thus its mathematical foundation leans toward the River Chart.

The Luo Writing governs "Arrangement" (Bùliè)—the fixed positions of the Nine Palaces, with their intersecting numerical relationships expressed spatially—matching the characteristic of Qimen Dunjia, which uses the Nine Palaces as a board and arranges various symbols in spatial orientations. The essence of Qimen Dunjia is to grasp the "arrangement" (bùliè) pattern of the Heaven, Man, and Earth plates in a specific time-space—thus its mathematical foundation leans toward the Luo Writing.

However, the River Chart and Luo Writing are not entirely separate entities. The Xici Zhuan states:

"The River produced a chart, Luo produced writing; the Sages took them as models." (Hé chū tú, Luò chū shū, shèngrén zé zhī.)

The Sages "took them as models," meaning they established arcane arts based on the River Chart and Luo Writing. The numbers of the River Chart and the numbers of the Luo Writing correspond, transform, and interweave. Although Bazi leans toward time (River Chart), it also contains spatial information; although Qimen Dunjia leans toward space (Luo Writing), it also uses time to initiate the chart. The comparison of their information capacities first manifests as a comparison of the mathematical capacities of the River Chart system versus the Luo Writing system.

Let us ask: Is the mathematical capacity of the River Chart greater, or is the capacity of the Luo Writing greater$14

Core data of the River Chart: 5 pairs of generating numbers, totaling 10 numbers, summing to 55. Core data of the Luo Writing: 9 palace positions, summing to 45, with only 1 arrangement structure for the third-order magic square (8 including rotations and reflections).

From a purely combinatorial mathematics perspective, the "generative relationship" of the River Chart contains the mutual generation and overcoming relationships of the Five Phases; its information capacity lies in "relationship" rather than "arrangement." The "nine-palace arrangement" of the Luo Writing contains the intersecting relationships of spatial directions; its information capacity lies in "structure" rather than "generation."

Here we see a deeper pattern: A temporal information system (e.g., River Chart $\rightarrow$ Bazi) determines its information capacity mainly by "sequential relationships"; a spatial information system (e.g., Luo Writing $\rightarrow$ Qimen) determines its information capacity mainly by "structural relationships." Sequential relationships are one-dimensional, while structural relationships are multi-dimensional—this might suggest that the information capacity of Qimen Dunjia could, in some respects, be greater than that of Bazi.

However, this inference requires more detailed argumentation, which will be unfolded in the subsequent sections.

Section 6: The Great Extrapolation Number and the Information Theory of Divination

The Xici Zhuan further states:

"The Great Extrapolation Number is Fifty, and forty-nine are used. Divide them into two to symbolize the Two Modes; suspend one to symbolize Three; strip them four by four to symbolize the Four Seasons; return the remainder to the pile to symbolize the intercalary month. After five years, there are two intercalary months, so after two remainders are returned, one is suspended." (Dàyǎn zhī shù wǔshí, qí yòng sìshíyǒu jiǔ. Fēn ér wéi èr yǐ xiàng liǎng, guà yī yǐ xiàng sān, shiè zhī yǐ sì yǐ xiàng sìshí, guī qí yú lèi yǐ xiàng rùn. Wǔ nián zài rùn, gù zài lèi ér hòu guà.)

This describes the method of divination using yarrow stalks (shéshī). The Great Extrapolation Number is Fifty, but Forty-nine are used. This process of dividing, suspending, stripping, and returning the 49 stalks ultimately yields four results for a single line: Elder Yang, Lesser Yin, Lesser Yang, Elder Yin.

Why is the Great Extrapolation Number Fifty$15 The Xici Zhuan does not explain, and there are many debates. From a mathematical perspective: $55$ (Heaven and Earth Numbers) $- 5$ (Heaven's Five) $= 50$. Heaven's Five resides in the center and is unused, taking the remaining 50, and then discarding one unused stalk (49). The meaning of this "omission of One" is profound—Laozi says "Dao produces One"; this "One" is the number of Taiji, omitted because it is untouchable. Thus, the usable number is 49.

$49 = 7 \times 7 = 7^2$. Seven is the number of Lesser Yang (Heaven Seven). Multiplying the number of Lesser Yang by itself yields the base number for divination, implying the meaning that Lesser Yang governs generation and activity.

In each round of divination (three changes), the 49 stalks are distributed according to specific numerical values, and the resulting probability distribution is:

  • Elder Yang (Value 36): Probability 3/16
  • Lesser Yin (Value 32): Probability 5/16
  • Lesser Yang (Value 28): Probability 7/16
  • Elder Yin (Value 24): Probability 1/16

This probability distribution is not uniform—Lesser Yang (7/16) is most frequent, Elder Yin (1/16) is least frequent, implicitly agreeing with the principle that "Yang governs emergence, Yin governs concealment."

From an information theory perspective, a non-uniform distribution has lower information entropy than a uniform distribution. If all four outcomes were equally probable, the entropy per line would be $\log_2(4) = 2$ bits. Under the non-uniform probabilities of yarrow divination, the entropy ($H$) is:

$H = - (3/16 \cdot \log_2(3/16) + 5/16 \cdot \log_2(5/16) + 7/16 \cdot \log_2(7/16) + 1/16 \cdot \log_2(1/16))$

This value is approximately $1.749$ bits, which is less than 2 bits.

The total information entropy for a complete hexagram (six lines) is approximately $6 \times 1.749 \approx 10.49$ bits.

This is the amount of information obtained from one complete divination—about $10.5$ bits.

Using this as a reference, we can similarly calculate the information capacities of Bazi and Qimen Dunjia.

We must ask: Why did the Sages establish such a non-uniform probability distribution$16 Wouldn't a uniform distribution be more "fair"$17

The answer is: The Heavenly Way is inherently not "uniform." The lengths of Spring, Summer, Autumn, and Winter are different; the waxing and waning of day and night are unequal; the rise and fall of the Five Phases change constantly—this is the actual state of the "non-uniformity" of the Heavenly Way. The Sages' divination method simulates precisely this "non-uniformity" of the Heavenly Way. The information encoding of arcane arts does not seek "uniformity" but rather "conformity to the Dao" (hézō*). This differs from the pursuits of pure mathematics later on. The information structures of Bazi and Qimen Dunjia also possess their own forms of "non-uniformity"; this "non-uniformity" is precisely the characteristic of their respective information.