cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-3 of 3 results.

A080936 Triangle read by rows: T(n,k) is the number of Dyck paths of semilength n and height k (1 <= k <= n).

Original entry on oeis.org

1, 1, 1, 1, 3, 1, 1, 7, 5, 1, 1, 15, 18, 7, 1, 1, 31, 57, 33, 9, 1, 1, 63, 169, 132, 52, 11, 1, 1, 127, 482, 484, 247, 75, 13, 1, 1, 255, 1341, 1684, 1053, 410, 102, 15, 1, 1, 511, 3669, 5661, 4199, 1975, 629, 133, 17, 1, 1, 1023, 9922, 18579, 16017, 8778, 3366, 912, 168, 19, 1
Offset: 1

Views

Author

Henry Bottomley, Feb 25 2003

Keywords

Comments

Sum of entries in row n is A000108(n) (the Catalan numbers).
From Gus Wiseman, Nov 16 2022: (Start)
Also the number of unlabeled ordered rooted trees with n nodes and height k. For example, row n = 5 counts the following trees:
(oooo) ((o)oo) (((o))o) ((((o))))
((oo)o) (((o)o))
((ooo)) (((oo)))
(o(o)o) ((o(o)))
(o(oo)) (o((o)))
(oo(o))
((o)(o))
(End)

Examples

			T(3,2)=3 because we have UUDDUD, UDUUDD, and UUDUDD, where U=(1,1) and D=(1,-1). The other two Dyck paths of semilength 3, UDUDUD and UUUDDD, have heights 1 and 3, respectively. - _Emeric Deutsch_, Jun 08 2011
Triangle starts:
  1;
  1,  1;
  1,  3,   1;
  1,  7,   5,   1;
  1, 15,  18,   7,  1;
  1, 31,  57,  33,  9,  1;
  1, 63, 169, 132, 52, 11, 1;
		

References

  • N. G. de Bruijn, D. E. Knuth, and S. O. Rice, The average height of planted plane trees, in: Graph Theory and Computing (ed. T. C. Read), Academic Press, New York, 1972, pp. 15-22.

Crossrefs

T(2n,n) gives A268316.
Counting by leaves instead of height gives A001263.
The unordered version is A034781.
The height statistic is ranked by A358379, unordered A109082.

