3

we have five coins:

  • Coin 1: \$1.
  • Coin 2: \$2.
  • Coin 3: \$5.
  • Coin 4: \$10.
  • Coin 5: \$20.

    In how many way can we get \$20 using those coins and combinations of them?

The only way I could do that was by counting all possibilities and it took forever.I started counting with this in mind : "in how many ways can only one of coins add up to \$20" . then went for combination of 2 coins ,after that of 3 coins . I got total of 40 combinations but it was very time consuming and illogical because if you have like \$50 to add up to you will never count that by hand .

Is there any other easier way maybe ,formula ?

  • I don't have an answer to this, but indeed this exact problem has been haunting me for a good 15 years ... I think generating functions will provide an answer! – Matti P. Apr 02 '20 at 11:53
  • I don't think there is an easy formula, but I would personally prefer to split into cases not depending on how many coins you use, but depending on how many $$20$ coins you use. And in each of those cases split again depending on how many $$10$ coins you use, and so on. To me, it seems a little easier not to miss possibilities that way. – Arthur Apr 02 '20 at 11:54
  • I thought of rewriting it in algebraic form like this $x$+$2y$+$5z$+$10a$+$20b$=20 (where $x,y,z,a,b$ are non-negative integers). but is it helpful? for me it gave nothing... I mean it's same, only way I could do that was again by counting possibilities. – alexnat009 Apr 02 '20 at 11:57
  • Similar questions discussed in many places, e.g., https://www.maa.org/frank-morgans-math-chat-293-ways-to-make-change-for-a-dollar and https://math.stackexchange.com/questions/203864/how-many-ways-you-can-make-change-for-an-amount and https://math.stackexchange.com/questions/15521/making-change-for-a-dollar-and-other-number-partitioning-problems and https://math.stackexchange.com/questions/2027067/how-many-ways-can-you-make-change-for-a-dollar and https://math.stackexchange.com/questions/607533/calculate-how-many-ways-to-get-change-of-78 and many, many more. – Gerry Myerson Apr 02 '20 at 12:03
  • Thanks i'll read them all. – alexnat009 Apr 02 '20 at 12:11
  • Coin analysis is standard in Groebner basis; although it is usually demonstrated for minimizing. I am reasonably sure it can be extended to count via. the basis result. Search google for something like "Bernd Sturmfels groebner video coins berkeley" There was a great elementary presentation on the MSRI website but I can't locate that particular one. There are other instructional videos there though. – rrogers Apr 02 '20 at 12:25
  • For instance:https://www.youtube.com/watch?v=TNO5WuxuNak 12 minutes in (or so). – rrogers Apr 02 '20 at 12:33
  • I'll watch that video . I really want to understand this problem – alexnat009 Apr 02 '20 at 13:07

1 Answers1

2

There are $41$ combinations in all. The following solution is essentially a twist on the usual approach using generating functions.

Start by noticing that if we want to make a total of 20 dollars, we can use any combination of the 2, 5, 10, and 20 dollar coins and make up the rest with 1 dollar coins. So we can solve the problem without 1 dollar coins for $r$ dollars for $0 \le r \le 20$ and add up the 21 solutions to get the total number of combinations. Let's say $a_r$ is the number of solutions (not using 1 dollar coins) for $r$ dollars. If you think about it a bit, I think you can see that $a_r$ is the coefficient of $x^r$ in a polynomial which we will denote by $f(x)$, defined by $$f(x) = P_2(x) P_5(x) P_{10}(x) P_{20}(x)$$ where $$\begin{align} P_2(x) &= 1 + x^2 + x^4 + x^6 + \dots + x^{20} \\ P_5(x) &= 1 + x^5 + x^{10} + x^{15} + x^{20} \\ P_{10}(x) &= 1 + x^{10} + x^{20} \\ P_{20}(x) &= 1 + x^{20} \\ \end{align}$$ To see this, think about the way multiplication of polynomials works. It may help to start by computing a smaller example, say $P_{10}(x) P_{20}(x)$, and see how the result relates to the problem of making change with only 10 and 20 dollar coins.

Expanding $f(x)$ is a straightforward computation. We start by computing $P_{20}(x)P_{10}(x)$, then compute $P_{20}(x)P_{10}(x)P_5(x)$, and then finish with $P_{20}(x)P_{10}(x)P_5(x)P_2(x)$. And since we are only interested in $a_r$ for $r \le 20$, we can discard any powers of $x$ higher than $x^{20}$. So here goes:

$$P_{20}(x) P_{10}(x) = 1+x^{10}+2 x^{20}+ O(x^{30})$$ $$P_{20}(x) P_{10}(x) P_5(x) = 1+x^5+2 x^{10}+2 x^{15}+4 x^{20} + O(x^{25})$$ $$P_{20}(x) P_{10}(x) P_5(x) P_2(x) = 1+x^2+x^4+x^5 + \\ x^6+x^7+x^8+x^9+3 x^{10} + \\ x^{11}+3 x^{12}+x^{13}+3 x^{14}+3 x^{15} + \\3 x^{16}+3 x^{17}+3 x^{18}+3 x^{19}+7 x^{20}+O(x^{21})$$

This last polynomial is $f(x)$, and if we sum its coefficients up to the coefficient of $x^{20}$ we find the answer to the problem is $41$.

awkward
  • 15,626
  • Thank you , it's very good answer ,too bad that my math level isn't that high and i can't understand everything out of it .Anyways thank you i accepted your answer – alexnat009 Apr 03 '20 at 08:19
  • The one thing I can't understand is why you discard possibilities with $1. You said "So we can solve the problem without 1 dollar coins for r dollars for 0≤r≤20 and add up the 21 solutions to get the total number of combinations." but where did you add those 21 ? – alexnat009 Apr 03 '20 at 10:03
  • @alexnat009 The sum is $1+1+1+1+1+1+1+1+3+1+3+1+3+3+3+3+3+3+7 = 41$ unless I have made a mistake copying those numbers. – awkward Apr 03 '20 at 13:15
  • I understood how you got 41 there , only thing I can't is where did possibilities involving 1 go ? I mean you said "So we can solve the problem without 1 dollar coins and then add all possibilities with 1 " where are those possibilities. to explain what i mean look at this $f(x)=P_{2}(x)P_{5}(x)P_{10}(x)P_{20}(x)$ this is all possibilities with combination of $2$,$5$,$10$ and $20$ but where are possibilities with $1$ – alexnat009 Apr 03 '20 at 14:16
  • @alexnat009 If you have a combination using only 2,5,10, and 20 that adds up to less than 20, you can add in 1 dollar coins (in only one way) to make the total 20. – awkward Apr 03 '20 at 17:55
  • yooo it makes much sense now . thank you very much because of your answer i want to study discrete math . very good answering btw. – alexnat009 Apr 04 '20 at 10:07