Exponential Generating Function For Derangements

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
13
down vote

favorite
9












I have been introduced to the concept of exponential generating functions a few days ago. However, my understanding of them are still quite limited, and I would like to see some examples. Earlier this term, I derived a formula for the number of derangements of size $n$ using the inclusion/exclusion principle, namely that $D_n = n!sum_k=0^inftyfrac(-1)^kk!$. How would I go about deriving this result using exponential generating functions, without using the inclusion/exclusion principle to derive $D_n$. The formula we are using for the these generating functions are $Phi_D(x) = sum_n=0^infty|D_n|fracx^nn!$.



If anyone could walk me through this example, I would greatly appreciate it :)
Thanks!







share|cite|improve this question


























    up vote
    13
    down vote

    favorite
    9












    I have been introduced to the concept of exponential generating functions a few days ago. However, my understanding of them are still quite limited, and I would like to see some examples. Earlier this term, I derived a formula for the number of derangements of size $n$ using the inclusion/exclusion principle, namely that $D_n = n!sum_k=0^inftyfrac(-1)^kk!$. How would I go about deriving this result using exponential generating functions, without using the inclusion/exclusion principle to derive $D_n$. The formula we are using for the these generating functions are $Phi_D(x) = sum_n=0^infty|D_n|fracx^nn!$.



    If anyone could walk me through this example, I would greatly appreciate it :)
    Thanks!







    share|cite|improve this question
























      up vote
      13
      down vote

      favorite
      9









      up vote
      13
      down vote

      favorite
      9






      9





      I have been introduced to the concept of exponential generating functions a few days ago. However, my understanding of them are still quite limited, and I would like to see some examples. Earlier this term, I derived a formula for the number of derangements of size $n$ using the inclusion/exclusion principle, namely that $D_n = n!sum_k=0^inftyfrac(-1)^kk!$. How would I go about deriving this result using exponential generating functions, without using the inclusion/exclusion principle to derive $D_n$. The formula we are using for the these generating functions are $Phi_D(x) = sum_n=0^infty|D_n|fracx^nn!$.



      If anyone could walk me through this example, I would greatly appreciate it :)
      Thanks!







      share|cite|improve this question














      I have been introduced to the concept of exponential generating functions a few days ago. However, my understanding of them are still quite limited, and I would like to see some examples. Earlier this term, I derived a formula for the number of derangements of size $n$ using the inclusion/exclusion principle, namely that $D_n = n!sum_k=0^inftyfrac(-1)^kk!$. How would I go about deriving this result using exponential generating functions, without using the inclusion/exclusion principle to derive $D_n$. The formula we are using for the these generating functions are $Phi_D(x) = sum_n=0^infty|D_n|fracx^nn!$.



      If anyone could walk me through this example, I would greatly appreciate it :)
      Thanks!









      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Aug 14 at 4:57









      joriki

      165k10180329




      165k10180329










      asked Nov 19 '12 at 4:05









      Nizbel99

      289417




      289417




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          16
          down vote



          accepted










          Here’s one way. Start with the recurrence $d_n+1=nd_n+nd_n-1$, where $d_n$ is the number of derangements of $[n]=1,dots,n$. Multiply by $fracx^nn!$ and sum over $nge 0$:



          $$sum_nge 0d_n+1fracx^nn!=sum_nge 0nd_nfracx^nn!+sum_nge 0nd_n-1fracx^nn!;.tag1$$



          (Here I make the assumption that $d_-1=0$: this is consistent with the recurrence, so it causes no problems.) Let $$D(x)=sum_nge 0d_nfracx^nn!$$ be the exponential generating function in question. Then $$D,'(x)=sum_nge 0nd_nfracx^n-1n!=sum_nge 1d_nfracx^n-1(n-1)!=sum_nge 0d_n+1fracx^nn!;,tag2$$



          $$xD,'(x)=xsum_nge 0nd_nfracx^n-1n!=sum_nge 0nd_nfracx^nn!;,tag3$$



          and $$xD(x)=sum_nge 0d_nfracx^n+1n!=sum_nge 0(n+1)d_nfracx^n+1(n+1)!=sum_nge 1nd_n-1fracx^nn!=sum_nge 0nd_n-1fracx^nn!;,tag4$$ since by convention $d_-1=0$.



          Compare $(2),(3)$, and $(4)$ with $(1)$, and you’ll see that



          $$D,'(x)=xD,'(x)+xD(x);,$$ or $$(1-x)D,'(x)=xD(x);.$$ This is a separable differential equation,



          $$fracD,'(x)D(x)=fracx1-x=-1+frac11-x;,$$



          which you can now solve for $D(x)$ by first-year calculus.




          Here’s another way, quicker but sneakier. For any particular set $K$ of $k$ elements of $[n]$ there are $d_n-k$ permutations of $[n]$ that have $K$ as their set of fixed points. There are $binomnk$ such subsets $K$, so there are $binomnkd_n-k$ permutations of $[n]$ with exactly $k$ fixed points. Since there are $n!$ permutations of $[n]$ altogether, $$sum_k=0^nbinomnkd_n-k=n!;.tag5$$ The lefthand side of $(5)$ is the $n$-th term of the binomial convolution of the sequences $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$, so the exponential generating function (egf) of the sequence



          $$leftlanglesum_k=0^nbinomnkd_n-k:ninBbb Nrightrangle=langle n!:ninBbb Nrangle$$



          is the product of the egfs of $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$. Clearly $$sum_nge 0n!fracx^nn!=sum_nge 0x^n=frac11-x$$ and $$sum_nge 01cdotfracx^nn!=e^x;,$$ so $$e^xD(x)=frac11-x;,$$ and $$D(x)=frace^-x1-x;.$$






          share|cite|improve this answer






















          • Wow, quite interesting. To be honest, I feel more comfortable with the steps outlined in the first proof than I do in the second, even though I don't think I would of came to the realization of starting it off the way you did. As for the second one, I feel like it has more of a combinatorial nature, even though I don't quite understand all of the steps. I've never heard of the binomial convolution formula before and I am not quite familiar with equation (5) and the product of the EGFs described after.
            – Nizbel99
            Nov 19 '12 at 6:53











          • However, the second proof does seem to reflect what we're doing in class, given that we're talking about classes of structures, which is the motivation we're using in order to discuss EGFs :)
            – Nizbel99
            Nov 19 '12 at 6:54






          • 1




            @user43552: I thought that the first one was a bit more straightforward. You might want to download Herbert Wilf’s generatingfunctionology, freely available here; it’s not the easiest book, but I actually lifed that second derivation from it.
            – Brian M. Scott
            Nov 19 '12 at 6:58






          • 1




            @AlJebr: It needn’t: the original constant term has derivative $0$, so it makes no difference whether one includes it or not. I thought that it might be clearer to leave that term in the sum at first, simply replacing the general term by its derivative, and then point out at the next step that in fact we can start the indexing at $1$ without losing anything.
            – Brian M. Scott
            Mar 15 '16 at 7:31






          • 1




            @AlJebr: If there is more than one way to express something, you use whatever expression is most useful for your purposes. This is every bit as true for power series as for anything else. I get the feeling that you’re trying to bypass thinking about what’s actually happening in the computation in favor of applying a mechanical rule; that’s not a good idea, at least not until you’ve become so familiar with such calculations that they are mechanical for you.
            – Brian M. Scott
            Mar 15 '16 at 7:40

















          up vote
          10
          down vote













          Another way: There are $n!$ permutations in all. A permutation with $k$ fixed points shuffles the other $n - k$ elements around without fixed points, the $k$ fixed points can be selected in $binomnk$ ways. So:
          $$
          n! = sum_0 le k le n binomnk d_n -k
          $$
          This is a binomial convolution, using Mike Spivey's notation that gives:
          $$
          beginalign*
          frac11 - x &= G_D(x) e^x \
          G_D(x) &= frace^-x1 - x
          endalign*
          $$






          share|cite|improve this answer






















          • +1, but actually this is the same as Brian's second way.
            – ShreevatsaR
            Jan 20 '14 at 5:50


















          up vote
          10
          down vote













          There's a shorter way even than the two in Brian's nice answer. Starting from the recurrence $D_n = n D_n-1 + (-1)^n$, multiply by $x^n/n!$ and sum over $n geq 1$ to get
          beginalign
          &sum_n geq 1 D_n fracx^nn! = sum_n geq 1 n D_n-1 fracx^nn! + sum_n geq 1 (-1)^n fracx^nn! \
          implies & G_D(x) - 1 = x sum_n geq 1 D_n-1 fracx^n-1(n-1)! + e^-x - 1, text as $D_0 = 1$ \
          implies & G_D(x) = x G_D(x) + e^-x,
          endalign
          which tells you that the exponential generating function is $$G_D(x) = frace^-x1-x.$$






          share|cite|improve this answer






















          • You first have to show that the two recurrences are equivalent.
            – marty cohen
            May 21 '13 at 19:56










          • @martycohen: Well, that depends on what you already know about the derangement numbers. But it is easy to get from the recurrence Brian uses to the one I use. See, for example, this blog post.
            – Mike Spivey
            May 23 '13 at 3:10










          • I just came across this question and noted that using $(9)$ from this answer, we simply need to multiply by $x^n$ and sum for $nge1$ to get $f(x)-1-xf(x)=e^-x-1$ which immediately gives $f(x)=frace^-x1-x$. This is essentially what you have here (+1)
            – robjohn♦
            Sep 18 '15 at 22:46











          • I just noticed that you are summing for $nge0$. What do you use for $D_-1$? Of course, it is being multiplied by $frac00!$, so perhaps we don't need to worry too much, but somehow, it still bothers me.
            – robjohn♦
            Sep 18 '15 at 22:48











          • @robjohn: Better? :)
            – Mike Spivey
            Sep 18 '15 at 23:15

















          up vote
          8
          down vote













          Yet another couple of ways.



          Method 1.
          $$mathcalD = operatornameSscriptsize ET(operatornameCscriptsize YC_> 1) implies D(z) = expleft(ln frac11-z - zright) = frace^-z1-z.$$



          Explanation: A derangement, a permutation with no fixed points, is a set of cycles each containing more than one element. The EGF for such cycles can be got by either taking the known EGF for all cycles, namely $C(z) = lnfrac11-z$, and subtracting the term "$z$" that corresponds to the unique cycle of length $1$, or, if you don't know $C(z)$, with explicit counting as
          $$C_>1(z) = sum_n ge 2 (n-1)! fracz^nn! = sum_nge 2fracz^nn = ln frac11-z - z$$



          And as derangements are sets of such cycles, their EGF is the exponential of the EGF of such cycles. (This set→exp-of-EGFs fact is also known as the exponential formula.)




          Note that the above aproach also easily gives the generating function for the number of permutations with all cycles of length greater than $r$ for any $r$ (derangements is the $r=1$ case): it's
          $$D_r(z) = expleft(sum_n > r fracz^rrright) = frace^-z-z^2/2 - dots - z^r/r1-z.$$
          Of course, the $r=0$ case simply gives the EGF of all permutations, $explnfrac11-z = frac11-z$, as expected.




          Method 2.

          This is a generating-functions analogue of the inclusion-exclusion principle. Though it is overkill for this problem, here it is as an illustration.



          Let $mathcalP$ be the class of all permutations, and let $mathcalQ$ be the class of all permutations with some subset of their fixed-points (possibly none, possibly all) specially distinguished. Viewing it differently, any member of $mathcalQ$ is got by taking an arbitrary permutation and inserting a set of fixed points in it: $mathcalQ = mathcalP star operatornameSscriptsize ET(mathcalZ)$. Using the variable $z$ to mark size and the variable $v$ to mark the distinguished fixed points, we get the (bivariate) EGF $Q(z,v) = frac11-ze^zv$.



          Now if $P(z, u)$ is the EGF for permutations where $z$ marks size and $u$ marks the fixed points, the act of "distinguishing" some of the fixed points corresponds to the substitution $1 + v$ for $u$ in the EGF for permutations: every fixed point (marked by $u$) is either distinguished (marked by $v$) or not (unmarked). So we have $Q(z, v) = P(z, 1 + v)$ or equivalently $P(z, u) = Q(z, u - 1) = dfrace^z(u-1)1-z$. The EGF of derangements is got by setting $u = 0$ in the above:
          $$D(z) = P(z, 0) = frace^-z1-z$$




          This approach also gives the EGF number of permutations with exactly $k$ fixed points, as the coefficient of $u^k$ in the above: it's $dfracz^kk!dfrace^-z1-z$.




          References: Both the above are from the book Analytic Combinatorics by Flajolet and Sedgewick, pp. 122–123 and 207–208 respectively.




          Of course, a simpler observation is that any permutation is a derangement along with a set of fixed points added, so
          $$mathcalP = mathcalD star operatornameSscriptsize ET(mathcalZ)
          implies P(z) = D(z) e^z implies D(z) = frace^-z1-z
          $$
          which is the same as Brian M. Scott's second approach and vonbrand's answer.






          share|cite|improve this answer




















            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',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            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%2f240357%2fexponential-generating-function-for-derangements%23new-answer', 'question_page');

            );

            Post as a guest






























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            16
            down vote



            accepted










            Here’s one way. Start with the recurrence $d_n+1=nd_n+nd_n-1$, where $d_n$ is the number of derangements of $[n]=1,dots,n$. Multiply by $fracx^nn!$ and sum over $nge 0$:



            $$sum_nge 0d_n+1fracx^nn!=sum_nge 0nd_nfracx^nn!+sum_nge 0nd_n-1fracx^nn!;.tag1$$



            (Here I make the assumption that $d_-1=0$: this is consistent with the recurrence, so it causes no problems.) Let $$D(x)=sum_nge 0d_nfracx^nn!$$ be the exponential generating function in question. Then $$D,'(x)=sum_nge 0nd_nfracx^n-1n!=sum_nge 1d_nfracx^n-1(n-1)!=sum_nge 0d_n+1fracx^nn!;,tag2$$



            $$xD,'(x)=xsum_nge 0nd_nfracx^n-1n!=sum_nge 0nd_nfracx^nn!;,tag3$$



            and $$xD(x)=sum_nge 0d_nfracx^n+1n!=sum_nge 0(n+1)d_nfracx^n+1(n+1)!=sum_nge 1nd_n-1fracx^nn!=sum_nge 0nd_n-1fracx^nn!;,tag4$$ since by convention $d_-1=0$.



            Compare $(2),(3)$, and $(4)$ with $(1)$, and you’ll see that



            $$D,'(x)=xD,'(x)+xD(x);,$$ or $$(1-x)D,'(x)=xD(x);.$$ This is a separable differential equation,



            $$fracD,'(x)D(x)=fracx1-x=-1+frac11-x;,$$



            which you can now solve for $D(x)$ by first-year calculus.




            Here’s another way, quicker but sneakier. For any particular set $K$ of $k$ elements of $[n]$ there are $d_n-k$ permutations of $[n]$ that have $K$ as their set of fixed points. There are $binomnk$ such subsets $K$, so there are $binomnkd_n-k$ permutations of $[n]$ with exactly $k$ fixed points. Since there are $n!$ permutations of $[n]$ altogether, $$sum_k=0^nbinomnkd_n-k=n!;.tag5$$ The lefthand side of $(5)$ is the $n$-th term of the binomial convolution of the sequences $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$, so the exponential generating function (egf) of the sequence



            $$leftlanglesum_k=0^nbinomnkd_n-k:ninBbb Nrightrangle=langle n!:ninBbb Nrangle$$



            is the product of the egfs of $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$. Clearly $$sum_nge 0n!fracx^nn!=sum_nge 0x^n=frac11-x$$ and $$sum_nge 01cdotfracx^nn!=e^x;,$$ so $$e^xD(x)=frac11-x;,$$ and $$D(x)=frace^-x1-x;.$$






            share|cite|improve this answer






















            • Wow, quite interesting. To be honest, I feel more comfortable with the steps outlined in the first proof than I do in the second, even though I don't think I would of came to the realization of starting it off the way you did. As for the second one, I feel like it has more of a combinatorial nature, even though I don't quite understand all of the steps. I've never heard of the binomial convolution formula before and I am not quite familiar with equation (5) and the product of the EGFs described after.
              – Nizbel99
              Nov 19 '12 at 6:53











            • However, the second proof does seem to reflect what we're doing in class, given that we're talking about classes of structures, which is the motivation we're using in order to discuss EGFs :)
              – Nizbel99
              Nov 19 '12 at 6:54






            • 1




              @user43552: I thought that the first one was a bit more straightforward. You might want to download Herbert Wilf’s generatingfunctionology, freely available here; it’s not the easiest book, but I actually lifed that second derivation from it.
              – Brian M. Scott
              Nov 19 '12 at 6:58






            • 1




              @AlJebr: It needn’t: the original constant term has derivative $0$, so it makes no difference whether one includes it or not. I thought that it might be clearer to leave that term in the sum at first, simply replacing the general term by its derivative, and then point out at the next step that in fact we can start the indexing at $1$ without losing anything.
              – Brian M. Scott
              Mar 15 '16 at 7:31






            • 1




              @AlJebr: If there is more than one way to express something, you use whatever expression is most useful for your purposes. This is every bit as true for power series as for anything else. I get the feeling that you’re trying to bypass thinking about what’s actually happening in the computation in favor of applying a mechanical rule; that’s not a good idea, at least not until you’ve become so familiar with such calculations that they are mechanical for you.
              – Brian M. Scott
              Mar 15 '16 at 7:40














            up vote
            16
            down vote



            accepted










            Here’s one way. Start with the recurrence $d_n+1=nd_n+nd_n-1$, where $d_n$ is the number of derangements of $[n]=1,dots,n$. Multiply by $fracx^nn!$ and sum over $nge 0$:



            $$sum_nge 0d_n+1fracx^nn!=sum_nge 0nd_nfracx^nn!+sum_nge 0nd_n-1fracx^nn!;.tag1$$



            (Here I make the assumption that $d_-1=0$: this is consistent with the recurrence, so it causes no problems.) Let $$D(x)=sum_nge 0d_nfracx^nn!$$ be the exponential generating function in question. Then $$D,'(x)=sum_nge 0nd_nfracx^n-1n!=sum_nge 1d_nfracx^n-1(n-1)!=sum_nge 0d_n+1fracx^nn!;,tag2$$



            $$xD,'(x)=xsum_nge 0nd_nfracx^n-1n!=sum_nge 0nd_nfracx^nn!;,tag3$$



            and $$xD(x)=sum_nge 0d_nfracx^n+1n!=sum_nge 0(n+1)d_nfracx^n+1(n+1)!=sum_nge 1nd_n-1fracx^nn!=sum_nge 0nd_n-1fracx^nn!;,tag4$$ since by convention $d_-1=0$.



            Compare $(2),(3)$, and $(4)$ with $(1)$, and you’ll see that



            $$D,'(x)=xD,'(x)+xD(x);,$$ or $$(1-x)D,'(x)=xD(x);.$$ This is a separable differential equation,



            $$fracD,'(x)D(x)=fracx1-x=-1+frac11-x;,$$



            which you can now solve for $D(x)$ by first-year calculus.




            Here’s another way, quicker but sneakier. For any particular set $K$ of $k$ elements of $[n]$ there are $d_n-k$ permutations of $[n]$ that have $K$ as their set of fixed points. There are $binomnk$ such subsets $K$, so there are $binomnkd_n-k$ permutations of $[n]$ with exactly $k$ fixed points. Since there are $n!$ permutations of $[n]$ altogether, $$sum_k=0^nbinomnkd_n-k=n!;.tag5$$ The lefthand side of $(5)$ is the $n$-th term of the binomial convolution of the sequences $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$, so the exponential generating function (egf) of the sequence



            $$leftlanglesum_k=0^nbinomnkd_n-k:ninBbb Nrightrangle=langle n!:ninBbb Nrangle$$



            is the product of the egfs of $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$. Clearly $$sum_nge 0n!fracx^nn!=sum_nge 0x^n=frac11-x$$ and $$sum_nge 01cdotfracx^nn!=e^x;,$$ so $$e^xD(x)=frac11-x;,$$ and $$D(x)=frace^-x1-x;.$$






            share|cite|improve this answer






















            • Wow, quite interesting. To be honest, I feel more comfortable with the steps outlined in the first proof than I do in the second, even though I don't think I would of came to the realization of starting it off the way you did. As for the second one, I feel like it has more of a combinatorial nature, even though I don't quite understand all of the steps. I've never heard of the binomial convolution formula before and I am not quite familiar with equation (5) and the product of the EGFs described after.
              – Nizbel99
              Nov 19 '12 at 6:53











            • However, the second proof does seem to reflect what we're doing in class, given that we're talking about classes of structures, which is the motivation we're using in order to discuss EGFs :)
              – Nizbel99
              Nov 19 '12 at 6:54






            • 1




              @user43552: I thought that the first one was a bit more straightforward. You might want to download Herbert Wilf’s generatingfunctionology, freely available here; it’s not the easiest book, but I actually lifed that second derivation from it.
              – Brian M. Scott
              Nov 19 '12 at 6:58






            • 1




              @AlJebr: It needn’t: the original constant term has derivative $0$, so it makes no difference whether one includes it or not. I thought that it might be clearer to leave that term in the sum at first, simply replacing the general term by its derivative, and then point out at the next step that in fact we can start the indexing at $1$ without losing anything.
              – Brian M. Scott
              Mar 15 '16 at 7:31






            • 1




              @AlJebr: If there is more than one way to express something, you use whatever expression is most useful for your purposes. This is every bit as true for power series as for anything else. I get the feeling that you’re trying to bypass thinking about what’s actually happening in the computation in favor of applying a mechanical rule; that’s not a good idea, at least not until you’ve become so familiar with such calculations that they are mechanical for you.
              – Brian M. Scott
              Mar 15 '16 at 7:40












            up vote
            16
            down vote



            accepted







            up vote
            16
            down vote



            accepted






            Here’s one way. Start with the recurrence $d_n+1=nd_n+nd_n-1$, where $d_n$ is the number of derangements of $[n]=1,dots,n$. Multiply by $fracx^nn!$ and sum over $nge 0$:



            $$sum_nge 0d_n+1fracx^nn!=sum_nge 0nd_nfracx^nn!+sum_nge 0nd_n-1fracx^nn!;.tag1$$



            (Here I make the assumption that $d_-1=0$: this is consistent with the recurrence, so it causes no problems.) Let $$D(x)=sum_nge 0d_nfracx^nn!$$ be the exponential generating function in question. Then $$D,'(x)=sum_nge 0nd_nfracx^n-1n!=sum_nge 1d_nfracx^n-1(n-1)!=sum_nge 0d_n+1fracx^nn!;,tag2$$



            $$xD,'(x)=xsum_nge 0nd_nfracx^n-1n!=sum_nge 0nd_nfracx^nn!;,tag3$$



            and $$xD(x)=sum_nge 0d_nfracx^n+1n!=sum_nge 0(n+1)d_nfracx^n+1(n+1)!=sum_nge 1nd_n-1fracx^nn!=sum_nge 0nd_n-1fracx^nn!;,tag4$$ since by convention $d_-1=0$.



            Compare $(2),(3)$, and $(4)$ with $(1)$, and you’ll see that



            $$D,'(x)=xD,'(x)+xD(x);,$$ or $$(1-x)D,'(x)=xD(x);.$$ This is a separable differential equation,



            $$fracD,'(x)D(x)=fracx1-x=-1+frac11-x;,$$



            which you can now solve for $D(x)$ by first-year calculus.




            Here’s another way, quicker but sneakier. For any particular set $K$ of $k$ elements of $[n]$ there are $d_n-k$ permutations of $[n]$ that have $K$ as their set of fixed points. There are $binomnk$ such subsets $K$, so there are $binomnkd_n-k$ permutations of $[n]$ with exactly $k$ fixed points. Since there are $n!$ permutations of $[n]$ altogether, $$sum_k=0^nbinomnkd_n-k=n!;.tag5$$ The lefthand side of $(5)$ is the $n$-th term of the binomial convolution of the sequences $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$, so the exponential generating function (egf) of the sequence



            $$leftlanglesum_k=0^nbinomnkd_n-k:ninBbb Nrightrangle=langle n!:ninBbb Nrangle$$



            is the product of the egfs of $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$. Clearly $$sum_nge 0n!fracx^nn!=sum_nge 0x^n=frac11-x$$ and $$sum_nge 01cdotfracx^nn!=e^x;,$$ so $$e^xD(x)=frac11-x;,$$ and $$D(x)=frace^-x1-x;.$$






            share|cite|improve this answer














            Here’s one way. Start with the recurrence $d_n+1=nd_n+nd_n-1$, where $d_n$ is the number of derangements of $[n]=1,dots,n$. Multiply by $fracx^nn!$ and sum over $nge 0$:



            $$sum_nge 0d_n+1fracx^nn!=sum_nge 0nd_nfracx^nn!+sum_nge 0nd_n-1fracx^nn!;.tag1$$



            (Here I make the assumption that $d_-1=0$: this is consistent with the recurrence, so it causes no problems.) Let $$D(x)=sum_nge 0d_nfracx^nn!$$ be the exponential generating function in question. Then $$D,'(x)=sum_nge 0nd_nfracx^n-1n!=sum_nge 1d_nfracx^n-1(n-1)!=sum_nge 0d_n+1fracx^nn!;,tag2$$



            $$xD,'(x)=xsum_nge 0nd_nfracx^n-1n!=sum_nge 0nd_nfracx^nn!;,tag3$$



            and $$xD(x)=sum_nge 0d_nfracx^n+1n!=sum_nge 0(n+1)d_nfracx^n+1(n+1)!=sum_nge 1nd_n-1fracx^nn!=sum_nge 0nd_n-1fracx^nn!;,tag4$$ since by convention $d_-1=0$.



            Compare $(2),(3)$, and $(4)$ with $(1)$, and you’ll see that



            $$D,'(x)=xD,'(x)+xD(x);,$$ or $$(1-x)D,'(x)=xD(x);.$$ This is a separable differential equation,



            $$fracD,'(x)D(x)=fracx1-x=-1+frac11-x;,$$



            which you can now solve for $D(x)$ by first-year calculus.




            Here’s another way, quicker but sneakier. For any particular set $K$ of $k$ elements of $[n]$ there are $d_n-k$ permutations of $[n]$ that have $K$ as their set of fixed points. There are $binomnk$ such subsets $K$, so there are $binomnkd_n-k$ permutations of $[n]$ with exactly $k$ fixed points. Since there are $n!$ permutations of $[n]$ altogether, $$sum_k=0^nbinomnkd_n-k=n!;.tag5$$ The lefthand side of $(5)$ is the $n$-th term of the binomial convolution of the sequences $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$, so the exponential generating function (egf) of the sequence



            $$leftlanglesum_k=0^nbinomnkd_n-k:ninBbb Nrightrangle=langle n!:ninBbb Nrangle$$



            is the product of the egfs of $langle 1,1,1,dotsrangle$ and $langle d_n:ninBbb Nrangle$. Clearly $$sum_nge 0n!fracx^nn!=sum_nge 0x^n=frac11-x$$ and $$sum_nge 01cdotfracx^nn!=e^x;,$$ so $$e^xD(x)=frac11-x;,$$ and $$D(x)=frace^-x1-x;.$$







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Mar 15 '16 at 7:21

























            answered Nov 19 '12 at 4:33









            Brian M. Scott

            448k39492880




            448k39492880











            • Wow, quite interesting. To be honest, I feel more comfortable with the steps outlined in the first proof than I do in the second, even though I don't think I would of came to the realization of starting it off the way you did. As for the second one, I feel like it has more of a combinatorial nature, even though I don't quite understand all of the steps. I've never heard of the binomial convolution formula before and I am not quite familiar with equation (5) and the product of the EGFs described after.
              – Nizbel99
              Nov 19 '12 at 6:53











            • However, the second proof does seem to reflect what we're doing in class, given that we're talking about classes of structures, which is the motivation we're using in order to discuss EGFs :)
              – Nizbel99
              Nov 19 '12 at 6:54






            • 1




              @user43552: I thought that the first one was a bit more straightforward. You might want to download Herbert Wilf’s generatingfunctionology, freely available here; it’s not the easiest book, but I actually lifed that second derivation from it.
              – Brian M. Scott
              Nov 19 '12 at 6:58






            • 1




              @AlJebr: It needn’t: the original constant term has derivative $0$, so it makes no difference whether one includes it or not. I thought that it might be clearer to leave that term in the sum at first, simply replacing the general term by its derivative, and then point out at the next step that in fact we can start the indexing at $1$ without losing anything.
              – Brian M. Scott
              Mar 15 '16 at 7:31






            • 1




              @AlJebr: If there is more than one way to express something, you use whatever expression is most useful for your purposes. This is every bit as true for power series as for anything else. I get the feeling that you’re trying to bypass thinking about what’s actually happening in the computation in favor of applying a mechanical rule; that’s not a good idea, at least not until you’ve become so familiar with such calculations that they are mechanical for you.
              – Brian M. Scott
              Mar 15 '16 at 7:40
















            • Wow, quite interesting. To be honest, I feel more comfortable with the steps outlined in the first proof than I do in the second, even though I don't think I would of came to the realization of starting it off the way you did. As for the second one, I feel like it has more of a combinatorial nature, even though I don't quite understand all of the steps. I've never heard of the binomial convolution formula before and I am not quite familiar with equation (5) and the product of the EGFs described after.
              – Nizbel99
              Nov 19 '12 at 6:53











            • However, the second proof does seem to reflect what we're doing in class, given that we're talking about classes of structures, which is the motivation we're using in order to discuss EGFs :)
              – Nizbel99
              Nov 19 '12 at 6:54






            • 1




              @user43552: I thought that the first one was a bit more straightforward. You might want to download Herbert Wilf’s generatingfunctionology, freely available here; it’s not the easiest book, but I actually lifed that second derivation from it.
              – Brian M. Scott
              Nov 19 '12 at 6:58






            • 1




              @AlJebr: It needn’t: the original constant term has derivative $0$, so it makes no difference whether one includes it or not. I thought that it might be clearer to leave that term in the sum at first, simply replacing the general term by its derivative, and then point out at the next step that in fact we can start the indexing at $1$ without losing anything.
              – Brian M. Scott
              Mar 15 '16 at 7:31






            • 1




              @AlJebr: If there is more than one way to express something, you use whatever expression is most useful for your purposes. This is every bit as true for power series as for anything else. I get the feeling that you’re trying to bypass thinking about what’s actually happening in the computation in favor of applying a mechanical rule; that’s not a good idea, at least not until you’ve become so familiar with such calculations that they are mechanical for you.
              – Brian M. Scott
              Mar 15 '16 at 7:40















            Wow, quite interesting. To be honest, I feel more comfortable with the steps outlined in the first proof than I do in the second, even though I don't think I would of came to the realization of starting it off the way you did. As for the second one, I feel like it has more of a combinatorial nature, even though I don't quite understand all of the steps. I've never heard of the binomial convolution formula before and I am not quite familiar with equation (5) and the product of the EGFs described after.
            – Nizbel99
            Nov 19 '12 at 6:53





            Wow, quite interesting. To be honest, I feel more comfortable with the steps outlined in the first proof than I do in the second, even though I don't think I would of came to the realization of starting it off the way you did. As for the second one, I feel like it has more of a combinatorial nature, even though I don't quite understand all of the steps. I've never heard of the binomial convolution formula before and I am not quite familiar with equation (5) and the product of the EGFs described after.
            – Nizbel99
            Nov 19 '12 at 6:53













            However, the second proof does seem to reflect what we're doing in class, given that we're talking about classes of structures, which is the motivation we're using in order to discuss EGFs :)
            – Nizbel99
            Nov 19 '12 at 6:54




            However, the second proof does seem to reflect what we're doing in class, given that we're talking about classes of structures, which is the motivation we're using in order to discuss EGFs :)
            – Nizbel99
            Nov 19 '12 at 6:54




            1




            1




            @user43552: I thought that the first one was a bit more straightforward. You might want to download Herbert Wilf’s generatingfunctionology, freely available here; it’s not the easiest book, but I actually lifed that second derivation from it.
            – Brian M. Scott
            Nov 19 '12 at 6:58




            @user43552: I thought that the first one was a bit more straightforward. You might want to download Herbert Wilf’s generatingfunctionology, freely available here; it’s not the easiest book, but I actually lifed that second derivation from it.
            – Brian M. Scott
            Nov 19 '12 at 6:58




            1




            1




            @AlJebr: It needn’t: the original constant term has derivative $0$, so it makes no difference whether one includes it or not. I thought that it might be clearer to leave that term in the sum at first, simply replacing the general term by its derivative, and then point out at the next step that in fact we can start the indexing at $1$ without losing anything.
            – Brian M. Scott
            Mar 15 '16 at 7:31




            @AlJebr: It needn’t: the original constant term has derivative $0$, so it makes no difference whether one includes it or not. I thought that it might be clearer to leave that term in the sum at first, simply replacing the general term by its derivative, and then point out at the next step that in fact we can start the indexing at $1$ without losing anything.
            – Brian M. Scott
            Mar 15 '16 at 7:31




            1




            1




            @AlJebr: If there is more than one way to express something, you use whatever expression is most useful for your purposes. This is every bit as true for power series as for anything else. I get the feeling that you’re trying to bypass thinking about what’s actually happening in the computation in favor of applying a mechanical rule; that’s not a good idea, at least not until you’ve become so familiar with such calculations that they are mechanical for you.
            – Brian M. Scott
            Mar 15 '16 at 7:40




            @AlJebr: If there is more than one way to express something, you use whatever expression is most useful for your purposes. This is every bit as true for power series as for anything else. I get the feeling that you’re trying to bypass thinking about what’s actually happening in the computation in favor of applying a mechanical rule; that’s not a good idea, at least not until you’ve become so familiar with such calculations that they are mechanical for you.
            – Brian M. Scott
            Mar 15 '16 at 7:40










            up vote
            10
            down vote













            Another way: There are $n!$ permutations in all. A permutation with $k$ fixed points shuffles the other $n - k$ elements around without fixed points, the $k$ fixed points can be selected in $binomnk$ ways. So:
            $$
            n! = sum_0 le k le n binomnk d_n -k
            $$
            This is a binomial convolution, using Mike Spivey's notation that gives:
            $$
            beginalign*
            frac11 - x &= G_D(x) e^x \
            G_D(x) &= frace^-x1 - x
            endalign*
            $$






            share|cite|improve this answer






















            • +1, but actually this is the same as Brian's second way.
              – ShreevatsaR
              Jan 20 '14 at 5:50















            up vote
            10
            down vote













            Another way: There are $n!$ permutations in all. A permutation with $k$ fixed points shuffles the other $n - k$ elements around without fixed points, the $k$ fixed points can be selected in $binomnk$ ways. So:
            $$
            n! = sum_0 le k le n binomnk d_n -k
            $$
            This is a binomial convolution, using Mike Spivey's notation that gives:
            $$
            beginalign*
            frac11 - x &= G_D(x) e^x \
            G_D(x) &= frace^-x1 - x
            endalign*
            $$






            share|cite|improve this answer






















            • +1, but actually this is the same as Brian's second way.
              – ShreevatsaR
              Jan 20 '14 at 5:50













            up vote
            10
            down vote










            up vote
            10
            down vote









            Another way: There are $n!$ permutations in all. A permutation with $k$ fixed points shuffles the other $n - k$ elements around without fixed points, the $k$ fixed points can be selected in $binomnk$ ways. So:
            $$
            n! = sum_0 le k le n binomnk d_n -k
            $$
            This is a binomial convolution, using Mike Spivey's notation that gives:
            $$
            beginalign*
            frac11 - x &= G_D(x) e^x \
            G_D(x) &= frace^-x1 - x
            endalign*
            $$






            share|cite|improve this answer














            Another way: There are $n!$ permutations in all. A permutation with $k$ fixed points shuffles the other $n - k$ elements around without fixed points, the $k$ fixed points can be selected in $binomnk$ ways. So:
            $$
            n! = sum_0 le k le n binomnk d_n -k
            $$
            This is a binomial convolution, using Mike Spivey's notation that gives:
            $$
            beginalign*
            frac11 - x &= G_D(x) e^x \
            G_D(x) &= frace^-x1 - x
            endalign*
            $$







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited May 23 '13 at 10:53

























            answered May 21 '13 at 18:08









            vonbrand

            19.6k62957




            19.6k62957











            • +1, but actually this is the same as Brian's second way.
              – ShreevatsaR
              Jan 20 '14 at 5:50

















            • +1, but actually this is the same as Brian's second way.
              – ShreevatsaR
              Jan 20 '14 at 5:50
















            +1, but actually this is the same as Brian's second way.
            – ShreevatsaR
            Jan 20 '14 at 5:50





            +1, but actually this is the same as Brian's second way.
            – ShreevatsaR
            Jan 20 '14 at 5:50











            up vote
            10
            down vote













            There's a shorter way even than the two in Brian's nice answer. Starting from the recurrence $D_n = n D_n-1 + (-1)^n$, multiply by $x^n/n!$ and sum over $n geq 1$ to get
            beginalign
            &sum_n geq 1 D_n fracx^nn! = sum_n geq 1 n D_n-1 fracx^nn! + sum_n geq 1 (-1)^n fracx^nn! \
            implies & G_D(x) - 1 = x sum_n geq 1 D_n-1 fracx^n-1(n-1)! + e^-x - 1, text as $D_0 = 1$ \
            implies & G_D(x) = x G_D(x) + e^-x,
            endalign
            which tells you that the exponential generating function is $$G_D(x) = frace^-x1-x.$$






            share|cite|improve this answer






















            • You first have to show that the two recurrences are equivalent.
              – marty cohen
              May 21 '13 at 19:56










            • @martycohen: Well, that depends on what you already know about the derangement numbers. But it is easy to get from the recurrence Brian uses to the one I use. See, for example, this blog post.
              – Mike Spivey
              May 23 '13 at 3:10










            • I just came across this question and noted that using $(9)$ from this answer, we simply need to multiply by $x^n$ and sum for $nge1$ to get $f(x)-1-xf(x)=e^-x-1$ which immediately gives $f(x)=frace^-x1-x$. This is essentially what you have here (+1)
              – robjohn♦
              Sep 18 '15 at 22:46











            • I just noticed that you are summing for $nge0$. What do you use for $D_-1$? Of course, it is being multiplied by $frac00!$, so perhaps we don't need to worry too much, but somehow, it still bothers me.
              – robjohn♦
              Sep 18 '15 at 22:48











            • @robjohn: Better? :)
              – Mike Spivey
              Sep 18 '15 at 23:15














            up vote
            10
            down vote













            There's a shorter way even than the two in Brian's nice answer. Starting from the recurrence $D_n = n D_n-1 + (-1)^n$, multiply by $x^n/n!$ and sum over $n geq 1$ to get
            beginalign
            &sum_n geq 1 D_n fracx^nn! = sum_n geq 1 n D_n-1 fracx^nn! + sum_n geq 1 (-1)^n fracx^nn! \
            implies & G_D(x) - 1 = x sum_n geq 1 D_n-1 fracx^n-1(n-1)! + e^-x - 1, text as $D_0 = 1$ \
            implies & G_D(x) = x G_D(x) + e^-x,
            endalign
            which tells you that the exponential generating function is $$G_D(x) = frace^-x1-x.$$






            share|cite|improve this answer






















            • You first have to show that the two recurrences are equivalent.
              – marty cohen
              May 21 '13 at 19:56










            • @martycohen: Well, that depends on what you already know about the derangement numbers. But it is easy to get from the recurrence Brian uses to the one I use. See, for example, this blog post.
              – Mike Spivey
              May 23 '13 at 3:10










            • I just came across this question and noted that using $(9)$ from this answer, we simply need to multiply by $x^n$ and sum for $nge1$ to get $f(x)-1-xf(x)=e^-x-1$ which immediately gives $f(x)=frace^-x1-x$. This is essentially what you have here (+1)
              – robjohn♦
              Sep 18 '15 at 22:46











            • I just noticed that you are summing for $nge0$. What do you use for $D_-1$? Of course, it is being multiplied by $frac00!$, so perhaps we don't need to worry too much, but somehow, it still bothers me.
              – robjohn♦
              Sep 18 '15 at 22:48











            • @robjohn: Better? :)
              – Mike Spivey
              Sep 18 '15 at 23:15












            up vote
            10
            down vote










            up vote
            10
            down vote









            There's a shorter way even than the two in Brian's nice answer. Starting from the recurrence $D_n = n D_n-1 + (-1)^n$, multiply by $x^n/n!$ and sum over $n geq 1$ to get
            beginalign
            &sum_n geq 1 D_n fracx^nn! = sum_n geq 1 n D_n-1 fracx^nn! + sum_n geq 1 (-1)^n fracx^nn! \
            implies & G_D(x) - 1 = x sum_n geq 1 D_n-1 fracx^n-1(n-1)! + e^-x - 1, text as $D_0 = 1$ \
            implies & G_D(x) = x G_D(x) + e^-x,
            endalign
            which tells you that the exponential generating function is $$G_D(x) = frace^-x1-x.$$






            share|cite|improve this answer














            There's a shorter way even than the two in Brian's nice answer. Starting from the recurrence $D_n = n D_n-1 + (-1)^n$, multiply by $x^n/n!$ and sum over $n geq 1$ to get
            beginalign
            &sum_n geq 1 D_n fracx^nn! = sum_n geq 1 n D_n-1 fracx^nn! + sum_n geq 1 (-1)^n fracx^nn! \
            implies & G_D(x) - 1 = x sum_n geq 1 D_n-1 fracx^n-1(n-1)! + e^-x - 1, text as $D_0 = 1$ \
            implies & G_D(x) = x G_D(x) + e^-x,
            endalign
            which tells you that the exponential generating function is $$G_D(x) = frace^-x1-x.$$







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Sep 18 '15 at 23:14

























            answered Feb 13 '13 at 22:45









            Mike Spivey

            41.4k8135225




            41.4k8135225











            • You first have to show that the two recurrences are equivalent.
              – marty cohen
              May 21 '13 at 19:56










            • @martycohen: Well, that depends on what you already know about the derangement numbers. But it is easy to get from the recurrence Brian uses to the one I use. See, for example, this blog post.
              – Mike Spivey
              May 23 '13 at 3:10










            • I just came across this question and noted that using $(9)$ from this answer, we simply need to multiply by $x^n$ and sum for $nge1$ to get $f(x)-1-xf(x)=e^-x-1$ which immediately gives $f(x)=frace^-x1-x$. This is essentially what you have here (+1)
              – robjohn♦
              Sep 18 '15 at 22:46











            • I just noticed that you are summing for $nge0$. What do you use for $D_-1$? Of course, it is being multiplied by $frac00!$, so perhaps we don't need to worry too much, but somehow, it still bothers me.
              – robjohn♦
              Sep 18 '15 at 22:48











            • @robjohn: Better? :)
              – Mike Spivey
              Sep 18 '15 at 23:15
















            • You first have to show that the two recurrences are equivalent.
              – marty cohen
              May 21 '13 at 19:56










            • @martycohen: Well, that depends on what you already know about the derangement numbers. But it is easy to get from the recurrence Brian uses to the one I use. See, for example, this blog post.
              – Mike Spivey
              May 23 '13 at 3:10










            • I just came across this question and noted that using $(9)$ from this answer, we simply need to multiply by $x^n$ and sum for $nge1$ to get $f(x)-1-xf(x)=e^-x-1$ which immediately gives $f(x)=frace^-x1-x$. This is essentially what you have here (+1)
              – robjohn♦
              Sep 18 '15 at 22:46











            • I just noticed that you are summing for $nge0$. What do you use for $D_-1$? Of course, it is being multiplied by $frac00!$, so perhaps we don't need to worry too much, but somehow, it still bothers me.
              – robjohn♦
              Sep 18 '15 at 22:48











            • @robjohn: Better? :)
              – Mike Spivey
              Sep 18 '15 at 23:15















            You first have to show that the two recurrences are equivalent.
            – marty cohen
            May 21 '13 at 19:56




            You first have to show that the two recurrences are equivalent.
            – marty cohen
            May 21 '13 at 19:56












            @martycohen: Well, that depends on what you already know about the derangement numbers. But it is easy to get from the recurrence Brian uses to the one I use. See, for example, this blog post.
            – Mike Spivey
            May 23 '13 at 3:10




            @martycohen: Well, that depends on what you already know about the derangement numbers. But it is easy to get from the recurrence Brian uses to the one I use. See, for example, this blog post.
            – Mike Spivey
            May 23 '13 at 3:10












            I just came across this question and noted that using $(9)$ from this answer, we simply need to multiply by $x^n$ and sum for $nge1$ to get $f(x)-1-xf(x)=e^-x-1$ which immediately gives $f(x)=frace^-x1-x$. This is essentially what you have here (+1)
            – robjohn♦
            Sep 18 '15 at 22:46





            I just came across this question and noted that using $(9)$ from this answer, we simply need to multiply by $x^n$ and sum for $nge1$ to get $f(x)-1-xf(x)=e^-x-1$ which immediately gives $f(x)=frace^-x1-x$. This is essentially what you have here (+1)
            – robjohn♦
            Sep 18 '15 at 22:46













            I just noticed that you are summing for $nge0$. What do you use for $D_-1$? Of course, it is being multiplied by $frac00!$, so perhaps we don't need to worry too much, but somehow, it still bothers me.
            – robjohn♦
            Sep 18 '15 at 22:48





            I just noticed that you are summing for $nge0$. What do you use for $D_-1$? Of course, it is being multiplied by $frac00!$, so perhaps we don't need to worry too much, but somehow, it still bothers me.
            – robjohn♦
            Sep 18 '15 at 22:48













            @robjohn: Better? :)
            – Mike Spivey
            Sep 18 '15 at 23:15




            @robjohn: Better? :)
            – Mike Spivey
            Sep 18 '15 at 23:15










            up vote
            8
            down vote













            Yet another couple of ways.



            Method 1.
            $$mathcalD = operatornameSscriptsize ET(operatornameCscriptsize YC_> 1) implies D(z) = expleft(ln frac11-z - zright) = frace^-z1-z.$$



            Explanation: A derangement, a permutation with no fixed points, is a set of cycles each containing more than one element. The EGF for such cycles can be got by either taking the known EGF for all cycles, namely $C(z) = lnfrac11-z$, and subtracting the term "$z$" that corresponds to the unique cycle of length $1$, or, if you don't know $C(z)$, with explicit counting as
            $$C_>1(z) = sum_n ge 2 (n-1)! fracz^nn! = sum_nge 2fracz^nn = ln frac11-z - z$$



            And as derangements are sets of such cycles, their EGF is the exponential of the EGF of such cycles. (This set→exp-of-EGFs fact is also known as the exponential formula.)




            Note that the above aproach also easily gives the generating function for the number of permutations with all cycles of length greater than $r$ for any $r$ (derangements is the $r=1$ case): it's
            $$D_r(z) = expleft(sum_n > r fracz^rrright) = frace^-z-z^2/2 - dots - z^r/r1-z.$$
            Of course, the $r=0$ case simply gives the EGF of all permutations, $explnfrac11-z = frac11-z$, as expected.




            Method 2.

            This is a generating-functions analogue of the inclusion-exclusion principle. Though it is overkill for this problem, here it is as an illustration.



            Let $mathcalP$ be the class of all permutations, and let $mathcalQ$ be the class of all permutations with some subset of their fixed-points (possibly none, possibly all) specially distinguished. Viewing it differently, any member of $mathcalQ$ is got by taking an arbitrary permutation and inserting a set of fixed points in it: $mathcalQ = mathcalP star operatornameSscriptsize ET(mathcalZ)$. Using the variable $z$ to mark size and the variable $v$ to mark the distinguished fixed points, we get the (bivariate) EGF $Q(z,v) = frac11-ze^zv$.



            Now if $P(z, u)$ is the EGF for permutations where $z$ marks size and $u$ marks the fixed points, the act of "distinguishing" some of the fixed points corresponds to the substitution $1 + v$ for $u$ in the EGF for permutations: every fixed point (marked by $u$) is either distinguished (marked by $v$) or not (unmarked). So we have $Q(z, v) = P(z, 1 + v)$ or equivalently $P(z, u) = Q(z, u - 1) = dfrace^z(u-1)1-z$. The EGF of derangements is got by setting $u = 0$ in the above:
            $$D(z) = P(z, 0) = frace^-z1-z$$




            This approach also gives the EGF number of permutations with exactly $k$ fixed points, as the coefficient of $u^k$ in the above: it's $dfracz^kk!dfrace^-z1-z$.




            References: Both the above are from the book Analytic Combinatorics by Flajolet and Sedgewick, pp. 122–123 and 207–208 respectively.




            Of course, a simpler observation is that any permutation is a derangement along with a set of fixed points added, so
            $$mathcalP = mathcalD star operatornameSscriptsize ET(mathcalZ)
            implies P(z) = D(z) e^z implies D(z) = frace^-z1-z
            $$
            which is the same as Brian M. Scott's second approach and vonbrand's answer.






            share|cite|improve this answer
























              up vote
              8
              down vote













              Yet another couple of ways.



              Method 1.
              $$mathcalD = operatornameSscriptsize ET(operatornameCscriptsize YC_> 1) implies D(z) = expleft(ln frac11-z - zright) = frace^-z1-z.$$



              Explanation: A derangement, a permutation with no fixed points, is a set of cycles each containing more than one element. The EGF for such cycles can be got by either taking the known EGF for all cycles, namely $C(z) = lnfrac11-z$, and subtracting the term "$z$" that corresponds to the unique cycle of length $1$, or, if you don't know $C(z)$, with explicit counting as
              $$C_>1(z) = sum_n ge 2 (n-1)! fracz^nn! = sum_nge 2fracz^nn = ln frac11-z - z$$



              And as derangements are sets of such cycles, their EGF is the exponential of the EGF of such cycles. (This set→exp-of-EGFs fact is also known as the exponential formula.)




              Note that the above aproach also easily gives the generating function for the number of permutations with all cycles of length greater than $r$ for any $r$ (derangements is the $r=1$ case): it's
              $$D_r(z) = expleft(sum_n > r fracz^rrright) = frace^-z-z^2/2 - dots - z^r/r1-z.$$
              Of course, the $r=0$ case simply gives the EGF of all permutations, $explnfrac11-z = frac11-z$, as expected.




              Method 2.

              This is a generating-functions analogue of the inclusion-exclusion principle. Though it is overkill for this problem, here it is as an illustration.



              Let $mathcalP$ be the class of all permutations, and let $mathcalQ$ be the class of all permutations with some subset of their fixed-points (possibly none, possibly all) specially distinguished. Viewing it differently, any member of $mathcalQ$ is got by taking an arbitrary permutation and inserting a set of fixed points in it: $mathcalQ = mathcalP star operatornameSscriptsize ET(mathcalZ)$. Using the variable $z$ to mark size and the variable $v$ to mark the distinguished fixed points, we get the (bivariate) EGF $Q(z,v) = frac11-ze^zv$.



              Now if $P(z, u)$ is the EGF for permutations where $z$ marks size and $u$ marks the fixed points, the act of "distinguishing" some of the fixed points corresponds to the substitution $1 + v$ for $u$ in the EGF for permutations: every fixed point (marked by $u$) is either distinguished (marked by $v$) or not (unmarked). So we have $Q(z, v) = P(z, 1 + v)$ or equivalently $P(z, u) = Q(z, u - 1) = dfrace^z(u-1)1-z$. The EGF of derangements is got by setting $u = 0$ in the above:
              $$D(z) = P(z, 0) = frace^-z1-z$$




              This approach also gives the EGF number of permutations with exactly $k$ fixed points, as the coefficient of $u^k$ in the above: it's $dfracz^kk!dfrace^-z1-z$.




              References: Both the above are from the book Analytic Combinatorics by Flajolet and Sedgewick, pp. 122–123 and 207–208 respectively.




              Of course, a simpler observation is that any permutation is a derangement along with a set of fixed points added, so
              $$mathcalP = mathcalD star operatornameSscriptsize ET(mathcalZ)
              implies P(z) = D(z) e^z implies D(z) = frace^-z1-z
              $$
              which is the same as Brian M. Scott's second approach and vonbrand's answer.






              share|cite|improve this answer






















                up vote
                8
                down vote










                up vote
                8
                down vote









                Yet another couple of ways.



                Method 1.
                $$mathcalD = operatornameSscriptsize ET(operatornameCscriptsize YC_> 1) implies D(z) = expleft(ln frac11-z - zright) = frace^-z1-z.$$



                Explanation: A derangement, a permutation with no fixed points, is a set of cycles each containing more than one element. The EGF for such cycles can be got by either taking the known EGF for all cycles, namely $C(z) = lnfrac11-z$, and subtracting the term "$z$" that corresponds to the unique cycle of length $1$, or, if you don't know $C(z)$, with explicit counting as
                $$C_>1(z) = sum_n ge 2 (n-1)! fracz^nn! = sum_nge 2fracz^nn = ln frac11-z - z$$



                And as derangements are sets of such cycles, their EGF is the exponential of the EGF of such cycles. (This set→exp-of-EGFs fact is also known as the exponential formula.)




                Note that the above aproach also easily gives the generating function for the number of permutations with all cycles of length greater than $r$ for any $r$ (derangements is the $r=1$ case): it's
                $$D_r(z) = expleft(sum_n > r fracz^rrright) = frace^-z-z^2/2 - dots - z^r/r1-z.$$
                Of course, the $r=0$ case simply gives the EGF of all permutations, $explnfrac11-z = frac11-z$, as expected.




                Method 2.

                This is a generating-functions analogue of the inclusion-exclusion principle. Though it is overkill for this problem, here it is as an illustration.



                Let $mathcalP$ be the class of all permutations, and let $mathcalQ$ be the class of all permutations with some subset of their fixed-points (possibly none, possibly all) specially distinguished. Viewing it differently, any member of $mathcalQ$ is got by taking an arbitrary permutation and inserting a set of fixed points in it: $mathcalQ = mathcalP star operatornameSscriptsize ET(mathcalZ)$. Using the variable $z$ to mark size and the variable $v$ to mark the distinguished fixed points, we get the (bivariate) EGF $Q(z,v) = frac11-ze^zv$.



                Now if $P(z, u)$ is the EGF for permutations where $z$ marks size and $u$ marks the fixed points, the act of "distinguishing" some of the fixed points corresponds to the substitution $1 + v$ for $u$ in the EGF for permutations: every fixed point (marked by $u$) is either distinguished (marked by $v$) or not (unmarked). So we have $Q(z, v) = P(z, 1 + v)$ or equivalently $P(z, u) = Q(z, u - 1) = dfrace^z(u-1)1-z$. The EGF of derangements is got by setting $u = 0$ in the above:
                $$D(z) = P(z, 0) = frace^-z1-z$$




                This approach also gives the EGF number of permutations with exactly $k$ fixed points, as the coefficient of $u^k$ in the above: it's $dfracz^kk!dfrace^-z1-z$.




                References: Both the above are from the book Analytic Combinatorics by Flajolet and Sedgewick, pp. 122–123 and 207–208 respectively.




                Of course, a simpler observation is that any permutation is a derangement along with a set of fixed points added, so
                $$mathcalP = mathcalD star operatornameSscriptsize ET(mathcalZ)
                implies P(z) = D(z) e^z implies D(z) = frace^-z1-z
                $$
                which is the same as Brian M. Scott's second approach and vonbrand's answer.






                share|cite|improve this answer












                Yet another couple of ways.



                Method 1.
                $$mathcalD = operatornameSscriptsize ET(operatornameCscriptsize YC_> 1) implies D(z) = expleft(ln frac11-z - zright) = frace^-z1-z.$$



                Explanation: A derangement, a permutation with no fixed points, is a set of cycles each containing more than one element. The EGF for such cycles can be got by either taking the known EGF for all cycles, namely $C(z) = lnfrac11-z$, and subtracting the term "$z$" that corresponds to the unique cycle of length $1$, or, if you don't know $C(z)$, with explicit counting as
                $$C_>1(z) = sum_n ge 2 (n-1)! fracz^nn! = sum_nge 2fracz^nn = ln frac11-z - z$$



                And as derangements are sets of such cycles, their EGF is the exponential of the EGF of such cycles. (This set→exp-of-EGFs fact is also known as the exponential formula.)




                Note that the above aproach also easily gives the generating function for the number of permutations with all cycles of length greater than $r$ for any $r$ (derangements is the $r=1$ case): it's
                $$D_r(z) = expleft(sum_n > r fracz^rrright) = frace^-z-z^2/2 - dots - z^r/r1-z.$$
                Of course, the $r=0$ case simply gives the EGF of all permutations, $explnfrac11-z = frac11-z$, as expected.




                Method 2.

                This is a generating-functions analogue of the inclusion-exclusion principle. Though it is overkill for this problem, here it is as an illustration.



                Let $mathcalP$ be the class of all permutations, and let $mathcalQ$ be the class of all permutations with some subset of their fixed-points (possibly none, possibly all) specially distinguished. Viewing it differently, any member of $mathcalQ$ is got by taking an arbitrary permutation and inserting a set of fixed points in it: $mathcalQ = mathcalP star operatornameSscriptsize ET(mathcalZ)$. Using the variable $z$ to mark size and the variable $v$ to mark the distinguished fixed points, we get the (bivariate) EGF $Q(z,v) = frac11-ze^zv$.



                Now if $P(z, u)$ is the EGF for permutations where $z$ marks size and $u$ marks the fixed points, the act of "distinguishing" some of the fixed points corresponds to the substitution $1 + v$ for $u$ in the EGF for permutations: every fixed point (marked by $u$) is either distinguished (marked by $v$) or not (unmarked). So we have $Q(z, v) = P(z, 1 + v)$ or equivalently $P(z, u) = Q(z, u - 1) = dfrace^z(u-1)1-z$. The EGF of derangements is got by setting $u = 0$ in the above:
                $$D(z) = P(z, 0) = frace^-z1-z$$




                This approach also gives the EGF number of permutations with exactly $k$ fixed points, as the coefficient of $u^k$ in the above: it's $dfracz^kk!dfrace^-z1-z$.




                References: Both the above are from the book Analytic Combinatorics by Flajolet and Sedgewick, pp. 122–123 and 207–208 respectively.




                Of course, a simpler observation is that any permutation is a derangement along with a set of fixed points added, so
                $$mathcalP = mathcalD star operatornameSscriptsize ET(mathcalZ)
                implies P(z) = D(z) e^z implies D(z) = frace^-z1-z
                $$
                which is the same as Brian M. Scott's second approach and vonbrand's answer.







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Jan 20 '14 at 5:48









                ShreevatsaR

                33.8k566101




                33.8k566101






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f240357%2fexponential-generating-function-for-derangements%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    這個網誌中的熱門文章

                    How to combine Bézier curves to a surface?

                    Carbon dioxide

                    Why am i infinitely getting the same tweet with the Twitter Search API?