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.

A162979 Triangle read by rows: T(n,k) is the number of alternating (i.e., down-up) permutations of {1,2,...,n} having k fixed points (n >= 0, 0 <= k <= ceiling(n/2)).

Original entry on oeis.org

1, 0, 1, 1, 0, 1, 1, 0, 2, 2, 1, 6, 6, 3, 1, 24, 24, 11, 2, 102, 102, 51, 15, 2, 528, 528, 252, 68, 9, 2952, 2952, 1476, 458, 89, 9, 19008, 19008, 9240, 2728, 493, 44, 131112, 131112, 65556, 20868, 4479, 621, 44, 1009728, 1009728, 495360, 152448, 31182, 4054, 265, 8271792, 8271792, 4135896, 1334928, 300954, 47670, 4959, 265
Offset: 0

Views

Author

Emeric Deutsch, Aug 06 2009

Keywords

Comments

Sum of entries in row n is the Euler (up-down) number A000111(n).
T(n,0) = T(n,1) = A129817(n) (n>=1).
T(2n,n) = T(2n+1,n+1) = d(n), where d(n) = A000166 is a derangement number (see the Chapman & Williams reference).
Sum_{k>=0} k*T(n,k) = A162978(n).

Examples

			T(5,2)=3 because we have 32415, 41325, and 52314.
Triangle starts:
    1;
    0,   1;
    1,   0;
    1,   1,   0;
    2,   2,   1;
    6,   6,   3,   1;
   24,  24,  11,   2;
  102, 102,  51,  15,   2;
		

Crossrefs

Programs

  • Maple
    fo := exp(E*(arctan(q*t)-arctan(t)))/(1-E*t): fe := sqrt((1+t^2)/(1+q^2*t^2))*exp(E*(arctan(q*t)-arctan(t)))/(1-E*t): foser := simplify(series(fo, t = 0, 18)): feser := simplify(series(fe, t = 0, 18)): Q := proc (n) if `mod`(n, 2) = 1 then coeff(foser, t, n) else coeff(feser, t, n) end if end proc: for n from 0 to 16 do Q(n) end do: g := sec(x)+tan(x): gser := series(g, x = 0, 20): for n from 0 to 18 do a[n] := factorial(n)*coeff(gser, x, n) end do: for n from 0 to 15 do P[n] := sort(subs({E^14 = a[14], E^15 = a[15], E^16 = a[16], E = a[1], E^2 = a[2], E^3 = a[3], E^4 = a[4], E^5 = a[5], E^6 = a[6], E^7 = a[7], E^8 = a[8], E^9 = a[9], E^10 = a[10], E^11 = a[11], E^12 = a[12], E^13 = a[13]}, Q(n))) end do: for n from 0 to 13 do seq(coeff(P[n], q, j), j = 0 .. ceil((1/2)*n)) end do;
  • Mathematica
    nmax = 13;
    fo = Exp[e*(ArcTan[q*t] - ArcTan[t])]/(1 - e*t);
    fe = Sqrt[(1+t^2)/(1+q^2*t^2)]*Exp[e*(ArcTan[q*t] - ArcTan[t])]/(1-e*t);
    Q[n_] := If [OddQ[n], SeriesCoefficient[fo, {t, 0, n}],  SeriesCoefficient[fe, {t, 0, n}]] // Expand;
    a[n_] := n!*SeriesCoefficient[Sec[x] + Tan[x], {x, 0, n}];
    P[n_] := (Q[n] /. e^k_Integer :> a[k]) /. e :> a[1] // Expand;
    Table[Switch[n, 0, {1}, 1, {0, 1}, 2, {1, 0}, 3, {1, 1, 0}, , CoefficientList[P[n], q]] , {n, 0, nmax}] // Flatten (* _Jean-François Alcover, Jul 23 2018, from Maple *)

Formula

The row generating polynomials can be obtained from Proposition 6.1 of the Stanley reference (see the Maple program).

A162977 Number of fixed points in all reverse alternating (i.e., up-down) permutations of {1,2,...,n}.

Original entry on oeis.org

1, 2, 1, 4, 15, 62, 257, 1384, 7679, 50522, 346113, 2702764, 22022143, 199360982, 1881735169, 19391512144, 207983607807, 2404879675442, 28880901505025, 370371188237524, 4922617151619071, 69348874393137902, 1010501269355233281
Offset: 1

Views

Author

Emeric Deutsch, Aug 06 2009

Keywords

Comments

a(n) = Sum_{k>=0} k*A162980(n,k).
a(2n+1) = A162978(2n+1).

Examples

			a(4) = 4 because in the 5 (=A000111(4)) up-down permutations of {1,2,3,4}, namely 1423, 1324, 3412, 2413, and 2314, we have a total of 1+2+0+0+1=4 fixed points.
		

Crossrefs