Programs

  • Maple
    f := proc (k) options operator, arrow:
       sum(binomial(k-i, i)*(-z)^i, i = 0 .. floor((1/2)*k))
    end proc:
    h := proc (k) options operator, arrow:
       z^k/(f(k)*f(k+1))
    end proc:
    T := proc (n, k) options operator, arrow:
       coeff(series(h(k), z = 0, 25), z, n)
    end proc:
    for n to 11 do seq(T(n, k), k = 1 .. n) end do; # yields sequence in triangular form Emeric Deutsch, Jun 08 2011
    # second Maple program:
    b:= proc(x, y, k) option remember; `if`(y>min(k, x) or y<0, 0,
          `if`(x=0, 1, b(x-1, y-1, k)+ b(x-1, y+1, k)))
        end:
    T:= (n, k)-> b(2*n, 0, k) -`if`(k=0, 0, b(2*n, 0, k-1)):
    seq(seq(T(n, k), k=1..n), n=1..14);  # Alois P. Heinz, Aug 06 2012
  • Mathematica
    b[x_, y_, k_] := b[x, y, k] = If[y > Min[k, x] || y<0, 0, If[x == 0, 1, b[x-1, y-1, k] + b[x-1, y+1, k]]]; T[n_, k_] := b[2*n, 0, k] - If[k == 0, 0, b[2*n, 0, k-1] ]; Table[Table[T[n, k], {k, 1, n}], {n, 1, 14}] // Flatten (* Jean-François Alcover, Feb 26 2015, after Alois P. Heinz *)
    aot[n_]:=If[n==1,{{}},Join@@Table[Tuples[aot/@c],{c,Join@@Permutations/@IntegerPartitions[n-1]}]];
    Table[Length[Select[aot[n],Depth[#]-2==k&]],{n,1,9},{k,1,n-1}] (* Gus Wiseman, Nov 16 2022 *)

Formula

T(n, k) = A080934(n, k) - A080934(n, k-1).
The g.f. for Dyck paths of height k is h(k) = z^k/(f(k)*f(k+1)), where f(k) are Fibonacci type polynomials defined by f(0)=f(1)=1, f(k)=f(k-1)-z*f(k-2) or by f(k) = Sum_{i=0..floor(k/2)} binomial(k-i,i)*(-z)^i. Incidentally, the g.f. for Dyck paths of height at most k is H(k) = f(k)/f(k+1). - Emeric Deutsch, Jun 08 2011
For all n >= 1 and floor((n+1)/2) <= k <= n we have: T(n,k) = 2*(2*k+3)*(2*k^2+6*k+1-3*n)*(2*n)!/((n-k)!*(n+k+3)!). - Gheorghe Coserea, Dec 06 2015
T(n, k) = Sum_{i=1..k-1} (-1)^(i+1) * (Sum_{j=1..n} (Sum_{x=0..n} (-1)^(j+x) * binomial(x+2n-2j+1,x))) * a(k-i); a(1)=1, a(0)=0. - Tim C. Flowers, May 14 2018

A258109 Number of balanced parenthesis expressions of length 2n and depth 3.

Original entry on oeis.org

1, 5, 18, 57, 169, 482, 1341, 3669, 9922, 26609, 70929, 188226, 497845, 1313501, 3459042, 9096393, 23895673, 62721698, 164531565, 431397285, 1130708866, 2962826465, 7761964833, 20331456642, 53249182309, 139449644717, 365166860706, 956185155129, 2503657040137
Offset: 3

Views

Author

Gheorghe Coserea, May 20 2015

Keywords

Comments

a(n) is the number of Dyck paths of length 2n and height 3. For example, a(3) = 1 because there is only one such Dyck path which is UUUDDD. - Ran Pan, Sep 26 2015
a(n) is the number of rooted plane trees with n+1 nodes and height 3 (see example for correspondence). - Gheorghe Coserea, Feb 04 2016

Examples

			For n=4, the a(4) = 5 solutions are
                /\       /\
               /  \        \
LRLLLRRR    /\/    \        \
................................
                /\        |
             /\/  \      / \
LLRLLRRR    /      \        \
................................
              /\/\        |
             /    \       |
LLLRLRRR    /      \     / \
................................
              /\          |
             /  \/\      / \
LLLRRLRR    /      \    /
................................
              /\          /\
             /  \        /
LLLRRRLR    /    \/\    /
		

References

  • S. S. Skiena and M. A. Revilla, Programming Challenges: The Programming Contest Training Manual, Springer, 2006, page 140.

Crossrefs

Column k=3 of A080936.
Column k=2 of A287213.

Programs

  • C
    typedef long long unsigned Integer;
    Integer a(int n)
    {
        int i;
        Integer pow2 = 1, a[3] = {0};
        for (i = 3; i <= n; ++i) {
            a[ i%3 ] = pow2 + 3 * a[ (i-1)%3 ] - a[ (i-2)%3 ];
            pow2 = pow2 * 2;
        }
        return a[ (i-1)%3 ];
    }
    
  • Magma
    I:=[1,5,18,57,169]; [n le 5 select I[n] else 5*Self(n-1) - 7*Self(n-2) + 2*Self(n-3): n in [1..40]]; // Vincenzo Librandi, Sep 26 2015
    
  • Maple
    a:= proc(n) option remember; `if`(n<3, 0,
          `if`(n=3, 1, 2^(n-3) +3*a(n-1) -a(n-2)))
        end:
    seq(a(n), n=3..30);  # Alois P. Heinz, May 20 2015
  • Mathematica
    Join[{1, 5}, LinearRecurrence[{5, -7, 2}, {18, 57, 169}, 30]] (* Vincenzo Librandi, Sep 26 2015 *)
  • PARI
    Vec(-x^3/((2*x-1)*(x^2-3*x+1)) + O(x^100)) \\ Colin Barker, May 24 2015
    
  • PARI
    a(n) = fibonacci(2*n-1) - 2^(n-1)  \\ Gheorghe Coserea, Feb 04 2016

Formula

a(n) = 2^(n-3) + 3 * a(n-1) - a(n-2).
a(n) = 5*a(n-1) - 7*a(n-2) + 2*a(n-3) for n>5. - Colin Barker, May 24 2015
G.f.: -x^3 / ((2*x-1)*(x^2-3*x+1)). - Colin Barker, May 24 2015
a(n) = A000045(2n-1) - A000079(n-1). - Gheorghe Coserea, Feb 04 2016
a(n) = 2^(-1-n)*(-5*4^n - (-5+sqrt(5))*(3+sqrt(5))^n + (3-sqrt(5))^n*(5+sqrt(5))) / 5. - Colin Barker, Jun 05 2017
a(n) = Sum_{i=1..n-1} A061667(i)*(n-1-i) - Tim C. Flowers, May 16 2018

A285197 Expansion of (1-6*x+11*x^2-5*x^3) / ((1-x)*(1-3*x)*(1-3*x+x^2)).

Original entry on oeis.org

1, 1, 2, 6, 20, 67, 221, 717, 2294, 7258, 22760, 70863, 219353, 675769, 2073674, 6342414, 19345052, 58867195, 178779893, 542042565, 1641058046, 4962262306, 14989121072, 45235277511, 136407241265, 411058035697, 1237981634066, 3726531171222, 11212544793764, 33723901952563
Offset: 0

Views

Author

N. J. A. Sloane, Apr 30 2017

Keywords

Crossrefs

Cf. A262600.

Programs

  • Mathematica
    LinearRecurrence[{7,-16,13,-3},{1,1,2,6},30] (* Harvey P. Dale, Apr 01 2018 *)
  • PARI
    Vec((1-6*x+11*x^2-5*x^3) / ((1-x)*(1-3*x)*(1-3*x+x^2)) + O(x^30)) \\ Colin Barker, May 01 2017

Formula

From Colin Barker, May 01 2017: (Start)
a(n) = 7*a(n-1) - 16*a(n-2) + 13*a(n-3) - 3*a(n-4) for n>3.
a(n) = (1/2 + 3^n/2 + (2^(-n)*((3-sqrt(5))^n - (3+sqrt(5))^n)) / sqrt(5)).
(End)
2*a(n) = 1 +3^n -2*A001906(n). - R. J. Mathar, Aug 19 2022
Showing 1-3 of 3 results.