ArticleslgStudy

computer science

Liu Hui's π algorithm

Liu Hui's π algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Liu Hui's π algorithm rather than just read about it. In short: Liu Hui's π algorithm was invented by Liu Hui (fl. 3rd century), a mathematician of the state of Cao Wei. Before his time, the ratio of the circumference of a circle to its diameter was often taken experimentally as three in China, while Zhang Heng (78–139) rendered it as 3.1724 (from the proportion of the celestial circle to the diameter of the earth, 92/29) or as π ≈ 10 ≈ 3.162 {\displaystyle \pi \approx {\sqrt {1…

Liu Hui's π algorithm — main illustration
Liu Hui's π algorithm — illustration

Key takeaways

  • Liu Hui's π algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Liu Hui's π algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Liu Hui's π algorithm from memory before moving on to harder problems.

Reference excerpt

Liu Hui's π algorithm was invented by Liu Hui (fl. 3rd century), a mathematician of the state of Cao Wei. Before his time, the ratio of the circumference of a circle to its diameter was often taken experimentally as three in China, while Zhang Heng (78–139) rendered it as 3.1724 (from the proportion of the celestial circle to the diameter of the earth, 92/29) or as π ≈ 10 ≈ 3.162 {\displaystyle \pi \approx {\sqrt {10}}\approx 3.162} . Liu Hui was not satisfied with this value. He commented that it was too large and overshot the mark. Another mathematician Wang Fan (219–257) provided π ≈ 142/45 ≈ 3.156. All these empirical π values were accurate to two digits (i.e. one decimal place). Liu Hui was the first Chinese mathematician to provide a rigorous algorithm for calculation of π to any accuracy. Liu Hui's own calculation with a 96-gon provided an accuracy of five digits i.e. π ≈ 3.1416. Liu Hui remarked in his commentary to The Nine Chapters on the Mathematical Art, that the ratio of the circumference of an inscribed hexagon to the diameter of the circle was three, hence π must be greater than three. He went on to provide a detailed step-by-step description of an iterative algorithm to calculate π to any required accuracy based on bisecting polygons; he calculated π to between 3.141024 and 3.142708 with a 96-gon; he suggested that 3.14 was a good enough approximation, and expressed π as 157/50; he admitted that this number was a bit small. Later he invented a quick method to improve on it, and obtained π ≈ 3.1416 with only a 96-gon, a level of accuracy comparable to that from a 1536-gon. His most important contribution in this area was his simple iterative π algorithm.

Area of a circle

Liu Hui argued:

"Multiply one side of a hexagon by the radius (of its circumcircle), then multiply this by three, to yield the area of a dodecagon; if we cut a hexagon into a dodecagon, multiply its side by its radius, then again multiply by six, we get the area of a 24-gon; the finer we cut, the smaller the loss with respect to the area of circle, thus with further cut after cut, the area of the resulting polygon will coincide and become one with the circle; there will be no loss". This is essentially equivalent to:

lim N → ∞ area of N -gon = area of circle . {\displaystyle \lim _{N\to \infty }{\text{area of }}N{\text{-gon}}={\text{area of circle}}.\,}

Further, Liu Hui proved that the area of a circle is half of its circumference multiplied by its radius. He said: "Between a polygon and a circle, there is excess radius. Multiply the excess radius by a side of the polygon. The resulting area exceeds the boundary of the circle". In the diagram d = excess radius. Multiplying d by one side results in oblong ABCD which exceeds the boundary of the circle. If a side of the polygon is small (i.e. there is a very large number of sides), then the excess radius will be small, hence excess area will be small. As in the diagram, when N → ∞, d → 0, and ABCD → 0. "Multiply the side of a polygon by its radius, and the area doubles; hence multiply half the circumference by the radius to yield the area of circle". When N → ∞, half the circumference of the N-gon approaches a semicircle, thus half a circumference of a circle multiplied by its radius equals the area of the circle. Liu Hui did not explain in detail this deduction. However, it is self-evident by using Liu Hui's "in-out complement principle" which he provided elsewhere in The Nine Chapters on the Mathematical Art: Cut up a geometric shape into parts, rearrange the parts to form another shape, the area of the two shapes will be identical. Thus rearranging the six green triangles, three blue triangles and three red triangles into a rectangle with width = 3L, and height R shows that the area of the dodecagon = 3RL. In general, multiplying half of the circumference of a N-gon by its radius yields the area of a 2N-gon. Liu Hui used this result repetitively in his π algorithm.

Liu Hui's π inequality

Liu Hui proved an inequality involving π by considering the area of inscribed polygons with N and 2N sides. In the diagram, the yellow area represents the area of an N-gon, denoted by A N {\displaystyle A_{N}} , and the yellow area plus the green area represents the area of a 2N-gon, denoted by A 2 N {\displaystyle A_{2N}} . Therefore, the green area represents the difference between the areas of the 2N-gon and the N-gon:

D 2 N = A 2 N − A N . {\displaystyle D_{2N}=A_{2N}-A_{N}.}

The red area is equal to the green area, and so is also D 2 N {\displaystyle D_{2N}} . So

Yellow area + green area + red area = A 2 N + D 2 N . {\displaystyle A_{2N}+D_{2N}.}

Let A C {\displaystyle A_{C}} represent the area of the circle. Then

A 2 N < A C < A 2 N + D 2 N . {\displaystyle A_{2N}<A_{C}<A_{2N}+D_{2N}.}

If the radius of the circle is taken to be 1, then we have Liu Hui's π inequality:

… excerpt ends here. Continue reading the full article.

Illustrations

Liu Hui's π algorithm: Liu Hui's method of calculating the area of a circle
Liu Hui's method of calculating the area of a circle
Liu Hui's π algorithm: The area within a circle is equal to the radius multiplied by half the circumference, or A = r x C/2 = r x r x π.
The area within a circle is equal to the radius multiplied by half the circumference, or A = r x C/2 = r x r x π.
Liu Hui's π algorithm: Liu Hui's π inequality
Liu Hui's π inequality
Liu Hui's π algorithm: Liu Hui's π algorithm
Liu Hui's π algorithm

Worked examples

Example 1 — a first encounter with Liu Hui's π algorithm

Start with the simplest possible case. Write down what Liu Hui's π algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Liu Hui's π algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Liu Hui's π algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Liu Hui's π algorithm

In research
Liu Hui's π algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Liu Hui's π algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Liu Hui's π algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Cao Wei, Chinese mathematical discoveries, Pi algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Liu Hui's π algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Liu Hui's π algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Liu Hui's π algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Liu Hui's π algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Liu Hui's π algorithm in simple terms?

Liu Hui's π algorithm was invented by Liu Hui (fl. 3rd century), a mathematician of the state of Cao Wei. Before his time, the ratio of the circumference of a circle to its diameter was often taken experimentally as three in China, while Zhang Heng (78–139) rendered it as 3.1724 (from the proportio…

Why does Liu Hui's π algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Liu Hui's π algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Liu Hui's π algorithm.

Tags

  • Cao Wei
  • Chinese mathematical discoveries
  • Pi algorithms

Keep exploring