TCM Algebra 7: Indeterminate Problems

**By: Tao Steven Zheng (鄭濤)**

## **Indeterminate Linear Systems**

In mathematics, an indeterminate problem is a problem for which there is more than one solution. The earliest example of an indeterminate system of linear equations appears in Chapter 8 of the *Jiuzhang Suanshu*. This *fang cheng* problem would be classified as an indeterminate problem because it is a system of 5 equations in 6 unknowns. The answer, however, only lists one solution set. This solution being the one with smallest integers, so perhaps, we can call this problem a "would be" indeterminate problem.

### **Problem Study 1: Well Shared Among Five Families**

答曰：井深七丈二尺一寸。甲綆長二丈六尺五寸，乙綆長一丈九尺一寸，丙綆長一丈四尺八寸，丁綆長一丈二尺九寸，戊綆長七尺六寸。

術曰：如方程，以正負術入之。

Answer: The depth of the well is 7 *zhang* 2 *chi* 1 *cun*. A’s rope is 2 *zhang* 6 *chi* 5 *cun* long; B’s rope is 1 *zhang* 9 *chi* 1 *cun* long; C’s rope is 1 *zhang* 4 *chi* 8 *cun* long; D’s rope is 1 *zhang* 2 *chi* 9 *cun* long; E’s rope is 7 *chi* 6 *cun* long.

Method: Use the *fang cheng* method and solve by the *zheng fu* method (正負術 *zheng fu shu*).

**Solution to *Jiuzhang Suanshu* [8.13]**

This problem is a system of linear equations of 5 equations in 6 unknowns:

{

2
a
# b
x

3
b
# c
x

4
c
# d
x

5
d
# e
x

6
e
# a
x

{\displaystyle \begin{cases}
2a + b = x \\
3b + c = x \\
4c + d = x \\
5d + e = x \\
6e + a = x \\
\end{cases} }

Set up the initial matrix. The traditional Chinese set up

[

1

2

3

1

4

1

5

1

6

1

1

1

1

1

1

]

{\displaystyle
\begin{bmatrix}
1 & & & & 2 \\
 & & & 3 & 1 \\
 & & 4 & 1 & \\
 & 5 & 1 & & \\
6 & 1 & & & \\
1 & 1 & 1 & 1 & 1 \\
\end{bmatrix} }

[

2

1

0

0

0

1

0

3

1

0

0

1

0

0

4

1

0

1

0

0

0

5

1

1

1

0

0

0

6

1

]

{\displaystyle
\begin{bmatrix}
2 & 1 & 0 & 0 & 0 & 1 \\
0 & 3 & 1 & 0 & 0 & 1 \\
0 & 0 & 4 & 1 & 0 & 1 \\
0 & 0 & 0 & 5 & 1 & 1 \\
1 & 0 & 0 & 0 & 6 & 1 \\
\end{bmatrix} }

The step-by-step solution for this problem is lengthy. The result is

[

721

721

721

721

721

76

129

148

191

256

]

{\displaystyle
\begin{bmatrix}
 & & & & 721 \\
 & & & 721 & \\
 & & 721 & & \\
 & 721 & & & \\
721 & & & & \\
76 & 129 & 148 & 191 & 256 \\
\end{bmatrix} }

[

1

0

0

0

0

256
721

0

1

0

0

0

191
721

0

0

1

0

0

148
721

0

0

0

1

0

129
721

0

0

0

0

1

76
721

]

{\displaystyle
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 & \frac{256}{721} \\
0 & 1 & 0 & 0 & 0 & \frac{191}{721} \\
0 & 0 & 1 & 0 & 0 & \frac{148}{721} \\
0 & 0 & 0 & 1 & 0 & \frac{129}{721} \\
0 & 0 & 0 & 0 & 1 & \frac{76}{721} \\
\end{bmatrix} }

Although there ae infinitely many solutions, the *Jiuzhang Suanshu* gives the solution with smallest integers.

### **Problem Study 2: Hundred Fowls Problem**

In the *Zhang Qiujian Suanjing* (張邱建算經, *Zhang Qiujian's Mathematical Canon*), a text from 5th century AD, there is a famous indeterminate problem called the "hundred fowls problem" (百雞問題 *bai ji wen ti*), which is named after the oldest problem of this type that is found in the *Zhang Qiujian Suanjing* (張邱建算經, *Zhang Qiujian's Computational Canon*).

答曰：雞翁四，直錢二十；雞母十八，直錢五十四；雞雛七十八，直錢二十六。
又答：雞翁八，直錢四十；雞母十一，直錢三十三；雞雛八十一，直錢二十七。
又答：雞翁十二，直錢六十；雞母四，直錢十二；雞雛八十四，直錢二十八。
術曰：雞翁每增四，雞母每減七，雞雛每益三，即得。
Answer: 4 roosters, cost 20 *qian*; 18 hens, cost 53 *qian*; 78 chickens, worth 26 *qian*.
Another answer: 8 roosters, cost 40 *qian*; 11 hens, cost 33 *qian*; 81 chickens, cost 27 *qian*.
Another answer: 12 roosters, cost 60 *qian*; 4 hens, cost 12 *qian*; 84 chickens, cost 28 *qian*.
Method: Increase 4 to the number of roosters every time, subtract 7 to the number of hens, and add 3 to the number of chicks every time to obtain the answer.

**Solution to *Zhang Qiujian Suanjing* [3.38]**

The *Zhang Qiujian Suanjing* does not provide a systematic solution method to the problem. Instead, the solution method merely lists three rates for calculating the number of roosters, hens, and chickens, presumably after one obtains the solution with the least number of roosters. By the nature of the problem, only positive integers are admitted for the number of roosters, hens, and chickens.

Let

x
,
y
,
z

{\displaystyle x, y, z}

represent the number of roosters, hens, and chickens respectively. The problem is a system of two linear equations in three unknowns:

{

x
y
# z
100

5
x
3
y

1
3

# z
100

{\displaystyle
\begin{cases}
x + y + z = 100 \\
5x + 3y + \frac{1}{3}z = 100
\end{cases}
}

Multiply the second equation by 3 gives

{

x
y
# z
100

15
x
9
y
# z

{\displaystyle
\begin{cases}
x + y + z = 100 \\
15x + 9y + z = 300.
\end{cases}
}

Subtract the first equation from the second equation to obtain

14
x
8
# y
200

{\displaystyle 14x + 8y = 200 }

, or

# y
25
−

7
4

x
.

{\displaystyle y = 25 - \frac{7}{4}x. }

Substituting

y

{\displaystyle y}

 back into the first equation gives

# z
75

3
4

x
.

{\displaystyle z = 75 + \frac{3}{4}x. }

Thus, the solution set is

(
x
,
y
,
z
# )

(

4
z

3

−
100
,
200
−

7
z

3

,
z

)

.

{\displaystyle (x, y, z) = \left(\frac{4z}{3} - 100, 200 - \frac{7z}{3}, z \right). }

By the nature of this problem, the solution for

x
,
y
,
z

{\displaystyle x, y, z}

 must be non-negative integers; hence,

x

{\displaystyle x}

 must be divisible by 4. Substitute

# x
4
t

{\displaystyle x = 4t }

 into the above solution set to obtain

(
x
,
y
,
z
# )

(

4
t
,
25
−
7
t
,
75
3
t

)

{\displaystyle (x, y, z) = \left(4t, 25 - 7t, 75 + 3t \right) }

where

# t
0
,
1
,
2
,
3

{\displaystyle t = 0, 1, 2,3 }

.

The possible solutions are:

(
x
,
y
,
z
# )

(

0
,
25
,
75

)

{\displaystyle (x,y,z) = \left(0,25,75 \right) }

(
x
,
y
,
z
# )

(

4
,
18
,
78

)

{\displaystyle (x,y,z) = \left(4,18,78 \right) }

(
x
,
y
,
z
# )

(

8
,
11
,
81

)

{\displaystyle (x,y,z) = \left(8,11,81 \right) }

(
x
,
y
,
z
# )

(

12
,
4
,
84

)

{\displaystyle (x,y,z) = \left(12,4,84 \right) }

Zhang Qiujian only gave positive integer solutions, so the first solution (0 roosters, 25 hens, and 75 chickens) is excluded.

 **Cost** | 20

 **Cost** | 40

 **Cost** | 60

This problem are found in late Indian, Arabic and European mathematics can trace its origin to the hundred fowls problem prototype in the *Zhang Qiujian Suanjing*.

## **Chinese Remainder Problem**

### **Problem Study 3: Objects of Unknown Number**

答曰：二十三。

術曰：「三、三數之，賸二」，置一百四十；「五、五數之，賸三」，置六十三；「七、七數之，賸二」，置三十。并之，得二百三十三。以二百一十減之，即得。凡三、三數之，賸一，則置七十；五，五數之，賸一，則置二十一；七、七數之，賸一，則置十五。一百六以上，以一百五減之，即得。

Answer: 23.

Method: “When counted in threes, 2 remain” set 140. “When counted in fives, 3 remain” set 63. “When counted in sevens, 2 remain” set 30. Add these numbers to get 233. Then subtract 210 to obtain the answer. When counted in threes, set 70 to get a remainder of 1. When counted in fives, set 21 to get a remainder of 1. When counted in sevens, set 15 to get a remainder of 1. While the result is greater than 106, subtract 105 to obtain the answer.

**Solution for *Sunzi Suanjing* [3.26]**

This problem is a system of indeterminate equations with infinitely many solutions.

N

≡
2

(
mod

3
)

N

≡
3

(
mod

5
)

N

≡
2

(
mod

7
)

{\displaystyle \begin{align}
 N &\equiv 2 \pmod{3} \\
 N &\equiv 3 \pmod{5} \\
 N &\equiv 2 \pmod{7}
\end{align}}

Calculate the product of the moduli

# M
3
(
5
)
(
7
# )
105

{\displaystyle M = 3(5)(7) = 105 }

 .

The solution of the Chinese remainder theorem prescribes that

# N

[

r
1

M
1

s
1

r
2

M
2

s
2

r
3

M
3

s
3

]

(
mod

M
)

{\displaystyle
N = \left[r\_1 M\_1 s\_1 + r\_2 M\_2 s\_2 + r\_3 M\_3 s\_3 \right] \pmod M
}

.
For this problem

M
1

=

105
3

=
35
,

M
2

=

105
5

=
21
,

M
3

=

105
7

=
15

{\displaystyle
M\_1 = \frac{105}{3} = 35, \quad M\_2 = \frac{105}{5} = 21, \quad M\_3 = \frac{105}{7} = 15
}

# N

[

2
(
35
)

s
1

3
(
21
)

s
2

2
(
15
)

s
3

]

(
mod

105
)

{\displaystyle
N = \left[2(35)s\_1 + 3(21)s\_2 + 2(15)s\_3 \right] \pmod{105}
}

where

35

s
1

≡
1

(
mod

3
)

21

s
2

≡
1

(
mod

5
)

15

s
3

≡
1

(
mod

7
)

{\displaystyle \begin{align}
 35s\_1 &\equiv 1 \pmod{3} \\
 21s\_2 &\equiv 1 \pmod{5} \\
 15s\_3 &\equiv 1 \pmod{7}
\end{align}}

s
1

,

s
2

,

s
3

{\displaystyle s\_1, s\_2, s\_3 }

 are the modular inverses of each respective remainder, which can be solved systematically using the Euclidean algorithm. However, the numbers involved in this problem is small enough to be obtained by guessing and checking.

35
(
2
)

≡
1

(
mod

3
)

21
(
1
)

≡
1

(
mod

5
)

15
(
1
)

≡
1

(
mod

7
)

{\displaystyle \begin{align}
 35(2) &\equiv 1 \pmod{3} \\
 21(1) &\equiv 1 \pmod{5} \\
 15(1) &\equiv 1 \pmod{7}
\end{align}
}

**Calculation**

# N

[

2
(
35
)
(
2
)
3
(
21
)
(
1
)
2
(
15
)
(
1
)

]

(
mod

105
)

{\displaystyle
N = \left[2(35)(2) + 3(21)(1) + 2(15)(1) \right] \pmod{105}
}

# N
233

(
mod

105
)

{\displaystyle
N = 233 \pmod{105}
}

Hence 233 is a solution. In fact, there are infinitely many solutions

# N
105
x
233

{\displaystyle N = 105x + 233 }

where

x

{\displaystyle x}

 is an integer. The answer assumes the lowest positive integer solution. The lowest positive integer solution is

233
−
2
(
105
# )

{\displaystyle 233 - 2(105) = 23. }

So there are 23 objects.

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**

Answer: 23.

Method: “When counted in threes, 2 remain” set 140. “When counted in fives, 3 remain” set 63. “When counted in sevens, 2 remain” set 30. Add these numbers to get 233. Then subtract 210 to obtain the answer. When counted in threes, set 70 to get a remainder of 1. When counted in fives, set 21 to get a remainder of 1. When counted in sevens, set 15 to get a remainder of 1. While the result is greater than 106, subtract 105 to obtain the answer.

**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

135
)

{\displaystyle \begin{cases}
 65 x\_1 &\equiv 1 \pmod{83} \\
 41 x\_2 &\equiv 1 \pmod{110} \\
 4 x\_3 &\equiv 1 \pmod{135}
\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

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 }

**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*.