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.

A186370 Triangle read by rows: T(n,k) is the number of permutations of {1,2,...,n} having k up-down runs (1 <= k <= n).

Original entry on oeis.org

1, 1, 1, 1, 3, 2, 1, 7, 11, 5, 1, 15, 43, 45, 16, 1, 31, 148, 268, 211, 61, 1, 63, 480, 1344, 1767, 1113, 272, 1, 127, 1509, 6171, 12099, 12477, 6551, 1385, 1, 255, 4661, 26955, 74211, 111645, 94631, 42585, 7936, 1, 511, 14246, 114266, 425976, 878856, 1070906, 770246, 303271, 50521
Offset: 1

Views

Author

Emeric Deutsch and Ira M. Gessel, Mar 01 2011

Keywords

Comments

The up-down runs of a permutation p are the alternating runs of the permutation p endowed with a 0 in the front. For example, 75814632 has 6 up-down runs: 07, 75, 58, 81, 146, and 632.

Examples

			T(3,2) = 3 because we have 132, 231, and 321.
T(4,4) = 5 because we have 13254, 14253, 14352, 15243, and 15342 (the up-down permutations).
Triangle starts:
1;
1,  1;
1,  3,  2;
1,  7, 11,  5;
1, 15, 43, 45, 16;
		

Crossrefs

Row sums give A000142.
T(2n,n) gives A291677, T(2n+1,n+1) gives A303159, T(n,ceiling(n/2)) gives A303160.

Programs

  • Maple
    w := sqrt(1-t^2): G := (w^2+t*w*sinh(z*w))/((1+t)*(1-t*cosh(z*w)))-1: Gser := simplify(series(G, z = 0, 12)): for n to 10 do P[n] := sort(expand(factorial(n)*coeff(Gser, z, n))) end do: for n to 10 do seq(coeff(P[n], t, k), k = 1 .. n) end do; # yields sequence in triangular form
    # second Maple program:
    b:= proc(u, o) option remember; expand(`if`(u+o=0, 1,
           add(b(o+j-1, u-j)*x, j=1..u)+
           add(b(u+j-1, o-j),   j=1..o)))
        end:
    T:= n-> (p-> seq(coeff(p, x, i), i=1..n))(b(n, 0)):
    seq(T(n), n=1..12);  # Alois P. Heinz, Aug 29 2017, Apr 17 2018
  • Mathematica
    b[u_, o_, t_] := b[u, o, t] = Expand[If[u + o == 0, 1, Sum[b[u - j, o + j - 1, 0]*x^t, {j, 1, u}] + Sum[b[u + j - 1, o - j, 1]*x^(1-t), {j, 1, o}]]];
    T[n_] := Function[p, Table[Coefficient[p, x, i], {i, 1, n}]][b[0, n, 0]];
    Table[T[n], {n, 1, 12}] // Flatten (* Jean-François Alcover, Nov 06 2017, after Alois P. Heinz *)
  • Sage
    @CachedFunction
    def A186370(n, k):
        if n == 0 or  k == 0: return 0
        if n == 1 and k == 1: return 1
        return k*A186370(n-1, k) + A186370(n-1, k-1) + (n-k+1)*A186370(n-1, k-2)
    for n in (1..7): [A186370(n, k) for k in (1..n)] # Peter Luschny, Apr 18 2014

Formula

T(n,2) = 2^{n-1}-1 = A000225(n-1).
T(n,n) = A000111(n) (the Euler or up-down numbers).
Sum_{k=1..n} k*T(n,k) = A186371(n).
E.g.f.: G(t,z) = Sum_{n>=1} Sum_{k>=1} T(n,k) * t^k * z^n / n! = (w^2 + tw*sinh(zw))/[(1+t)(1-t*cosh(zw))]-1, where w=sqrt(1-t^2).
The e.g.f. G(t,z) satisfies the linear homogeneous partial differential equation (1-t^2*z)(dG/dz)-t(1-t^2)dG/dt = tG; G(0,z)=1.
Recurrence: T(n,k) = k*T(n-1,k) + T(n-1,k-1) + (n-k+1)*T(n-1,k-2); T(n,0) = T(0,k) = 0, T(1,1) = 1.

