[Math] Solving a “How many coins of each type do I have?” word problem with linear algebra and MatLab command line

linear algebraMATLABword problem

The coins currently in Canada are nickels (worth \$0.05), dimes (worth \$0.10), quarters (worth \$0.25), loonies (worth \$1.00), and toonies (worth $2.00).

The coins I have in my pocket have a total value of \$5.75. I have twice as many dimes as nickels. I have the same number of nickels as I have toonies. The nickels and dimes together are worth \$0.50. There are a total of 10 coins in my pocket. How many coins of each type do I have?

How can I use matrices and MatLab to solve this question? Currently, what I have tried is getting 5 matrices and using those as my system of equations.
[screenshot of written work]

However, when I put the matrix into RREF, I get that $a=-1.6$, $b=-3.67$, etc.

[screenshot of matlab]

I have also used logic to determine that the answer should be two nickels, four dimes, one quarter, one loonie, and two toonies.

What I want to know is the steps I would take to convert the word problem into a numerical problem, and how I would use MatLab to solve the resulting system of equations (if there even is one). This purpose of this exercise is for me to learn MatLab, and the process should only be completed using the MatLab command line.

Best Answer

Let $n$, $d$, $q$, $l$ and $t$ represent the number of nickels, dimes, quarters, loonies and toonies, respectively.

From nickels and dimes being $\$0.50$ we get

$$.05n+.1d=0.5$$

Twice as many dimes as nickels gives us $$2d-n=0$$

Number of nickels equals number of toonies gives us $$n-t=0$$

Ten total coins gives us $$n+d+q+l+t=10$$

Finally, a total of $\$5.75$ gives us $$.05n+0.1d + 0.25q + l + 2t=5.75$$

These five equations and five unknowns gives you a matrix equation which you can plug into Matlab and solve.

Related Question