I want to find the number of ways to make change for $22.22 using pennies, nickels, dimes, quarters, half dollars, and dollars. I have a textbook with generating functions for this, but I don't exactly see what to do.
Asked
Active
Viewed 841 times
0
-
Start with reading your textbook? – amWhy Mar 12 '17 at 20:25
-
I have read my textbook, and I find the section to be poorly written and difficult to follow. – Hugh Mungus Mar 12 '17 at 20:28
1 Answers
1
Let
- $x_1$ be the number of pennies (1 cent)
- $x_2$ be the number of nickels (5 cents)
- $x_3$ be the number of dimes (10 cents)
- $x_4$ be the number of quarters (25 cents)
- $x_5$ be the number of half dollars
- $x_6$ be the number of dollars
We would like to determine the number of non-negative integer solutions of
$$x_1 + 5 x_2 + 10 x_3 + 25 x_4 + 50 x_5 + 100 x_6 = 2222$$
which is the coefficient of $t^{2222}$ in the following generating function
$$\frac{1}{(1-t) (1-t^5) (1-t^{10}) (1-t^{25}) (1-t^{50}) (1-t^{100})}$$
Using SymPy:
>>> from sympy import *
>>> t = Symbol('t')
>>> f = 1 / ((1-t) * (1-t**5) * (1-t**10) * (1-t**25) * (1-t**50) * (1-t**100))
>>> f.series(t,0,2223)
1 + t + t**2 + t**3 + t**4 + 2*t**5 + 2*t**6 + 2*t**7 + 2*t**8 + 2*t**9 + 4*t**10 + 4*t**11 + 4*t**12 + 4*t**13 + 4*t**14 + 6*t**15 + [removed 2199 terms] + 87993032*t**2215 + 87993032*t**2216 + 87993032*t**2217 + 87993032*t**2218 + 87993032*t**2219 + 88949188*t**2220 + 88949188*t**2221 + 88949188*t**2222 + O(t**2223)
Hence, there are $88949188$ non-negative integer solutions.
Rodrigo de Azevedo
- 23,223