Jiuzhang Suanshu Fangcheng 8

## **Problem**

答曰：牛價一千二百，羊價五百，豕價三百。

術曰：如方程，置牛二、羊五正，豕一十三負，餘錢數正；次牛三正，羊九負，豕三正；次牛五負，羊六正，豕八正，不足錢負。以正負術入之。

Answer: The price of one cow is 1200 *qian*; the price of one sheep is 500 *qian*; the price of one pig is 300 *qian*.

Method: Use the *fangcheng* method. Set 2 for cows and 5 for sheep; both are positive, negative 13 for pigs, and the excess *qian* is positive. Next set positive 3 for cows, negative 9 for sheep, and positive 3 for pigs. Next set negative 5 for cows, positive 6 for sheep, positive 8 for pigs, and the deficit *qian* is negative. Solve this using the *zheng fu* method.

## **Solution**

Let

x
,
y
,
z

{\displaystyle x, y, z}

 represent the cost one one cow, one sheep, and one pig respectively. This problem is characterized by the system of three equations in three unknowns:

{

2
x
5
# y
13
z
1000

3
x
3
# z
9
y

6
y
8
# z
5
x
−
600

{\displaystyle \begin{cases}
2x + 5y = 13z + 1000 \\
3x + 3z = 9y \\
6y + 8z = 5x - 600
\end{cases} }

Set up the initial matrix and solve using modern matrix methods.

[

2

5

−
13

1000

3

−
9

3

0

−
5

6

8

−
600

]

{\displaystyle
\begin{bmatrix}
2 & 5 & -13 & 1000 \\
3 & -9 & 3 & 0 \\
-5 & 6 & 8 & -600
\end{bmatrix} }

(1) Divide row 2 by three:

1
3

R
2

{\displaystyle \frac{1}{3} R\_2 }

[

2

5

−
13

1000

1

−
3

1

0

−
5

6

8

−
600

]

{\displaystyle
\begin{bmatrix}
2 & 5 & -13 & 1000 \\
1 & -3 & 1 & 0 \\
-5 & 6 & 8 & -600
\end{bmatrix} }

(2) Subtract row 1 by two times row 2:

R
1

−
2

R
2

{\displaystyle R\_1 - 2R\_2 }

[

0

11

−
15

1000

1

−
3

1

0

−
5

6

8

−
600

]

{\displaystyle
\begin{bmatrix}
0 & 11 & -15 & 1000 \\
1 & -3 & 1 & 0 \\
-5 & 6 & 8 & -600
\end{bmatrix} }

(3) Add row 3 by five times row 2:

R
3

5

R
2

{\displaystyle R\_3 + 5R\_2 }

[

0

11

−
15

1000

1

−
3

1

0

0

−
9

13

−
600

]

{\displaystyle
\begin{bmatrix}
0 & 11 & -15 & 1000 \\
1 & -3 & 1 & 0 \\
0 & -9 & 13 & -600
\end{bmatrix} }

(4) Add row 1 by row 3:

R
1

R
3

{\displaystyle R\_1 + R\_3 }

[

0

2

−
2

400

1

−
3

1

0

0

−
9

13

−
600

]

{\displaystyle
\begin{bmatrix}
0 & 2 & -2 & 400 \\
1 & -3 & 1 & 0 \\
0 & -9 & 13 & -600
\end{bmatrix} }

(5) Divide row 1 by two:

1
2

R
1

{\displaystyle \frac{1}{2}R\_1 }

[

0

1

−
1

200

1

−
3

1

0

0

−
9

13

−
600

]

{\displaystyle
\begin{bmatrix}
0 & 1 & -1 & 200 \\
1 & -3 & 1 & 0 \\
0 & -9 & 13 & -600
\end{bmatrix} }

(6) Add nine times row 1 to row 3:

R
3

9

R
1

{\displaystyle R\_3 + 9R\_1 }

[

0

1

−
1

200

1

−
3

1

0

0

0

4

1200

]

{\displaystyle
\begin{bmatrix}
0 & 1 & -1 & 200 \\
1 & -3 & 1 & 0 \\
0 & 0 & 4 & 1200
\end{bmatrix} }

(7) Divide row 3 by four:

1
4

R
3

{\displaystyle \frac{1}{4}R\_3}

[

0

1

−
1

200

1

−
3

1

0

0

0

1

300

]

{\displaystyle
\begin{bmatrix}
0 & 1 & -1 & 200 \\
1 & -3 & 1 & 0 \\
0 & 0 & 1 & 300
\end{bmatrix} }

(8) Add row 3 to row 1:

R
1

R
3

{\displaystyle R\_1 + R\_3 }

[

0

1

0

500

1

−
3

1

0

0

0

1

300

]

{\displaystyle
\begin{bmatrix}
0 & 1 & 0 & 500 \\
1 & -3 & 1 & 0 \\
0 & 0 & 1 & 300
\end{bmatrix} }

(9) Subtract row 2 by row 3:

R
2

−

R
3

{\displaystyle R\_2 - R\_3 }

[

0

1

0

500

1

−
3

0

−
300

0

0

1

300

]

{\displaystyle
\begin{bmatrix}
0 & 1 & 0 & 500 \\
1 & -3 & 0 & -300 \\
0 & 0 & 1 & 300
\end{bmatrix} }

(10) Add three times row 1 to row 2:

R
2

3

R
1

{\displaystyle R\_2 + 3R\_1 }

[

0

1

0

500

1

0

0

1200

0

0

1

300

]

{\displaystyle
\begin{bmatrix}
0 & 1 & 0 & 500 \\
1 & 0 & 0 & 1200 \\
0 & 0 & 1 & 300
\end{bmatrix} }

(11) Swap row 1 with row 2:

R
1

↔

R
2

{\displaystyle R\_1 \leftrightarrow R\_2 }

[

1

0

0

1200

0

1

0

500

0

0

1

300

]

{\displaystyle
\begin{bmatrix}
1 & 0 & 0 & 1200 \\
0 & 1 & 0 & 500 \\
0 & 0 & 1 & 300
\end{bmatrix} }