Programs

  • Maple
    E := sec(x)+tan(x): Eser := series(E, x = 0, 30): for n from 0 to 27 do E[n] := factorial(n)*coeff(Eser, x, n) end do: for n to 12 do a[2*n] := E[2*n]-(-1)^n end do: for n from 0 to 12 do a[2*n+1] := add((-1)^j*E[2*n+1-2*j], j = 0 .. n) end do: seq(a[n], n = 1 .. 25);
    # second Maple program:
    b:= proc(u, o) option remember; `if`(u+o=0, 1,
          add(b(o-1+j, u-j), j=1..u))
        end:
    a:= proc(n) option remember; `if`(irem(n, 2, 'r')=0,
          b(n, 0)-(-1)^r, add((-1)^j*b(n-2*j, 0), j=0..r))
        end:
    seq(a(n), n=1..30);  # Alois P. Heinz, Dec 09 2016
  • Mathematica
    b[u_, o_] := b[u, o] = If[u + o == 0, 1, Sum[b[o - 1 + j, u - j], {j, 1, u}]]; a[n_] := a[n] = If[{q, r} = QuotientRemainder[n, 2]; r == 0, b[n, 0] - (-1)^q, Sum[(-1)^j*b[n - 2*j, 0], {j, 0, q}]]; Table[a[n], {n, 1, 30}] (* Jean-François Alcover, Dec 20 2016, after Alois P. Heinz *)

Formula

a(2n) = E(2n)-(-1)^n; a(2n+1) = Sum_{j=0..n}(-1)^j*E(2n+1-2j), where E(i) = A000111(i) are the Euler (or up-down) numbers.

A303564 Number T(n,k) of derangements of [n] having exactly k peaks; triangle T(n,k), n>=0, 0<=k<=max(0,floor((n-1)/2)), read by rows.

Original entry on oeis.org

1, 0, 1, 1, 1, 3, 6, 5, 33, 6, 11, 152, 102, 21, 663, 1068, 102, 43, 2778, 9060, 2952, 85, 11413, 68250, 50796, 2952, 171, 46332, 477978, 679368, 131112, 341, 186867, 3192192, 7824834, 3349224, 131112, 683, 750878, 20648088, 81751824, 64791576, 8271792
Offset: 0

Views

Author

Alois P. Heinz, Apr 26 2018

Keywords

Examples

			T(5,0) = 5: 51234, 53124, 53214, 54123, 54213.
T(5,1) = 33: 21453, 21534, 23451, 23514, 24513, 24531, 25134, 25413, 25431, 31254, 31452, 31524, 34512, 34521, 35124, 35214, 35412, 35421, 41253, 41523, 41532, 43152, 43251, 43512, 43521, 45123, 45213, 51423, 51432, 53412, 53421, 54132, 54231.
T(5,2) = 6: 23154, 24153, 34152, 34251, 45132, 45231.
Triangle T(n,k) begins:
    1;
    0;
    1;
    1,      1;
    3,      6;
    5,     33,        6;
   11,    152,      102;
   21,    663,     1068,      102;
   43,   2778,     9060,     2952;
   85,  11413,    68250,    50796,     2952;
  171,  46332,   477978,   679368,   131112;
  341, 186867,  3192192,  7824834,  3349224,  131112;
  683, 750878, 20648088, 81751824, 64791576, 8271792;
		

Crossrefs

Columns k=0-1 give: A001045(n-1) for n>0, A301272.
Row sums give A000166.
Cf. A008303 (the same for permutations), A004526, A129815, A129817, A162979, A162980, A216963, A303648 (the same for involutions).

Programs

  • Maple
    b:= proc(s, i, j) option remember; expand(`if`(s={}, 1, add(
          `if`(k=nops(s), 0, b(s minus {k}, `if`(j>k, 0, j), k)*
          `if`(i>0 and j>0 and ik, x, 1)), k=s)))
        end:
    T:= n-> (p-> seq(coeff(p, x, i), i=0..max(0, degree(p))))(b({$1..n}, 0$2)):
    seq(T(n), n=0..12);
  • Mathematica
    b[s_, i_, j_] := b[s, i, j] = Expand[If[s == {}, 1, Sum[If[k == Length[s], 0, b[s ~Complement~ {k}, If[j > k, 0, j], k]*If[i > 0 && j > 0 && i < j && j > k, x, 1]], {k, s}]]];
    T[n_] := Function[p, Table[Coefficient[p, x, i], {i, 0, Max[0, Exponent[p, x]]}]][b[Range[n], 0, 0]];
    Table[T[n], {n, 0, 12}] // Flatten (* Jean-François Alcover, May 31 2018, from Maple *)

Formula

T(2*n+1,n) = A129815(2*n+1) = A129817(2*n+1) = A162979(2*n+1,0) = A162980(2*n+1,0).
Showing 1-3 of 3 results.