generating function problem












0












$begingroup$


I need to solve this problem using generating functions:
What is the generating function to the number of ways of expressing n dollars as a 1,2 and 5 dollar coins.



I wasn't able to solve the $ (1+x^2+x^4)^n $ part.










share|cite|improve this question











$endgroup$












  • $begingroup$
    Is this the full and exact problem statement? It's not very clear to me
    $endgroup$
    – Yuriy S
    Dec 29 '18 at 15:45










  • $begingroup$
    Yes, this is the question
    $endgroup$
    – Igor
    Dec 29 '18 at 15:46








  • 1




    $begingroup$
    Maybe you mean number of ways of expressing $n$ dollars as a collection of $1$, $2$ and $5$ dollar coins?
    $endgroup$
    – Jakobian
    Dec 29 '18 at 15:58












  • $begingroup$
    Yes, It looked clear enough for me. I will edit it,
    $endgroup$
    – Igor
    Dec 29 '18 at 16:02
















0












$begingroup$


I need to solve this problem using generating functions:
What is the generating function to the number of ways of expressing n dollars as a 1,2 and 5 dollar coins.



I wasn't able to solve the $ (1+x^2+x^4)^n $ part.










share|cite|improve this question











$endgroup$












  • $begingroup$
    Is this the full and exact problem statement? It's not very clear to me
    $endgroup$
    – Yuriy S
    Dec 29 '18 at 15:45










  • $begingroup$
    Yes, this is the question
    $endgroup$
    – Igor
    Dec 29 '18 at 15:46








  • 1




    $begingroup$
    Maybe you mean number of ways of expressing $n$ dollars as a collection of $1$, $2$ and $5$ dollar coins?
    $endgroup$
    – Jakobian
    Dec 29 '18 at 15:58












  • $begingroup$
    Yes, It looked clear enough for me. I will edit it,
    $endgroup$
    – Igor
    Dec 29 '18 at 16:02














0












0








0


0



$begingroup$


I need to solve this problem using generating functions:
What is the generating function to the number of ways of expressing n dollars as a 1,2 and 5 dollar coins.



I wasn't able to solve the $ (1+x^2+x^4)^n $ part.










share|cite|improve this question











$endgroup$




I need to solve this problem using generating functions:
What is the generating function to the number of ways of expressing n dollars as a 1,2 and 5 dollar coins.



I wasn't able to solve the $ (1+x^2+x^4)^n $ part.







combinatorics generating-functions






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 29 '18 at 16:03







Igor

















asked Dec 29 '18 at 15:35









IgorIgor

315




315












  • $begingroup$
    Is this the full and exact problem statement? It's not very clear to me
    $endgroup$
    – Yuriy S
    Dec 29 '18 at 15:45










  • $begingroup$
    Yes, this is the question
    $endgroup$
    – Igor
    Dec 29 '18 at 15:46








  • 1




    $begingroup$
    Maybe you mean number of ways of expressing $n$ dollars as a collection of $1$, $2$ and $5$ dollar coins?
    $endgroup$
    – Jakobian
    Dec 29 '18 at 15:58












  • $begingroup$
    Yes, It looked clear enough for me. I will edit it,
    $endgroup$
    – Igor
    Dec 29 '18 at 16:02


















  • $begingroup$
    Is this the full and exact problem statement? It's not very clear to me
    $endgroup$
    – Yuriy S
    Dec 29 '18 at 15:45










  • $begingroup$
    Yes, this is the question
    $endgroup$
    – Igor
    Dec 29 '18 at 15:46








  • 1




    $begingroup$
    Maybe you mean number of ways of expressing $n$ dollars as a collection of $1$, $2$ and $5$ dollar coins?
    $endgroup$
    – Jakobian
    Dec 29 '18 at 15:58












  • $begingroup$
    Yes, It looked clear enough for me. I will edit it,
    $endgroup$
    – Igor
    Dec 29 '18 at 16:02
















$begingroup$
Is this the full and exact problem statement? It's not very clear to me
$endgroup$
– Yuriy S
Dec 29 '18 at 15:45