A291677 Number of permutations p of [2n] such that 0p has exactly n alternating runs.

Original entry on oeis.org

1, 1, 7, 148, 6171, 425976, 43979902, 6346283560, 1219725741715, 301190499710320, 92921064554444490, 35025128774218944648, 15838288022236083603486, 8462453158197423495502224, 5274234568391796228927038748, 3792391176672742840187796835728
Offset: 0

Views

Author

Alois P. Heinz, Aug 29 2017

Keywords

Examples

			a(2) = 7: 1243, 1342, 1432, 2341, 2431, 3421, 4321.
		

Crossrefs

Cf. A186370.
Bisection (even part) of A303160.

Programs

  • Maple
    b:= proc(n, k) option remember; `if`(k=0,
          `if`(n=0, 1, 0), `if`(k<0 or k>n, 0,
           k*b(n-1, k)+b(n-1, k-1)+(n-k+1)*b(n-1, k-2)))
        end:
    a:= n-> b(2*n, n):
    seq(a(n), n=0..20);
  • Mathematica
    b[n_, k_] := b[n, k] = If[k == 0, If[n == 0, 1, 0], If[k < 0 || k > n, 0, k*b[n - 1, k] + b[n - 1, k - 1] + (n - k + 1)*b[n - 1, k - 2]]];
    a[n_] := b[2*n, n]; Table[a[n], {n, 0, 20}] (* Jean-François Alcover, May 30 2019, after Alois P. Heinz *)
  • Python
    from sympy.core.cache import cacheit
    @cacheit
    def b(n, k): return (1 if n==0 else 0) if k==0 else 0 if k<0 or k>n else k*b(n - 1, k) + b(n - 1, k - 1) + (n - k + 1)*b(n - 1, k - 2)
    def a(n): return b(2*n, n)
    print([a(n) for n in range(31)]) # Indranil Ghosh, Aug 30 2017

Formula

a(n) = A186370(2n,n).
a(n) ~ c * d^n * n! * (n-1)!, where d = 3.4210546206711870249402157940795853513... and c = 0.32723781013647536133280275922604008889245... - Vaclav Kotesovec, Apr 29 2018

A303159 Number of permutations p of [2n+1] such that 0p has exactly n+1 alternating runs.

Original entry on oeis.org

1, 3, 43, 1344, 74211, 6384708, 789649750, 132789007200, 29145283614115, 8092186932120060, 2772830282722806978, 1149343084932146388144, 566844242187778610648334, 328043720353943611689811272, 220147053200818211779539712908, 169580070210721829547034445169024
Offset: 0

Views

Author

Alois P. Heinz, Apr 19 2018

Keywords

Examples

			a(1) = 3: 132, 231, 321.
		

Crossrefs

Bisection (odd part) of A303160.
Cf. A186370.

Programs

  • Maple
    b:= proc(n, k) option remember; `if`(k=0,
          `if`(n=0, 1, 0), `if`(k<0 or k>n, 0,
           k*b(n-1, k)+b(n-1, k-1)+(n-k+1)*b(n-1, k-2)))
        end:
    a:= n-> b(2*n+1, n+1):
    seq(a(n), n=0..20);
  • Mathematica
    b[n_, k_] := b[n, k] = If[k == 0,
        If[n == 0, 1, 0], If[k < 0 || k > n, 0,
        k b[n-1, k] + b[n-1, k-1] + (n-k+1) b[n-1, k-2]]];
    a[n_] := b[2n+1, n+1];
    a /@ Range[0, 20] (* Jean-François Alcover, Dec 21 2020, after Alois P. Heinz *)

Formula

a(n) = A186370(2n+1,n+1).
a(n) ~ c * d^n * n!^2, where d = 3.4210546206711870249402157940795853513031388... and c = 0.974460718185930534652526741942010711752... - Vaclav Kotesovec, Apr 29 2018
Showing 1-3 of 3 results.