Shushu Jiuzhang Dayanlei 5

The following number theory problem is from the *Shushu Jiuzhang* (數書九章) by Qin Jiushao (秦九韶, 1202 - 1261 AD). The solution presented here outlines Qin Jiushao's version of the Euclidean algorithm (大衍求一術 *dayan qiuyi shu*) and his generalized Chinese Remainder Theorem (大衍總數術 *dayan zongshu shu*).

## **Problem**

**Traditional Chinese**

問有上農三人，力田所收之米，系用足斗均分，各往他處出糶，甲糶與本郡官場，餘三斗二昇。乙果與安吉鄉民，餘七斗。丙糶與平江攬戶，餘三斗。欲知共米及三人所分各糶石數幾何？

**Simplified Chinese**

问有上农三人，力田所收之米，系用足斗均分，各往他处出粜，甲粜与本郡官场，余三斗二升。乙果与安吉乡民，余七斗。丙粜与平江揽户，余三斗。欲知共米及三人所分各粜石数几何?

**English Translation**

There are three farmers of the highest class. As for the grain they harvested from their fields, when making use of a full standard *dou*, the amounts are the same. All of them go to different places to sell their grain. After selling his grain on the official markets of his own prefecture, A has 3 *dou* 2 *sheng* remaining. After selling his grain to the villagers of Anji, B has 7 *dou* remaining. After selling his grain to an agent from Pingjiang, C has 3 *dou* remaining. How much grain did the farmers have altogether, and how much did each farmer sell in terms of the respective capacity rates in *dan*?

In the solution, Qin Jiushao reveals that each market has a different unit of volume called *hu* (斛): the official market *hu* is 8 *dou* 3 *sheng*, the Anji *hu* is 1 *dan* 1 *dou*, and the Pingjiang *hu* is 1 *dan* 3 *dou* 5 *sheng*.

Since 1 *dan* = 10 *dou* = 100 *sheng* and 1 *dou* = 10 *sheng*, this problem is a system of indeterminate equations:

{

N

≡
32

(
mod

83
)

N

≡
70

(
mod

110
)

N

≡
30

(
mod

135
)

{\displaystyle \begin{cases}
 N &\equiv 32 \pmod{83} \\
 N &\equiv 70 \pmod{110} \\
 N &\equiv 30 \pmod{135}
\end{cases}}

Calculate the lowest positive integer solution.

## **Solution**

**Part 1: Determine the *dingshu* 求定數**

The initial problem begins with the moduli, which Qin Jiushao called *wenshu* (問數), are

m
1

=
83
,

m
2

=
110
,

m
3

=
135

{\displaystyle m\_1 = 83, m\_2 = 110, m\_3 = 135 }

. Since the moduli are natural numbers, they are referred to as *yuanshu* (元數) and the remainders

r
1

=
32
,

r
2

=
70
,

r
3

=
30

{\displaystyle r\_1 = 32, r\_2 = 70, r\_3 = 30 }

.

{

N

≡
32

(
mod

83
)

N

≡
70

(
mod

110
)

N

≡
30

(
mod

135
)

{\displaystyle \begin{cases}
 N &\equiv 32 \pmod{83} \\
 N &\equiv 70 \pmod{110} \\
 N &\equiv 30 \pmod{135}
\end{cases}}

Notice that the second and third moduli are not coprime because 110 and 135 share a common divisor 5. This is determined by an often lengthy procedure called the *lianhuan qiudeng* (連環求等). Qin Jiushao’s algorithm prescribes that the congruence of odd moduli be reduced, which in this case is the third moduli. The new moduli, called *dingshu* (定數), are

m

1

′

=
83
,

m

2

′

=
110
,

m

3

′

=
27

{\displaystyle m\_{1}^{'} = 83, m\_{2}^{'} = 110, m\_{3}^{'} = 27 }

. Because

30
≡
3

(
mod

27
)

{\displaystyle 30 \equiv 3 \pmod{27} }

, the new remainder of the third congruence is 3. Hence, the new remainders are

r

1

′

=
32
,

r

2

′

=
70
,

r

3

′

=
3

{\displaystyle r\_{1}^{'} = 32, r\_{2}^{'} = 70, r\_{3}^{'} = 3 }

.

Subsequently, the new problem with coprime moduli to solve is:

{

N

≡
32

(
mod

83
)

N

≡
70

(
mod

110
)

N

≡
3

(
mod

27
)

{\displaystyle \begin{cases}
 N &\equiv 32 \pmod{83} \\
 N &\equiv 70 \pmod{110} \\
 N &\equiv 3 \pmod{27}
\end{cases}}

**Part 2: Determine the *yanmu* and the *yanshu* 求衍母和衍數**

First calculate the *yanmu* (衍母)

M

{\displaystyle M}

, which is the product of the coprime moduli.

# M
83
×
110
×
# 27
246510

{\displaystyle M = 83 \times 110 \times 27 = 246510 }

Divide the *yanmu* (衍母) by each moduli to obtain each *yanshu*(衍數)

M
i

{\displaystyle M\_i}

.

M
1

=

M

m

1

′

=

246510
83

=
2970

{\displaystyle M\_1 = \frac{M}{m\_{1}^{'}} = \frac{246510}{83} = 2970 }

M
2

=

M

m

2

′

=

246510
110

=
2241

{\displaystyle M\_2 = \frac{M}{m\_{2}^{'}} = \frac{246510}{110} = 2241 }

M
3

=

M

m

3

′

=

246510
27

=
9130

{\displaystyle M\_3 = \frac{M}{m\_{3}^{'}} = \frac{246510}{27} = 9130 }

**Part 3: Determine the *chenglü* 求乘率**

The next step is to determine the *qishu* (奇數)

K
i

{\displaystyle K\_i}

, which satisfies

M
i

≡

K
i

(
mod

m

i

′

)

{\displaystyle M\_i \equiv K\_i \pmod{m\_{i}^{'}} }

.

2970
≡
65

(
mod

83
)
⇒

K
1

=
65

{\displaystyle 2970 \equiv 65 \pmod{83} \Rightarrow K\_1 = 65 }

2241
≡
41

(
mod

110
)
⇒

K
2

=
41

{\displaystyle 2241 \equiv 41 \pmod{110} \Rightarrow K\_2 = 41 }

9130
≡
4

(
mod

27
)
⇒

K
3

=
4

{\displaystyle 9130 \equiv 4 \pmod{27} \Rightarrow K\_3 = 4 }

Next solve each congruence

K
i

x
i

≡
1

(
mod

m

i

′

)

{\displaystyle K\_i x\_i \equiv 1 \pmod{m\_{i}^{'}} }

, where

x
i

{\displaystyle x\_i }

 is called the *chenglü* (乘率). Qin Jiushao solves each congruence with what he calls the *dayan qiuyi shu* (大衍求一術), which is the Euclidean algorithm.

{

65

x
1

≡
1

(
mod

83
)

41

x
2

≡
1

(
mod

110
)

4

x
3

≡
1

(
mod

28
)

{\displaystyle \begin{cases}
 65 x\_1 &\equiv 1 \pmod{83} \\
 41 x\_2 &\equiv 1 \pmod{110} \\
 4 x\_3 &\equiv 1 \pmod{28}
\end{cases}}

For this problem, we will demonstrate how the *dayan qiuyi shu* works for

65

x
1

≡
1

(
mod

83
)

{\displaystyle 65 x\_1 \equiv 1 \pmod{83} }

.

**Step 1:**  Set up the *tianyuan* (天元), *qishu* (奇數), and *dingshu* (定數).

         0

**Step 2:** Perform the calculations and sequencing of the *dayan qiuyi shu*.

1(1) + 0 = 1
 0

3(1) + 1 = 4
 1

1(4) + 1 = 5
 1

1(5) + 4 = 9
 5

1(9) + 5 = 14
 5

1(14) + 9 = 23
 14

This process is also used for computing the other two linear congruences. The solution for this system is

x
1

=
23
,

x
2

=
51
,

x
3

=
7

{\displaystyle x\_1 = 23,\, x\_2 = 51,\, x\_3 = 7 }

.

**Part 4: Determine the *yongshu* and the *zongshu* 求用數和總數**

The *yongshu* (用數) are the products

M
i

x
i

{\displaystyle M\_i x\_i }

M
1

x
1

=
2970
×
# 23
68310

{\displaystyle M\_1 x\_1 = 2970 \times 23 = 68310 }

M
2

x
2

=
2241
×
# 51
114271

{\displaystyle M\_2 x\_2 = 2241 \times 51 = 114271 }

M
3

x
3

=
9131
×
# 7
63910

{\displaystyle M\_3 x\_3 = 9131 \times 7 = 63910 }

The *zongshu* (總數) is the sum

∑

# i
1

n

M
i

x
i

r

i

′

{\displaystyle \sum\_{i=1}^{n} M\_i x\_i r\_{i}^{'} }

68310
×
32
114291
×
70
63910
×
# 3
10378020

{\displaystyle 68310 \times 32 + 114291 \times 70 + 63910 \times 3 = 10378020 }

**Part 5: Determine the minimum non-negative solution**

10378020
≡
24600

(
mod

246510
)

{\displaystyle 10378020 \equiv 24600 \pmod{246510} }

So the total amount of rice each farmer sold 24600 *sheng* or 246 *dan*, and the total amount sold is 738 *dan*.