$begingroup$
Is this the full and exact problem statement? It's not very clear to me
$endgroup$
– Yuriy S
Dec 29 '18 at 15:45












$begingroup$
Yes, this is the question
$endgroup$
– Igor
Dec 29 '18 at 15:46






$begingroup$
Yes, this is the question
$endgroup$
– Igor
Dec 29 '18 at 15:46






1




1




$begingroup$
Maybe you mean number of ways of expressing $n$ dollars as a collection of $1$, $2$ and $5$ dollar coins?
$endgroup$
– Jakobian
Dec 29 '18 at 15:58






$begingroup$
Maybe you mean number of ways of expressing $n$ dollars as a collection of $1$, $2$ and $5$ dollar coins?
$endgroup$
– Jakobian
Dec 29 '18 at 15:58














$begingroup$
Yes, It looked clear enough for me. I will edit it,
$endgroup$
– Igor
Dec 29 '18 at 16:02




$begingroup$
Yes, It looked clear enough for me. I will edit it,
$endgroup$
– Igor
Dec 29 '18 at 16:02










2 Answers
2






active

oldest

votes


















0












$begingroup$

The generating function for coins of value $k$ is
$dfrac1{1-x^k}$.



For different value coins, multiply their generating functions.






share|cite|improve this answer









$endgroup$





















    0












    $begingroup$

    We're looking for
    $$F(x) = sum_{n=0}^infty a_nx^n $$
    where $a_n$ is the number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins.
    $$a_n = sum_{k_1+k_2+k_3 = n} m_{k_1, 1}m_{k_2, 2}m_{k_3, 5} $$
    where $m_{k_1, 1}$ is the number of ways to express $k_1$ dollars in terms of $1$ dollar coins, $m_{k_2, 2}$ is the number of ways of expressing $k_2$ dollars in terms of $2$ dollar coins, and $m_{k_3, 5}$ is the number of ways of expressing $k_3$ dollars in terms of $5$ dollar coins. From this:
    $$F(x) = left(sum_{n=0}^infty m_{n, 1}x^nright)left(sum_{n=0}^infty m_{n, 2}x^nright)left(sum_{n=0}^infty m_{n, 5}x^nright) = left(sum_{n=0}^infty x^nright)left(sum_{n=0}^infty x^{2n}right)left(sum_{n=0}^infty x^{5n}right)=\ = frac{1}{1-x}cdot frac{1}{1-x^2}cdot frac{1}{1-x^5} $$
    If the order of the coins is important, then we can derive a recurrence:
    $$b_{n+5} = b_{n+4}+b_{n+3}+b_n, ngeq 0 \ b_0 = 0, b_1 = 1, b_2 = 2, b_3 = 3, b_4 = 5$$
    It's because there is $3$ possible cases, we have $1, 2$ or $5$ dollar coin at the end, and we take as much dollars from the whole if that's the case. Then we have
    $$G(x) = sumlimits_{n=0}^infty b_nx^n = x+2x^2+3x^3+5x^4+sumlimits_{n=0}^infty b_{n+5}x^{n+5} = \ = p(x)+sum_{n=0}^infty (b_{n+4}+b_{n+3}+b_n)x^{n+5} = p(x)+sum_{n=0}^infty b_nx^{n+5} + sum_{n=0}^infty b_{n+3}x^{n+5} + sum_{n=0}^infty b_{n+4}x^{n+5} $$
    where $p(x) = x+2x^2+3x^3+5x^4$. Then we can simplify the $3$ sums
    $$sum_{n=0}^infty b_nx^{n+5} = x^5sum_{n=0}^infty b_nx^n = x^5G(x) $$
    $$sum_{n=0}^infty b_{n+3}x^{n+5} = x^2sum_{n=0}^infty b_{n+3}x^{n+3} = x^2sum_{n=3}^infty b_nx^n = x^2(sum_{n=0}^infty b_nx^n - sum_{n=0}^2 b_nx^n)= \ = x^2(G(x)-2x^2-x) = x^2G(x) - 2x^4-x^3 $$
    $$sum_{n=0}^infty b_{n+4}x^{n+5} = xsum_{n=0}^infty b_{n+4}x^{n+4} = xsum_{n=4}^infty b_nx^n = x(sum_{n=0}^infty b_nx^n - sum_{n=0}^3 b_nx^n) = \ = x(G(x)-3x^3-2x^2-x) = xG(x)-3x^4-2x^3-x^2 $$
    So we can now calulate what $G(x)$ is
    $$G(x) = p(x)+(x^5+x^2+x)G(x)-5x^4-3x^3-x^2 = (x^5+x^2+x)G(x)+x+x^2 $$
    $$G(x) = frac{x+x^2}{1-(x+x^2+x^5)} $$






    share|cite|improve this answer











    $endgroup$













    • $begingroup$
      Follow up question - What if I the order of the coins is important. How will it change?
      $endgroup$
      – Igor
      Dec 30 '18 at 11:33








    • 1




      $begingroup$
      @Igor I've edited my answer
      $endgroup$
      – Jakobian
      Dec 30 '18 at 12:37












    • $begingroup$
      I didn't quiet understand the transition. Why is G(X) defined this way and what is x+2x^2+3x^3+5x^4? I lost you there..
      $endgroup$
      – Igor
      Dec 30 '18 at 15:14












    • $begingroup$
      @Igor If $b_n$ is number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins, so that the order of coins matters, then from definition, it's generating function is $sum_{n=0}^infty b_nx^n$. This is just the definition. $x+2x^2+3x^3+5x^4 = sum_{n=0}^4 b_nx^n$, we split the sum in two parts.
      $endgroup$
      – Jakobian
      Dec 30 '18 at 17:08












    • $begingroup$
      Why can't you say this is the answer? $$ frac{1}{(1-x^2-x^3-x^5)} $$ I am just summing all the possibilities for choosing coins.
      $endgroup$
      – Igor
      Jan 1 at 17:36











    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3055952%2fgenerating-function-problem%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$

    The generating function for coins of value $k$ is
    $dfrac1{1-x^k}$.



    For different value coins, multiply their generating functions.






    share|cite|improve this answer









    $endgroup$


















      0












      $begingroup$

      The generating function for coins of value $k$ is
      $dfrac1{1-x^k}$.



      For different value coins, multiply their generating functions.






      share|cite|improve this answer









      $endgroup$
















        0












        0








        0





        $begingroup$

        The generating function for coins of value $k$ is
        $dfrac1{1-x^k}$.



        For different value coins, multiply their generating functions.






        share|cite|improve this answer









        $endgroup$



        The generating function for coins of value $k$ is
        $dfrac1{1-x^k}$.



        For different value coins, multiply their generating functions.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Dec 29 '18 at 16:14









        marty cohenmarty cohen

        72.9k549128




        72.9k549128























            0












            $begingroup$

            We're looking for
            $$F(x) = sum_{n=0}^infty a_nx^n $$
            where $a_n$ is the number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins.
            $$a_n = sum_{k_1+k_2+k_3 = n} m_{k_1, 1}m_{k_2, 2}m_{k_3, 5} $$
            where $m_{k_1, 1}$ is the number of ways to express $k_1$ dollars in terms of $1$ dollar coins, $m_{k_2, 2}$ is the number of ways of expressing $k_2$ dollars in terms of $2$ dollar coins, and $m_{k_3, 5}$ is the number of ways of expressing $k_3$ dollars in terms of $5$ dollar coins. From this:
            $$F(x) = left(sum_{n=0}^infty m_{n, 1}x^nright)left(sum_{n=0}^infty m_{n, 2}x^nright)left(sum_{n=0}^infty m_{n, 5}x^nright) = left(sum_{n=0}^infty x^nright)left(sum_{n=0}^infty x^{2n}right)left(sum_{n=0}^infty x^{5n}right)=\ = frac{1}{1-x}cdot frac{1}{1-x^2}cdot frac{1}{1-x^5} $$
            If the order of the coins is important, then we can derive a recurrence:
            $$b_{n+5} = b_{n+4}+b_{n+3}+b_n, ngeq 0 \ b_0 = 0, b_1 = 1, b_2 = 2, b_3 = 3, b_4 = 5$$
            It's because there is $3$ possible cases, we have $1, 2$ or $5$ dollar coin at the end, and we take as much dollars from the whole if that's the case. Then we have
            $$G(x) = sumlimits_{n=0}^infty b_nx^n = x+2x^2+3x^3+5x^4+sumlimits_{n=0}^infty b_{n+5}x^{n+5} = \ = p(x)+sum_{n=0}^infty (b_{n+4}+b_{n+3}+b_n)x^{n+5} = p(x)+sum_{n=0}^infty b_nx^{n+5} + sum_{n=0}^infty b_{n+3}x^{n+5} + sum_{n=0}^infty b_{n+4}x^{n+5} $$
            where $p(x) = x+2x^2+3x^3+5x^4$. Then we can simplify the $3$ sums
            $$sum_{n=0}^infty b_nx^{n+5} = x^5sum_{n=0}^infty b_nx^n = x^5G(x) $$
            $$sum_{n=0}^infty b_{n+3}x^{n+5} = x^2sum_{n=0}^infty b_{n+3}x^{n+3} = x^2sum_{n=3}^infty b_nx^n = x^2(sum_{n=0}^infty b_nx^n - sum_{n=0}^2 b_nx^n)= \ = x^2(G(x)-2x^2-x) = x^2G(x) - 2x^4-x^3 $$
            $$sum_{n=0}^infty b_{n+4}x^{n+5} = xsum_{n=0}^infty b_{n+4}x^{n+4} = xsum_{n=4}^infty b_nx^n = x(sum_{n=0}^infty b_nx^n - sum_{n=0}^3 b_nx^n) = \ = x(G(x)-3x^3-2x^2-x) = xG(x)-3x^4-2x^3-x^2 $$
            So we can now calulate what $G(x)$ is
            $$G(x) = p(x)+(x^5+x^2+x)G(x)-5x^4-3x^3-x^2 = (x^5+x^2+x)G(x)+x+x^2 $$
            $$G(x) = frac{x+x^2}{1-(x+x^2+x^5)} $$






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Follow up question - What if I the order of the coins is important. How will it change?
              $endgroup$
              – Igor
              Dec 30 '18 at 11:33








            • 1




              $begingroup$
              @Igor I've edited my answer
              $endgroup$
              – Jakobian
              Dec 30 '18 at 12:37












            • $begingroup$
              I didn't quiet understand the transition. Why is G(X) defined this way and what is x+2x^2+3x^3+5x^4? I lost you there..
              $endgroup$
              – Igor
              Dec 30 '18 at 15:14












            • $begingroup$
              @Igor If $b_n$ is number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins, so that the order of coins matters, then from definition, it's generating function is $sum_{n=0}^infty b_nx^n$. This is just the definition. $x+2x^2+3x^3+5x^4 = sum_{n=0}^4 b_nx^n$, we split the sum in two parts.
              $endgroup$
              – Jakobian
              Dec 30 '18 at 17:08












            • $begingroup$
              Why can't you say this is the answer? $$ frac{1}{(1-x^2-x^3-x^5)} $$ I am just summing all the possibilities for choosing coins.
              $endgroup$
              – Igor
              Jan 1 at 17:36
















            0












            $begingroup$

            We're looking for
            $$F(x) = sum_{n=0}^infty a_nx^n $$
            where $a_n$ is the number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins.
            $$a_n = sum_{k_1+k_2+k_3 = n} m_{k_1, 1}m_{k_2, 2}m_{k_3, 5} $$
            where $m_{k_1, 1}$ is the number of ways to express $k_1$ dollars in terms of $1$ dollar coins, $m_{k_2, 2}$ is the number of ways of expressing $k_2$ dollars in terms of $2$ dollar coins, and $m_{k_3, 5}$ is the number of ways of expressing $k_3$ dollars in terms of $5$ dollar coins. From this:
            $$F(x) = left(sum_{n=0}^infty m_{n, 1}x^nright)left(sum_{n=0}^infty m_{n, 2}x^nright)left(sum_{n=0}^infty m_{n, 5}x^nright) = left(sum_{n=0}^infty x^nright)left(sum_{n=0}^infty x^{2n}right)left(sum_{n=0}^infty x^{5n}right)=\ = frac{1}{1-x}cdot frac{1}{1-x^2}cdot frac{1}{1-x^5} $$
            If the order of the coins is important, then we can derive a recurrence:
            $$b_{n+5} = b_{n+4}+b_{n+3}+b_n, ngeq 0 \ b_0 = 0, b_1 = 1, b_2 = 2, b_3 = 3, b_4 = 5$$
            It's because there is $3$ possible cases, we have $1, 2$ or $5$ dollar coin at the end, and we take as much dollars from the whole if that's the case. Then we have
            $$G(x) = sumlimits_{n=0}^infty b_nx^n = x+2x^2+3x^3+5x^4+sumlimits_{n=0}^infty b_{n+5}x^{n+5} = \ = p(x)+sum_{n=0}^infty (b_{n+4}+b_{n+3}+b_n)x^{n+5} = p(x)+sum_{n=0}^infty b_nx^{n+5} + sum_{n=0}^infty b_{n+3}x^{n+5} + sum_{n=0}^infty b_{n+4}x^{n+5} $$
            where $p(x) = x+2x^2+3x^3+5x^4$. Then we can simplify the $3$ sums
            $$sum_{n=0}^infty b_nx^{n+5} = x^5sum_{n=0}^infty b_nx^n = x^5G(x) $$
            $$sum_{n=0}^infty b_{n+3}x^{n+5} = x^2sum_{n=0}^infty b_{n+3}x^{n+3} = x^2sum_{n=3}^infty b_nx^n = x^2(sum_{n=0}^infty b_nx^n - sum_{n=0}^2 b_nx^n)= \ = x^2(G(x)-2x^2-x) = x^2G(x) - 2x^4-x^3 $$
            $$sum_{n=0}^infty b_{n+4}x^{n+5} = xsum_{n=0}^infty b_{n+4}x^{n+4} = xsum_{n=4}^infty b_nx^n = x(sum_{n=0}^infty b_nx^n - sum_{n=0}^3 b_nx^n) = \ = x(G(x)-3x^3-2x^2-x) = xG(x)-3x^4-2x^3-x^2 $$
            So we can now calulate what $G(x)$ is
            $$G(x) = p(x)+(x^5+x^2+x)G(x)-5x^4-3x^3-x^2 = (x^5+x^2+x)G(x)+x+x^2 $$
            $$G(x) = frac{x+x^2}{1-(x+x^2+x^5)} $$






            share|cite|improve this answer











            $endgroup$













            • $begingroup$
              Follow up question - What if I the order of the coins is important. How will it change?
              $endgroup$
              – Igor
              Dec 30 '18 at 11:33








            • 1




              $begingroup$
              @Igor I've edited my answer
              $endgroup$
              – Jakobian
              Dec 30 '18 at 12:37












            • $begingroup$
              I didn't quiet understand the transition. Why is G(X) defined this way and what is x+2x^2+3x^3+5x^4? I lost you there..
              $endgroup$
              – Igor
              Dec 30 '18 at 15:14












            • $begingroup$
              @Igor If $b_n$ is number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins, so that the order of coins matters, then from definition, it's generating function is $sum_{n=0}^infty b_nx^n$. This is just the definition. $x+2x^2+3x^3+5x^4 = sum_{n=0}^4 b_nx^n$, we split the sum in two parts.
              $endgroup$
              – Jakobian
              Dec 30 '18 at 17:08












            • $begingroup$
              Why can't you say this is the answer? $$ frac{1}{(1-x^2-x^3-x^5)} $$ I am just summing all the possibilities for choosing coins.
              $endgroup$
              – Igor
              Jan 1 at 17:36














            0












            0








            0





            $begingroup$

            We're looking for
            $$F(x) = sum_{n=0}^infty a_nx^n $$
            where $a_n$ is the number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins.
            $$a_n = sum_{k_1+k_2+k_3 = n} m_{k_1, 1}m_{k_2, 2}m_{k_3, 5} $$
            where $m_{k_1, 1}$ is the number of ways to express $k_1$ dollars in terms of $1$ dollar coins, $m_{k_2, 2}$ is the number of ways of expressing $k_2$ dollars in terms of $2$ dollar coins, and $m_{k_3, 5}$ is the number of ways of expressing $k_3$ dollars in terms of $5$ dollar coins. From this:
            $$F(x) = left(sum_{n=0}^infty m_{n, 1}x^nright)left(sum_{n=0}^infty m_{n, 2}x^nright)left(sum_{n=0}^infty m_{n, 5}x^nright) = left(sum_{n=0}^infty x^nright)left(sum_{n=0}^infty x^{2n}right)left(sum_{n=0}^infty x^{5n}right)=\ = frac{1}{1-x}cdot frac{1}{1-x^2}cdot frac{1}{1-x^5} $$
            If the order of the coins is important, then we can derive a recurrence:
            $$b_{n+5} = b_{n+4}+b_{n+3}+b_n, ngeq 0 \ b_0 = 0, b_1 = 1, b_2 = 2, b_3 = 3, b_4 = 5$$
            It's because there is $3$ possible cases, we have $1, 2$ or $5$ dollar coin at the end, and we take as much dollars from the whole if that's the case. Then we have
            $$G(x) = sumlimits_{n=0}^infty b_nx^n = x+2x^2+3x^3+5x^4+sumlimits_{n=0}^infty b_{n+5}x^{n+5} = \ = p(x)+sum_{n=0}^infty (b_{n+4}+b_{n+3}+b_n)x^{n+5} = p(x)+sum_{n=0}^infty b_nx^{n+5} + sum_{n=0}^infty b_{n+3}x^{n+5} + sum_{n=0}^infty b_{n+4}x^{n+5} $$
            where $p(x) = x+2x^2+3x^3+5x^4$. Then we can simplify the $3$ sums
            $$sum_{n=0}^infty b_nx^{n+5} = x^5sum_{n=0}^infty b_nx^n = x^5G(x) $$
            $$sum_{n=0}^infty b_{n+3}x^{n+5} = x^2sum_{n=0}^infty b_{n+3}x^{n+3} = x^2sum_{n=3}^infty b_nx^n = x^2(sum_{n=0}^infty b_nx^n - sum_{n=0}^2 b_nx^n)= \ = x^2(G(x)-2x^2-x) = x^2G(x) - 2x^4-x^3 $$
            $$sum_{n=0}^infty b_{n+4}x^{n+5} = xsum_{n=0}^infty b_{n+4}x^{n+4} = xsum_{n=4}^infty b_nx^n = x(sum_{n=0}^infty b_nx^n - sum_{n=0}^3 b_nx^n) = \ = x(G(x)-3x^3-2x^2-x) = xG(x)-3x^4-2x^3-x^2 $$
            So we can now calulate what $G(x)$ is
            $$G(x) = p(x)+(x^5+x^2+x)G(x)-5x^4-3x^3-x^2 = (x^5+x^2+x)G(x)+x+x^2 $$
            $$G(x) = frac{x+x^2}{1-(x+x^2+x^5)} $$






            share|cite|improve this answer











            $endgroup$



            We're looking for
            $$F(x) = sum_{n=0}^infty a_nx^n $$
            where $a_n$ is the number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins.
            $$a_n = sum_{k_1+k_2+k_3 = n} m_{k_1, 1}m_{k_2, 2}m_{k_3, 5} $$
            where $m_{k_1, 1}$ is the number of ways to express $k_1$ dollars in terms of $1$ dollar coins, $m_{k_2, 2}$ is the number of ways of expressing $k_2$ dollars in terms of $2$ dollar coins, and $m_{k_3, 5}$ is the number of ways of expressing $k_3$ dollars in terms of $5$ dollar coins. From this:
            $$F(x) = left(sum_{n=0}^infty m_{n, 1}x^nright)left(sum_{n=0}^infty m_{n, 2}x^nright)left(sum_{n=0}^infty m_{n, 5}x^nright) = left(sum_{n=0}^infty x^nright)left(sum_{n=0}^infty x^{2n}right)left(sum_{n=0}^infty x^{5n}right)=\ = frac{1}{1-x}cdot frac{1}{1-x^2}cdot frac{1}{1-x^5} $$
            If the order of the coins is important, then we can derive a recurrence:
            $$b_{n+5} = b_{n+4}+b_{n+3}+b_n, ngeq 0 \ b_0 = 0, b_1 = 1, b_2 = 2, b_3 = 3, b_4 = 5$$
            It's because there is $3$ possible cases, we have $1, 2$ or $5$ dollar coin at the end, and we take as much dollars from the whole if that's the case. Then we have
            $$G(x) = sumlimits_{n=0}^infty b_nx^n = x+2x^2+3x^3+5x^4+sumlimits_{n=0}^infty b_{n+5}x^{n+5} = \ = p(x)+sum_{n=0}^infty (b_{n+4}+b_{n+3}+b_n)x^{n+5} = p(x)+sum_{n=0}^infty b_nx^{n+5} + sum_{n=0}^infty b_{n+3}x^{n+5} + sum_{n=0}^infty b_{n+4}x^{n+5} $$
            where $p(x) = x+2x^2+3x^3+5x^4$. Then we can simplify the $3$ sums
            $$sum_{n=0}^infty b_nx^{n+5} = x^5sum_{n=0}^infty b_nx^n = x^5G(x) $$
            $$sum_{n=0}^infty b_{n+3}x^{n+5} = x^2sum_{n=0}^infty b_{n+3}x^{n+3} = x^2sum_{n=3}^infty b_nx^n = x^2(sum_{n=0}^infty b_nx^n - sum_{n=0}^2 b_nx^n)= \ = x^2(G(x)-2x^2-x) = x^2G(x) - 2x^4-x^3 $$
            $$sum_{n=0}^infty b_{n+4}x^{n+5} = xsum_{n=0}^infty b_{n+4}x^{n+4} = xsum_{n=4}^infty b_nx^n = x(sum_{n=0}^infty b_nx^n - sum_{n=0}^3 b_nx^n) = \ = x(G(x)-3x^3-2x^2-x) = xG(x)-3x^4-2x^3-x^2 $$
            So we can now calulate what $G(x)$ is
            $$G(x) = p(x)+(x^5+x^2+x)G(x)-5x^4-3x^3-x^2 = (x^5+x^2+x)G(x)+x+x^2 $$
            $$G(x) = frac{x+x^2}{1-(x+x^2+x^5)} $$







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Dec 30 '18 at 12:36

























            answered Dec 29 '18 at 16:11









            JakobianJakobian

            2,493720




            2,493720












            • $begingroup$
              Follow up question - What if I the order of the coins is important. How will it change?
              $endgroup$
              – Igor
              Dec 30 '18 at 11:33








            • 1




              $begingroup$
              @Igor I've edited my answer
              $endgroup$
              – Jakobian
              Dec 30 '18 at 12:37












            • $begingroup$
              I didn't quiet understand the transition. Why is G(X) defined this way and what is x+2x^2+3x^3+5x^4? I lost you there..
              $endgroup$
              – Igor
              Dec 30 '18 at 15:14












            • $begingroup$
              @Igor If $b_n$ is number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins, so that the order of coins matters, then from definition, it's generating function is $sum_{n=0}^infty b_nx^n$. This is just the definition. $x+2x^2+3x^3+5x^4 = sum_{n=0}^4 b_nx^n$, we split the sum in two parts.
              $endgroup$
              – Jakobian
              Dec 30 '18 at 17:08












            • $begingroup$
              Why can't you say this is the answer? $$ frac{1}{(1-x^2-x^3-x^5)} $$ I am just summing all the possibilities for choosing coins.
              $endgroup$
              – Igor
              Jan 1 at 17:36


















            • $begingroup$
              Follow up question - What if I the order of the coins is important. How will it change?
              $endgroup$
              – Igor
              Dec 30 '18 at 11:33








            • 1




              $begingroup$
              @Igor I've edited my answer
              $endgroup$
              – Jakobian
              Dec 30 '18 at 12:37












            • $begingroup$
              I didn't quiet understand the transition. Why is G(X) defined this way and what is x+2x^2+3x^3+5x^4? I lost you there..
              $endgroup$
              – Igor
              Dec 30 '18 at 15:14












            • $begingroup$
              @Igor If $b_n$ is number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins, so that the order of coins matters, then from definition, it's generating function is $sum_{n=0}^infty b_nx^n$. This is just the definition. $x+2x^2+3x^3+5x^4 = sum_{n=0}^4 b_nx^n$, we split the sum in two parts.
              $endgroup$
              – Jakobian
              Dec 30 '18 at 17:08












            • $begingroup$
              Why can't you say this is the answer? $$ frac{1}{(1-x^2-x^3-x^5)} $$ I am just summing all the possibilities for choosing coins.
              $endgroup$
              – Igor
              Jan 1 at 17:36
















            $begingroup$
            Follow up question - What if I the order of the coins is important. How will it change?
            $endgroup$
            – Igor
            Dec 30 '18 at 11:33






            $begingroup$
            Follow up question - What if I the order of the coins is important. How will it change?
            $endgroup$
            – Igor
            Dec 30 '18 at 11:33






            1




            1




            $begingroup$
            @Igor I've edited my answer
            $endgroup$
            – Jakobian
            Dec 30 '18 at 12:37






            $begingroup$
            @Igor I've edited my answer
            $endgroup$
            – Jakobian
            Dec 30 '18 at 12:37














            $begingroup$
            I didn't quiet understand the transition. Why is G(X) defined this way and what is x+2x^2+3x^3+5x^4? I lost you there..
            $endgroup$
            – Igor
            Dec 30 '18 at 15:14






            $begingroup$
            I didn't quiet understand the transition. Why is G(X) defined this way and what is x+2x^2+3x^3+5x^4? I lost you there..
            $endgroup$
            – Igor
            Dec 30 '18 at 15:14














            $begingroup$
            @Igor If $b_n$ is number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins, so that the order of coins matters, then from definition, it's generating function is $sum_{n=0}^infty b_nx^n$. This is just the definition. $x+2x^2+3x^3+5x^4 = sum_{n=0}^4 b_nx^n$, we split the sum in two parts.
            $endgroup$
            – Jakobian
            Dec 30 '18 at 17:08






            $begingroup$
            @Igor If $b_n$ is number of ways of expressing $n$ dollars as a collection of $1, 2, 5$ dollar coins, so that the order of coins matters, then from definition, it's generating function is $sum_{n=0}^infty b_nx^n$. This is just the definition. $x+2x^2+3x^3+5x^4 = sum_{n=0}^4 b_nx^n$, we split the sum in two parts.
            $endgroup$
            – Jakobian
            Dec 30 '18 at 17:08














            $begingroup$
            Why can't you say this is the answer? $$ frac{1}{(1-x^2-x^3-x^5)} $$ I am just summing all the possibilities for choosing coins.
            $endgroup$
            – Igor
            Jan 1 at 17:36




            $begingroup$
            Why can't you say this is the answer? $$ frac{1}{(1-x^2-x^3-x^5)} $$ I am just summing all the possibilities for choosing coins.
            $endgroup$
            – Igor
            Jan 1 at 17:36


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3055952%2fgenerating-function-problem%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Human spaceflight

            Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

            張江高科駅