[Linear Algebra] Farm Animals Buy and Sell
By: Tao Steven Zheng (鄭濤)
【Problem】
Jiuzhang Suanshu (Fangcheng 8)
Suppose 2 cows and 5 sheep are sold to buy 13 pigs, there is an excess of 1000 coins; when 3 cows and 3 pigs are sold, there is just enough coins to buy 9 sheep; when 6 sheep and 8 pigs are sold to buy 5 cows, there is a deficiency of 600 coins. Question: What is the price of one cow, one sheep, and one pig?


【Solution】
Let? represent cows, sheep and pigs respectively. In modern mathematical notation, this problem is a system of linear equations in three unknowns.
Construct the matrix?
Step 1: Divide row 2 by three
Step 2: Subtract row 1 by two times row 2
Step 3: Add row 3 by five times row 2
Step 4: Add row 1 by row 3
Step 5: Divide row 1 by two
Step 6: Add nine times row 1 to row 3
Step 7: Divide row 3 by four
Step 8: Add row 3 to row 1
Step 9: Subtract row 2 by row 3
Step 10: Add three times row 1 to row 2
Step 11: Swap row 1 with row 2
A cow costs 1200 coins, a sheep costs 500 coins, a pig costs 300 coins.