Counting Hexagons in Triangle Grid Recurrence?












6












$begingroup$


(This is from a long finished programming competition)



Consider a triangle grid with side N. How many hexagons can fit into it?



This diagram shows N = 4:





I need a recurrence for it:



I tried the following:



$T_1 = 0$



$T_2 = 0$



$T_3 = 1$



$T_4 = 7$



$T_n = ???$



Using inclusion/exclusion:



$T_n = 3T_{n-1} - 3T_{n-2} + T_{n-3} + 3(n-2) - 2 $



Each part is as follows:



(We consider the count of hexagons that fit in certain sub-triangles of the current triangle)





  1. $3T_{n-1}$ The three n-1 triangles in each corner


  2. $-3T_{n-2}$ The three n-2 triangles touching one side each. These are each double counted in (1), so we subtract one of each.


  3. $T_{n-3}$ The n-3 triangle in the center, this is counted 3-3=0 times from (1) and (2) so we need to add one of them.


  4. $3(n-2)$ The number of hexagons which take up an entire side (and don't fit in any of the above) is n-2. We count this three times for each side.


  5. $-2$ The maximum hexagon is counted three times in (4), so we subtract 2 copies.


However it seems I have made a mistake because for $T_7$ I get 140, whereas the expected answer is 232.



Can anyone see where I have gone wrong?










share|cite|improve this question











$endgroup$

















    6












    $begingroup$


    (This is from a long finished programming competition)



    Consider a triangle grid with side N. How many hexagons can fit into it?



    This diagram shows N = 4:





    I need a recurrence for it:



    I tried the following:



    $T_1 = 0$



    $T_2 = 0$



    $T_3 = 1$



    $T_4 = 7$



    $T_n = ???$



    Using inclusion/exclusion:



    $T_n = 3T_{n-1} - 3T_{n-2} + T_{n-3} + 3(n-2) - 2 $



    Each part is as follows:



    (We consider the count of hexagons that fit in certain sub-triangles of the current triangle)





    1. $3T_{n-1}$ The three n-1 triangles in each corner


    2. $-3T_{n-2}$ The three n-2 triangles touching one side each. These are each double counted in (1), so we subtract one of each.


    3. $T_{n-3}$ The n-3 triangle in the center, this is counted 3-3=0 times from (1) and (2) so we need to add one of them.


    4. $3(n-2)$ The number of hexagons which take up an entire side (and don't fit in any of the above) is n-2. We count this three times for each side.


    5. $-2$ The maximum hexagon is counted three times in (4), so we subtract 2 copies.


    However it seems I have made a mistake because for $T_7$ I get 140, whereas the expected answer is 232.



    Can anyone see where I have gone wrong?










    share|cite|improve this question











    $endgroup$















      6












      6








      6


      3



      $begingroup$


      (This is from a long finished programming competition)



      Consider a triangle grid with side N. How many hexagons can fit into it?



      This diagram shows N = 4:





      I need a recurrence for it:



      I tried the following:



      $T_1 = 0$



      $T_2 = 0$



      $T_3 = 1$



      $T_4 = 7$



      $T_n = ???$



      Using inclusion/exclusion:



      $T_n = 3T_{n-1} - 3T_{n-2} + T_{n-3} + 3(n-2) - 2 $



      Each part is as follows:



      (We consider the count of hexagons that fit in certain sub-triangles of the current triangle)





      1. $3T_{n-1}$ The three n-1 triangles in each corner


      2. $-3T_{n-2}$ The three n-2 triangles touching one side each. These are each double counted in (1), so we subtract one of each.


      3. $T_{n-3}$ The n-3 triangle in the center, this is counted 3-3=0 times from (1) and (2) so we need to add one of them.


      4. $3(n-2)$ The number of hexagons which take up an entire side (and don't fit in any of the above) is n-2. We count this three times for each side.


      5. $-2$ The maximum hexagon is counted three times in (4), so we subtract 2 copies.


      However it seems I have made a mistake because for $T_7$ I get 140, whereas the expected answer is 232.



      Can anyone see where I have gone wrong?










      share|cite|improve this question











      $endgroup$




      (This is from a long finished programming competition)



      Consider a triangle grid with side N. How many hexagons can fit into it?



      This diagram shows N = 4:





      I need a recurrence for it:



      I tried the following:



      $T_1 = 0$



      $T_2 = 0$



      $T_3 = 1$



      $T_4 = 7$



      $T_n = ???$



      Using inclusion/exclusion:



      $T_n = 3T_{n-1} - 3T_{n-2} + T_{n-3} + 3(n-2) - 2 $



      Each part is as follows:



      (We consider the count of hexagons that fit in certain sub-triangles of the current triangle)





      1. $3T_{n-1}$ The three n-1 triangles in each corner


      2. $-3T_{n-2}$ The three n-2 triangles touching one side each. These are each double counted in (1), so we subtract one of each.


      3. $T_{n-3}$ The n-3 triangle in the center, this is counted 3-3=0 times from (1) and (2) so we need to add one of them.


      4. $3(n-2)$ The number of hexagons which take up an entire side (and don't fit in any of the above) is n-2. We count this three times for each side.


      5. $-2$ The maximum hexagon is counted three times in (4), so we subtract 2 copies.


      However it seems I have made a mistake because for $T_7$ I get 140, whereas the expected answer is 232.



      Can anyone see where I have gone wrong?







      combinatorics geometry sequences-and-series






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Jan 7 at 7:27









      Glorfindel

      3,41381930




      3,41381930










      asked Sep 14 '12 at 0:59









      Andrew TomazosAndrew Tomazos

      1,12121531




      1,12121531






















          1 Answer
          1






          active

          oldest

          votes


















          5





          +50







          $begingroup$

          Starting from your idea: By inclusion-exclusion, for $n>3$
          $$tag{1}T_n = X_n +3T_{n-1}-3T_{n-2}+T_{n-3},$$
          where $X_n$ is the number of "full-size" hexagons, i.e. those that touch all three sides. A full-size hexagon is determined by three positive integers $a,b,c$ (the sizes of the small triangles chopped off) with $a+b<n, b+c<n, a+c<n$.



          How many such triples ($a,b,c)$ with $max{a+b,a+c,b+c}<n$ are there for each $n$?
          We shall assume $nge3$.
          There are $n-1choose 2$ possibilities to choose $x,yge 1$ such that $x+y<n$ (think of inserting two separators into the $n-1$ gaps between $n$ pebbles, thus gouping them into $xge1$, $yge1$ and $n-x-yge1$ pebbles). Therefore, there are $n-1choose2$ triples each of the forms $(1,b,c)$ and $(a,1,c)$and $(a,b,1)$. We have to subtract the $n-2$ triples each of the forms $(a,1,1)$, $(1,b,1)$, $(1,1,c)$. Then we have to add back the single triple $(1,1,1)$. What remains are triples $(a,b,c)$ with $a,b,cge2$. By mapping these to $(a-1,b-1,c-1)$ we biject them with the $X_{n-3}$ triples $(x,y,z)$ with $max{x+y,x+z.y+z}<n-2$.
          Therefore
          $$tag{2}X_n = X_{n-2}+3{n-1choose 2}-3(n-2)+1=X_{n-2}+3{n-2choose 2}+1 $$
          This would be the correct count of what corresponds to your (4) and (5). Without going into details, we see that $X_n$ is cubic in $n$, not linear as in your count; so that's where your error comes from.



          We can eliminate $X_n$ by combinig equation $(1)$ with $n$ and $n-2$:
          $$T_n-T_{n-2}=X_n-X_{n-2}+3(T_{n-1}-T_{n-3})-3(T_{n-2}-T_{n-4})+T_{n-3}-T_{n-5},$$
          $$tag{3}T_n = 3T_{n-1}-2T_{n-2}-2T_{n-3}+3T_{n-4}-T_{n-5}+3{n-2choose 2}+1.$$
          Using this recursion and $T_{-2}=ldots=T_2=0$ as starting values, one finds
          $$ T_3=1\
          T_4=7\
          T_5=29\
          T_6=90\
          T_7=232\
          T_8=524\
          T_9=1072\
          vdots
          $$



          The polynomial equation $x^5=3x^4-2x^3-2x^2+3x+1$ has $+1$ as quadruple root and $-1$ as a simple root. This suggests that there is an explicit formula $T_n=a_0+a_1n+a_2n^2+a_3n^3+b(-1)^n$. However, the cubic inhomogenuous part increases the degree so that we shall find an explicit formula
          $$tag{4}T_n=a_0+a_1n+a_2n^2+a_3n^3+a_4n^4+a_5n^5+a_6n^6+b(-1)^n.$$
          The coefficients can be obtained by plugging $(4)$ into $(3)$ and the inital values. It turns out that
          $$ T_n = frac{n^6}{480}-frac{n^4}{192}-frac{n^2}{80}+frac1{128}-frac{(-1)^n}{128}=frac{4n^6 - 10n^4 - 24n^2 + 15-15cdot(-1)^n}{1920}.$$






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            This is correct, thanks. I was fooled by the N=4 case into thinking that all hexagons that touch all three sides must have one side of n-2, which is true for N=4 but not true for higher values of N. For example for N=5 we can have a hexagon that results from chopping off triangles of side 2 removed from each corner of the grid.
            $endgroup$
            – Andrew Tomazos
            Sep 17 '12 at 4:31










          • $begingroup$
            Yeah, the law of small numbers strikes again.
            $endgroup$
            – Hagen von Eitzen
            Sep 17 '12 at 18:08






          • 1




            $begingroup$
            Interesting. By a completely different technique I arrived at the less elegant but equally correct solution $$T_n=frac1{360}(x^6-9x^5+130x^4-1005x^3+4189x^2-9066x+7920);.$$ (@user1131467 may also be interested.)
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 10:56












          • $begingroup$
            @BrianM.Scott: What was your technique?
            $endgroup$
            – Andrew Tomazos
            Sep 21 '12 at 13:02










          • $begingroup$
            I found a reasonable way to count the hexagons with bases on the bottom edge. This gives a recurrence $T_{n+1}=T_n+f(n)$. The function $f(n)$ was a bit messy, but it showed that $T_n$ was polynomial in $n$ of degree at most $6$. The rest was just an application of finite differences, since $f(n)$ allowed easy computation of more than enough values of $T_n$.
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 20:21














          Your Answer








          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%2f195486%2fcounting-hexagons-in-triangle-grid-recurrence%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5





          +50







          $begingroup$

          Starting from your idea: By inclusion-exclusion, for $n>3$
          $$tag{1}T_n = X_n +3T_{n-1}-3T_{n-2}+T_{n-3},$$
          where $X_n$ is the number of "full-size" hexagons, i.e. those that touch all three sides. A full-size hexagon is determined by three positive integers $a,b,c$ (the sizes of the small triangles chopped off) with $a+b<n, b+c<n, a+c<n$.



          How many such triples ($a,b,c)$ with $max{a+b,a+c,b+c}<n$ are there for each $n$?
          We shall assume $nge3$.
          There are $n-1choose 2$ possibilities to choose $x,yge 1$ such that $x+y<n$ (think of inserting two separators into the $n-1$ gaps between $n$ pebbles, thus gouping them into $xge1$, $yge1$ and $n-x-yge1$ pebbles). Therefore, there are $n-1choose2$ triples each of the forms $(1,b,c)$ and $(a,1,c)$and $(a,b,1)$. We have to subtract the $n-2$ triples each of the forms $(a,1,1)$, $(1,b,1)$, $(1,1,c)$. Then we have to add back the single triple $(1,1,1)$. What remains are triples $(a,b,c)$ with $a,b,cge2$. By mapping these to $(a-1,b-1,c-1)$ we biject them with the $X_{n-3}$ triples $(x,y,z)$ with $max{x+y,x+z.y+z}<n-2$.
          Therefore
          $$tag{2}X_n = X_{n-2}+3{n-1choose 2}-3(n-2)+1=X_{n-2}+3{n-2choose 2}+1 $$
          This would be the correct count of what corresponds to your (4) and (5). Without going into details, we see that $X_n$ is cubic in $n$, not linear as in your count; so that's where your error comes from.



          We can eliminate $X_n$ by combinig equation $(1)$ with $n$ and $n-2$:
          $$T_n-T_{n-2}=X_n-X_{n-2}+3(T_{n-1}-T_{n-3})-3(T_{n-2}-T_{n-4})+T_{n-3}-T_{n-5},$$
          $$tag{3}T_n = 3T_{n-1}-2T_{n-2}-2T_{n-3}+3T_{n-4}-T_{n-5}+3{n-2choose 2}+1.$$
          Using this recursion and $T_{-2}=ldots=T_2=0$ as starting values, one finds
          $$ T_3=1\
          T_4=7\
          T_5=29\
          T_6=90\
          T_7=232\
          T_8=524\
          T_9=1072\
          vdots
          $$



          The polynomial equation $x^5=3x^4-2x^3-2x^2+3x+1$ has $+1$ as quadruple root and $-1$ as a simple root. This suggests that there is an explicit formula $T_n=a_0+a_1n+a_2n^2+a_3n^3+b(-1)^n$. However, the cubic inhomogenuous part increases the degree so that we shall find an explicit formula
          $$tag{4}T_n=a_0+a_1n+a_2n^2+a_3n^3+a_4n^4+a_5n^5+a_6n^6+b(-1)^n.$$
          The coefficients can be obtained by plugging $(4)$ into $(3)$ and the inital values. It turns out that
          $$ T_n = frac{n^6}{480}-frac{n^4}{192}-frac{n^2}{80}+frac1{128}-frac{(-1)^n}{128}=frac{4n^6 - 10n^4 - 24n^2 + 15-15cdot(-1)^n}{1920}.$$






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            This is correct, thanks. I was fooled by the N=4 case into thinking that all hexagons that touch all three sides must have one side of n-2, which is true for N=4 but not true for higher values of N. For example for N=5 we can have a hexagon that results from chopping off triangles of side 2 removed from each corner of the grid.
            $endgroup$
            – Andrew Tomazos
            Sep 17 '12 at 4:31










          • $begingroup$
            Yeah, the law of small numbers strikes again.
            $endgroup$
            – Hagen von Eitzen
            Sep 17 '12 at 18:08






          • 1




            $begingroup$
            Interesting. By a completely different technique I arrived at the less elegant but equally correct solution $$T_n=frac1{360}(x^6-9x^5+130x^4-1005x^3+4189x^2-9066x+7920);.$$ (@user1131467 may also be interested.)
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 10:56












          • $begingroup$
            @BrianM.Scott: What was your technique?
            $endgroup$
            – Andrew Tomazos
            Sep 21 '12 at 13:02










          • $begingroup$
            I found a reasonable way to count the hexagons with bases on the bottom edge. This gives a recurrence $T_{n+1}=T_n+f(n)$. The function $f(n)$ was a bit messy, but it showed that $T_n$ was polynomial in $n$ of degree at most $6$. The rest was just an application of finite differences, since $f(n)$ allowed easy computation of more than enough values of $T_n$.
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 20:21


















          5





          +50







          $begingroup$

          Starting from your idea: By inclusion-exclusion, for $n>3$
          $$tag{1}T_n = X_n +3T_{n-1}-3T_{n-2}+T_{n-3},$$
          where $X_n$ is the number of "full-size" hexagons, i.e. those that touch all three sides. A full-size hexagon is determined by three positive integers $a,b,c$ (the sizes of the small triangles chopped off) with $a+b<n, b+c<n, a+c<n$.



          How many such triples ($a,b,c)$ with $max{a+b,a+c,b+c}<n$ are there for each $n$?
          We shall assume $nge3$.
          There are $n-1choose 2$ possibilities to choose $x,yge 1$ such that $x+y<n$ (think of inserting two separators into the $n-1$ gaps between $n$ pebbles, thus gouping them into $xge1$, $yge1$ and $n-x-yge1$ pebbles). Therefore, there are $n-1choose2$ triples each of the forms $(1,b,c)$ and $(a,1,c)$and $(a,b,1)$. We have to subtract the $n-2$ triples each of the forms $(a,1,1)$, $(1,b,1)$, $(1,1,c)$. Then we have to add back the single triple $(1,1,1)$. What remains are triples $(a,b,c)$ with $a,b,cge2$. By mapping these to $(a-1,b-1,c-1)$ we biject them with the $X_{n-3}$ triples $(x,y,z)$ with $max{x+y,x+z.y+z}<n-2$.
          Therefore
          $$tag{2}X_n = X_{n-2}+3{n-1choose 2}-3(n-2)+1=X_{n-2}+3{n-2choose 2}+1 $$
          This would be the correct count of what corresponds to your (4) and (5). Without going into details, we see that $X_n$ is cubic in $n$, not linear as in your count; so that's where your error comes from.



          We can eliminate $X_n$ by combinig equation $(1)$ with $n$ and $n-2$:
          $$T_n-T_{n-2}=X_n-X_{n-2}+3(T_{n-1}-T_{n-3})-3(T_{n-2}-T_{n-4})+T_{n-3}-T_{n-5},$$
          $$tag{3}T_n = 3T_{n-1}-2T_{n-2}-2T_{n-3}+3T_{n-4}-T_{n-5}+3{n-2choose 2}+1.$$
          Using this recursion and $T_{-2}=ldots=T_2=0$ as starting values, one finds
          $$ T_3=1\
          T_4=7\
          T_5=29\
          T_6=90\
          T_7=232\
          T_8=524\
          T_9=1072\
          vdots
          $$



          The polynomial equation $x^5=3x^4-2x^3-2x^2+3x+1$ has $+1$ as quadruple root and $-1$ as a simple root. This suggests that there is an explicit formula $T_n=a_0+a_1n+a_2n^2+a_3n^3+b(-1)^n$. However, the cubic inhomogenuous part increases the degree so that we shall find an explicit formula
          $$tag{4}T_n=a_0+a_1n+a_2n^2+a_3n^3+a_4n^4+a_5n^5+a_6n^6+b(-1)^n.$$
          The coefficients can be obtained by plugging $(4)$ into $(3)$ and the inital values. It turns out that
          $$ T_n = frac{n^6}{480}-frac{n^4}{192}-frac{n^2}{80}+frac1{128}-frac{(-1)^n}{128}=frac{4n^6 - 10n^4 - 24n^2 + 15-15cdot(-1)^n}{1920}.$$






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            This is correct, thanks. I was fooled by the N=4 case into thinking that all hexagons that touch all three sides must have one side of n-2, which is true for N=4 but not true for higher values of N. For example for N=5 we can have a hexagon that results from chopping off triangles of side 2 removed from each corner of the grid.
            $endgroup$
            – Andrew Tomazos
            Sep 17 '12 at 4:31










          • $begingroup$
            Yeah, the law of small numbers strikes again.
            $endgroup$
            – Hagen von Eitzen
            Sep 17 '12 at 18:08






          • 1




            $begingroup$
            Interesting. By a completely different technique I arrived at the less elegant but equally correct solution $$T_n=frac1{360}(x^6-9x^5+130x^4-1005x^3+4189x^2-9066x+7920);.$$ (@user1131467 may also be interested.)
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 10:56












          • $begingroup$
            @BrianM.Scott: What was your technique?
            $endgroup$
            – Andrew Tomazos
            Sep 21 '12 at 13:02










          • $begingroup$
            I found a reasonable way to count the hexagons with bases on the bottom edge. This gives a recurrence $T_{n+1}=T_n+f(n)$. The function $f(n)$ was a bit messy, but it showed that $T_n$ was polynomial in $n$ of degree at most $6$. The rest was just an application of finite differences, since $f(n)$ allowed easy computation of more than enough values of $T_n$.
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 20:21
















          5





          +50







          5





          +50



          5




          +50



          $begingroup$

          Starting from your idea: By inclusion-exclusion, for $n>3$
          $$tag{1}T_n = X_n +3T_{n-1}-3T_{n-2}+T_{n-3},$$
          where $X_n$ is the number of "full-size" hexagons, i.e. those that touch all three sides. A full-size hexagon is determined by three positive integers $a,b,c$ (the sizes of the small triangles chopped off) with $a+b<n, b+c<n, a+c<n$.



          How many such triples ($a,b,c)$ with $max{a+b,a+c,b+c}<n$ are there for each $n$?
          We shall assume $nge3$.
          There are $n-1choose 2$ possibilities to choose $x,yge 1$ such that $x+y<n$ (think of inserting two separators into the $n-1$ gaps between $n$ pebbles, thus gouping them into $xge1$, $yge1$ and $n-x-yge1$ pebbles). Therefore, there are $n-1choose2$ triples each of the forms $(1,b,c)$ and $(a,1,c)$and $(a,b,1)$. We have to subtract the $n-2$ triples each of the forms $(a,1,1)$, $(1,b,1)$, $(1,1,c)$. Then we have to add back the single triple $(1,1,1)$. What remains are triples $(a,b,c)$ with $a,b,cge2$. By mapping these to $(a-1,b-1,c-1)$ we biject them with the $X_{n-3}$ triples $(x,y,z)$ with $max{x+y,x+z.y+z}<n-2$.
          Therefore
          $$tag{2}X_n = X_{n-2}+3{n-1choose 2}-3(n-2)+1=X_{n-2}+3{n-2choose 2}+1 $$
          This would be the correct count of what corresponds to your (4) and (5). Without going into details, we see that $X_n$ is cubic in $n$, not linear as in your count; so that's where your error comes from.



          We can eliminate $X_n$ by combinig equation $(1)$ with $n$ and $n-2$:
          $$T_n-T_{n-2}=X_n-X_{n-2}+3(T_{n-1}-T_{n-3})-3(T_{n-2}-T_{n-4})+T_{n-3}-T_{n-5},$$
          $$tag{3}T_n = 3T_{n-1}-2T_{n-2}-2T_{n-3}+3T_{n-4}-T_{n-5}+3{n-2choose 2}+1.$$
          Using this recursion and $T_{-2}=ldots=T_2=0$ as starting values, one finds
          $$ T_3=1\
          T_4=7\
          T_5=29\
          T_6=90\
          T_7=232\
          T_8=524\
          T_9=1072\
          vdots
          $$



          The polynomial equation $x^5=3x^4-2x^3-2x^2+3x+1$ has $+1$ as quadruple root and $-1$ as a simple root. This suggests that there is an explicit formula $T_n=a_0+a_1n+a_2n^2+a_3n^3+b(-1)^n$. However, the cubic inhomogenuous part increases the degree so that we shall find an explicit formula
          $$tag{4}T_n=a_0+a_1n+a_2n^2+a_3n^3+a_4n^4+a_5n^5+a_6n^6+b(-1)^n.$$
          The coefficients can be obtained by plugging $(4)$ into $(3)$ and the inital values. It turns out that
          $$ T_n = frac{n^6}{480}-frac{n^4}{192}-frac{n^2}{80}+frac1{128}-frac{(-1)^n}{128}=frac{4n^6 - 10n^4 - 24n^2 + 15-15cdot(-1)^n}{1920}.$$






          share|cite|improve this answer









          $endgroup$



          Starting from your idea: By inclusion-exclusion, for $n>3$
          $$tag{1}T_n = X_n +3T_{n-1}-3T_{n-2}+T_{n-3},$$
          where $X_n$ is the number of "full-size" hexagons, i.e. those that touch all three sides. A full-size hexagon is determined by three positive integers $a,b,c$ (the sizes of the small triangles chopped off) with $a+b<n, b+c<n, a+c<n$.



          How many such triples ($a,b,c)$ with $max{a+b,a+c,b+c}<n$ are there for each $n$?
          We shall assume $nge3$.
          There are $n-1choose 2$ possibilities to choose $x,yge 1$ such that $x+y<n$ (think of inserting two separators into the $n-1$ gaps between $n$ pebbles, thus gouping them into $xge1$, $yge1$ and $n-x-yge1$ pebbles). Therefore, there are $n-1choose2$ triples each of the forms $(1,b,c)$ and $(a,1,c)$and $(a,b,1)$. We have to subtract the $n-2$ triples each of the forms $(a,1,1)$, $(1,b,1)$, $(1,1,c)$. Then we have to add back the single triple $(1,1,1)$. What remains are triples $(a,b,c)$ with $a,b,cge2$. By mapping these to $(a-1,b-1,c-1)$ we biject them with the $X_{n-3}$ triples $(x,y,z)$ with $max{x+y,x+z.y+z}<n-2$.
          Therefore
          $$tag{2}X_n = X_{n-2}+3{n-1choose 2}-3(n-2)+1=X_{n-2}+3{n-2choose 2}+1 $$
          This would be the correct count of what corresponds to your (4) and (5). Without going into details, we see that $X_n$ is cubic in $n$, not linear as in your count; so that's where your error comes from.



          We can eliminate $X_n$ by combinig equation $(1)$ with $n$ and $n-2$:
          $$T_n-T_{n-2}=X_n-X_{n-2}+3(T_{n-1}-T_{n-3})-3(T_{n-2}-T_{n-4})+T_{n-3}-T_{n-5},$$
          $$tag{3}T_n = 3T_{n-1}-2T_{n-2}-2T_{n-3}+3T_{n-4}-T_{n-5}+3{n-2choose 2}+1.$$
          Using this recursion and $T_{-2}=ldots=T_2=0$ as starting values, one finds
          $$ T_3=1\
          T_4=7\
          T_5=29\
          T_6=90\
          T_7=232\
          T_8=524\
          T_9=1072\
          vdots
          $$



          The polynomial equation $x^5=3x^4-2x^3-2x^2+3x+1$ has $+1$ as quadruple root and $-1$ as a simple root. This suggests that there is an explicit formula $T_n=a_0+a_1n+a_2n^2+a_3n^3+b(-1)^n$. However, the cubic inhomogenuous part increases the degree so that we shall find an explicit formula
          $$tag{4}T_n=a_0+a_1n+a_2n^2+a_3n^3+a_4n^4+a_5n^5+a_6n^6+b(-1)^n.$$
          The coefficients can be obtained by plugging $(4)$ into $(3)$ and the inital values. It turns out that
          $$ T_n = frac{n^6}{480}-frac{n^4}{192}-frac{n^2}{80}+frac1{128}-frac{(-1)^n}{128}=frac{4n^6 - 10n^4 - 24n^2 + 15-15cdot(-1)^n}{1920}.$$







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Sep 16 '12 at 18:43









          Hagen von EitzenHagen von Eitzen

          283k23273508




          283k23273508












          • $begingroup$
            This is correct, thanks. I was fooled by the N=4 case into thinking that all hexagons that touch all three sides must have one side of n-2, which is true for N=4 but not true for higher values of N. For example for N=5 we can have a hexagon that results from chopping off triangles of side 2 removed from each corner of the grid.
            $endgroup$
            – Andrew Tomazos
            Sep 17 '12 at 4:31










          • $begingroup$
            Yeah, the law of small numbers strikes again.
            $endgroup$
            – Hagen von Eitzen
            Sep 17 '12 at 18:08






          • 1




            $begingroup$
            Interesting. By a completely different technique I arrived at the less elegant but equally correct solution $$T_n=frac1{360}(x^6-9x^5+130x^4-1005x^3+4189x^2-9066x+7920);.$$ (@user1131467 may also be interested.)
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 10:56












          • $begingroup$
            @BrianM.Scott: What was your technique?
            $endgroup$
            – Andrew Tomazos
            Sep 21 '12 at 13:02










          • $begingroup$
            I found a reasonable way to count the hexagons with bases on the bottom edge. This gives a recurrence $T_{n+1}=T_n+f(n)$. The function $f(n)$ was a bit messy, but it showed that $T_n$ was polynomial in $n$ of degree at most $6$. The rest was just an application of finite differences, since $f(n)$ allowed easy computation of more than enough values of $T_n$.
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 20:21




















          • $begingroup$
            This is correct, thanks. I was fooled by the N=4 case into thinking that all hexagons that touch all three sides must have one side of n-2, which is true for N=4 but not true for higher values of N. For example for N=5 we can have a hexagon that results from chopping off triangles of side 2 removed from each corner of the grid.
            $endgroup$
            – Andrew Tomazos
            Sep 17 '12 at 4:31










          • $begingroup$
            Yeah, the law of small numbers strikes again.
            $endgroup$
            – Hagen von Eitzen
            Sep 17 '12 at 18:08






          • 1




            $begingroup$
            Interesting. By a completely different technique I arrived at the less elegant but equally correct solution $$T_n=frac1{360}(x^6-9x^5+130x^4-1005x^3+4189x^2-9066x+7920);.$$ (@user1131467 may also be interested.)
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 10:56












          • $begingroup$
            @BrianM.Scott: What was your technique?
            $endgroup$
            – Andrew Tomazos
            Sep 21 '12 at 13:02










          • $begingroup$
            I found a reasonable way to count the hexagons with bases on the bottom edge. This gives a recurrence $T_{n+1}=T_n+f(n)$. The function $f(n)$ was a bit messy, but it showed that $T_n$ was polynomial in $n$ of degree at most $6$. The rest was just an application of finite differences, since $f(n)$ allowed easy computation of more than enough values of $T_n$.
            $endgroup$
            – Brian M. Scott
            Sep 21 '12 at 20:21


















          $begingroup$
          This is correct, thanks. I was fooled by the N=4 case into thinking that all hexagons that touch all three sides must have one side of n-2, which is true for N=4 but not true for higher values of N. For example for N=5 we can have a hexagon that results from chopping off triangles of side 2 removed from each corner of the grid.
          $endgroup$
          – Andrew Tomazos
          Sep 17 '12 at 4:31




          $begingroup$
          This is correct, thanks. I was fooled by the N=4 case into thinking that all hexagons that touch all three sides must have one side of n-2, which is true for N=4 but not true for higher values of N. For example for N=5 we can have a hexagon that results from chopping off triangles of side 2 removed from each corner of the grid.
          $endgroup$
          – Andrew Tomazos
          Sep 17 '12 at 4:31












          $begingroup$
          Yeah, the law of small numbers strikes again.
          $endgroup$
          – Hagen von Eitzen
          Sep 17 '12 at 18:08




          $begingroup$
          Yeah, the law of small numbers strikes again.
          $endgroup$
          – Hagen von Eitzen
          Sep 17 '12 at 18:08




          1




          1




          $begingroup$
          Interesting. By a completely different technique I arrived at the less elegant but equally correct solution $$T_n=frac1{360}(x^6-9x^5+130x^4-1005x^3+4189x^2-9066x+7920);.$$ (@user1131467 may also be interested.)
          $endgroup$
          – Brian M. Scott
          Sep 21 '12 at 10:56






          $begingroup$
          Interesting. By a completely different technique I arrived at the less elegant but equally correct solution $$T_n=frac1{360}(x^6-9x^5+130x^4-1005x^3+4189x^2-9066x+7920);.$$ (@user1131467 may also be interested.)
          $endgroup$
          – Brian M. Scott
          Sep 21 '12 at 10:56














          $begingroup$
          @BrianM.Scott: What was your technique?
          $endgroup$
          – Andrew Tomazos
          Sep 21 '12 at 13:02




          $begingroup$
          @BrianM.Scott: What was your technique?
          $endgroup$
          – Andrew Tomazos
          Sep 21 '12 at 13:02












          $begingroup$
          I found a reasonable way to count the hexagons with bases on the bottom edge. This gives a recurrence $T_{n+1}=T_n+f(n)$. The function $f(n)$ was a bit messy, but it showed that $T_n$ was polynomial in $n$ of degree at most $6$. The rest was just an application of finite differences, since $f(n)$ allowed easy computation of more than enough values of $T_n$.
          $endgroup$
          – Brian M. Scott
          Sep 21 '12 at 20:21






          $begingroup$
          I found a reasonable way to count the hexagons with bases on the bottom edge. This gives a recurrence $T_{n+1}=T_n+f(n)$. The function $f(n)$ was a bit messy, but it showed that $T_n$ was polynomial in $n$ of degree at most $6$. The rest was just an application of finite differences, since $f(n)$ allowed easy computation of more than enough values of $T_n$.
          $endgroup$
          – Brian M. Scott
          Sep 21 '12 at 20:21




















          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%2f195486%2fcounting-hexagons-in-triangle-grid-recurrence%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

          Wiesbaden

          Marschland

          Dieringhausen