A097805 Number of compositions of n with k parts, T(n, k) = binomial(n-1, k-1) for n, k >= 1 and T(n, 0) = 0^n, triangle read by rows for n >= 0 and 0 <= k <= n.
1, 0, 1, 0, 1, 1, 0, 1, 2, 1, 0, 1, 3, 3, 1, 0, 1, 4, 6, 4, 1, 0, 1, 5, 10, 10, 5, 1, 0, 1, 6, 15, 20, 15, 6, 1, 0, 1, 7, 21, 35, 35, 21, 7, 1, 0, 1, 8, 28, 56, 70, 56, 28, 8, 1, 0, 1, 9, 36, 84, 126, 126, 84, 36, 9, 1, 0, 1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1, 0, 1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1
Offset: 0
A345197 Concatenation of square matrices A(n), each read by rows, where A(n)(k,i) is the number of compositions of n of length k with alternating sum i, where 1 <= k <= n, and i ranges from -n + 2 to n in steps of 2.
1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 2, 3, 0, 0, 2, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 2, 3, 4, 0, 0, 3, 4, 3, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 1, 0, 0, 0
Offset: 0
Comments
The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.
Examples
The matrices for n = 1..7: 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0 0 1 0 0 1 2 0 0 1 2 3 0 0 1 2 3 4 0 0 1 2 3 4 5 0 0 1 0 0 0 2 2 0 0 0 3 4 3 0 0 0 4 6 6 4 0 0 0 0 1 0 0 0 0 2 3 0 0 0 0 3 6 6 0 0 0 0 1 0 0 0 0 0 3 3 0 0 0 0 0 0 1 0 0 0 Matrix n = 5 counts the following compositions: i=-3: i=-1: i=1: i=3: i=5: ----------------------------------------------------------------- k=1: | 0 0 0 0 (5) k=2: | (14) (23) (32) (41) 0 k=3: | 0 (131) (221)(122) (311)(113)(212) 0 k=4: | 0 (1211)(1112) (2111)(1121) 0 0 k=5: | 0 0 (11111) 0 0
Links
- Gus Wiseman, A raster plot of the zeros in A(16).
Crossrefs
The number of nonzero terms in each matrix appears to be A000096.
The number of zeros in each matrix appears to be A000124.
Row sums and column sums both appear to be A007318 (Pascal's triangle).
The matrix sums are A131577.
Antidiagonal sums appear to be A163493.
The reverse-alternating version is also A345197 (this sequence).
Antidiagonals are A345907.
Traces are A345908.
A011782 counts compositions.
A097805 counts compositions by alternating (or reverse-alternating) sum.
A344610 counts partitions by sum and positive reverse-alternating sum.
A344611 counts partitions of 2n with reverse-alternating sum >= 0.
Compositions of n, 2n, or 2n+1 with alternating/reverse-alternating sum k:
Programs
-
Mathematica
ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}]; Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],Length[#]==k&&ats[#]==i&]],{n,0,6},{k,1,n},{i,-n+2,n,2}]
A163493 Number of binary strings of length n which have the same number of 00 and 01 substrings.
1, 2, 2, 3, 6, 9, 15, 30, 54, 97, 189, 360, 675, 1304, 2522, 4835, 9358, 18193, 35269, 68568, 133737, 260802, 509132, 995801, 1948931, 3816904, 7483636, 14683721, 28827798, 56637969, 111347879, 219019294, 431043814, 848764585, 1672056525, 3295390800, 6497536449
Offset: 0
Keywords
Comments
A variation of problem 11424 in the American Mathematical Monthly. Terms were brute-force calculated using Maple 10.
Proposed Problem 11610 in the Dec 2011 A.M.M.
From Gus Wiseman, Jul 27 2021: (Start)
Also the antidiagonal sums of the matrices counting integer compositions by length and alternating sum (A345197). So a(n) is the number of integer compositions of n + 1 of length (n - s + 3)/2, where s is the alternating sum of the composition. For example, the a(0) = 1 through a(6) = 7 compositions are:
(1) (2) (3) (4) (5) (6) (7)
(11) (21) (31) (41) (51) (61)
(121) (122) (123) (124)
(221) (222) (223)
(1112) (321) (322)
(1211) (1122) (421)
(1221) (1132)
(2112) (1231)
(2211) (2122)
(2221)
(3112)
(3211)
(11131)
(12121)
(13111)
For a bijection with the main (binary string) interpretation, take the run-lengths of each binary string of length n + 1 that satisfies the condition and starts with 1.
(End)
Examples
1 + 2*x + 2*x^2 + 3*x^3 + 6*x^4 + 9*x^5 + 15*x^6 + 30*x^7 + 54*x^8 + 97*x^9 + ... From _Gus Wiseman_, Jul 27 2021: (Start) The a(0) = 1 though a(6) = 15 binary strings: () (0) (1,0) (0,0,1) (0,0,1,0) (0,0,1,1,0) (0,0,0,1,0,1) (1) (1,1) (1,1,0) (0,0,1,1) (0,0,1,1,1) (0,0,1,0,0,1) (1,1,1) (0,1,0,0) (0,1,1,0,0) (0,0,1,1,1,0) (1,0,0,1) (1,0,0,1,0) (0,0,1,1,1,1) (1,1,1,0) (1,0,0,1,1) (0,1,0,0,0,1) (1,1,1,1) (1,0,1,0,0) (0,1,1,1,0,0) (1,1,0,0,1) (1,0,0,1,1,0) (1,1,1,1,0) (1,0,0,1,1,1) (1,1,1,1,1) (1,0,1,1,0,0) (1,1,0,0,1,0) (1,1,0,0,1,1) (1,1,0,1,0,0) (1,1,1,0,0,1) (1,1,1,1,1,0) (1,1,1,1,1,1) (End)
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..3328 (first 501 terms from R. H. Hardin)
- Shalosh B. Ekhad and Doron Zeilberger, Automatic Solution of Richard Stanley's Amer. Math. Monthly Problem #11610 and ANY Problem of That Type, arXiv preprint arXiv:1112.6207 [math.CO], 2011. See subpages for rigorous derivations of g.f., recurrence, asymptotics for this sequence. [From _N. J. A. Sloane_, Apr 07 2012]
- R. Stanley, Problem 11610, Amer. Math. Monthly, 118 (2011), 937; 120 (2013), 943-944.
Crossrefs
Antidiagonal sums of the matrices A345197.
Row sums of A345907.
Taking diagonal instead of antidiagonal sums gives A345908.
A011782 counts compositions (or binary strings).
A097805 counts compositions by alternating (or reverse-alternating) sum.
Compositions of n, 2n, or 2n+1 with alternating/reverse-alternating sum k:
Programs
-
Maple
with(combinat): count := proc(n) local S, matches, A, k, i; S := subsets(\{seq(i, i=1..n)\}): matches := 0: while not S[finished] do A := S[nextvalue](): k := 0: for i from 1 to n-1 do: if not (i in A) and not (i+1 in A) then k := k + 1: fi: if not (i in A) and (i+1 in A) then k := k - 1: fi: od: if (k = 0) then matches := matches + 1: fi: end do; return(matches); end proc: # second Maple program: b:= proc(n, l, t) option remember; `if`(n-abs(t)<0, 0, `if`(n=0, 1, add(b(n-1, i, t+`if`(l=0, (-1)^i, 0)), i=0..1))) end: a:= n-> b(n, 1, 0): seq(a(n), n=0..36); # Alois P. Heinz, Mar 20 2024
-
Mathematica
a[0] = 1; a[n_] := Sum[Binomial[2*k - 1, k]*Binomial[n - 2*k, k] + Binomial[2*k, k]*Binomial[n - 2*k - 1, k], {k, 0, n/3}]; Table[a[n], {n, 0, 40}] (* Jean-François Alcover, Nov 28 2017, after Joel B. Lewis *) Table[Length[Select[Tuples[{0,1},n],Count[Partition[#,2,1],{0,0}]==Count[Partition[#,2,1],{0,1}]&]],{n,0,10}] (* Gus Wiseman, Jul 27 2021 *) a[0]:=1; a[n_]:=(1 + 3*HypergeometricPFQ[{1/2, 1-3*n/8, (1-n)/3, (2-n)/3, -n/3},{1, (1-n)/2, 1-n/2, -3*n/8}, -27])/2; Array[a,37,0] (* Stefano Spezia, Apr 26 2024 *)
-
Python
from math import comb def A163493(n): return 2+sum((x:=comb((k:=m<<1)-1,m)*comb(n-k,m))+(x*(n-3*m)<<1)//(n-k) for m in range(1,n//3+1)) if n else 1 # Chai Wah Wu, May 01 2024
Formula
G.f.: 1/2/(1-x) + (1+2*x)/2/sqrt((1-x)*(1-2*x)*(1+x+2*x^2)). - Richard Stanley, corrected Apr 29 2011
G.f.: (1 + sqrt( 1 + 4*x / ((1 - x) * (1 - 2*x) * (1 + x + 2*x^2)))) / (2*(1 - x)). - Michael Somos, Jan 30 2012
a(n) = sum( binomial(2*k-1, k)*binomial(n-2*k,k) + binomial(2*k, k)*binomial(n-2*k-1, k), k=0..floor(n/3)). - Joel B. Lewis, May 21 2011
Conjecture: -n*a(n) +(2+n)*a(n-1) +(3n-12)*a(n-2) +(12-n)*a(n-3) +(2n-18)*a(n-4)+(56-12n)*a(n-5) +(8n-40)*a(n-6)=0. - R. J. Mathar, Nov 28 2011
G.f. y = A(x) satisfies x = (1 - x) * (1 - 2*x) * (1 + x + 2*x^2) * y * (y * (1 - x) - 1). - Michael Somos, Jan 30 2012
Sequence a(n) satisfies 0 = a(n) * (n^2-2*n) + a(n-1) * (-3*n^2+8*n-2) + a(n-2) * (3*n^2-10*n+2) + a(n-3) * (-5*n^2+18*n-6) + a(n-4) * (8*n^2-34*n+22) + a(n-5) * (-4*n^2+20*n-16) except if n=1 or n=2. - Michael Somos, Jan 30 2012
a(n) = (1 + 3*hypergeom([1/2, 1-3*n/8, (1-n)/3, (2-n)/3, -n/3],[1, (1-n)/2, 1-n/2, -3*n/8],-27))/2 for n > 0. - Stefano Spezia, Apr 26 2024
a(n) ~ 2^n / sqrt(Pi*n). - Vaclav Kotesovec, Apr 26 2024
A345908 Traces of the matrices (A345197) counting integer compositions by length and alternating sum.
1, 1, 0, 1, 3, 3, 6, 15, 24, 43, 92, 171, 315, 629, 1218, 2313, 4523, 8835, 17076, 33299, 65169
Offset: 0
Comments
The matrices (A345197) count the integer compositions of n of length k with alternating sum i, where 1 <= k <= n, and i ranges from -n + 2 to n in steps of 2. Here, the alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i. So a(n) is the number of compositions of n of length (n + s)/2, where s is the alternating sum of the composition.
Examples
The a(0) = 1 through a(7) = 15 compositions of n = 0..7 of length (n + s)/2 where s = alternating sum (empty column indicated by dot): () (1) . (2,1) (2,2) (2,3) (2,4) (2,5) (1,1,2) (1,2,2) (1,3,2) (1,4,2) (2,1,1) (2,2,1) (2,3,1) (2,4,1) (1,1,3,1) (1,1,3,2) (2,1,2,1) (1,2,3,1) (3,1,1,1) (2,1,2,2) (2,2,2,1) (3,1,1,2) (3,2,1,1) (1,1,1,1,3) (1,1,2,1,2) (1,1,3,1,1) (2,1,1,1,2) (2,1,2,1,1) (3,1,1,1,1)
Crossrefs
Programs
-
Mathematica
ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}]; Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],Length[#]==(n+ats[#])/2&]],{n,0,15}]
A346632 Triangle read by rows giving the main diagonals of the matrices counting integer compositions by length and alternating sum (A345197).
1, 0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 6, 6, 0, 0, 0, 1, 2, 9, 12, 0, 0, 0, 0, 1, 2, 12, 18, 10, 0, 0, 0, 0, 1, 2, 15, 24, 30, 20, 0, 0, 0, 0, 1, 2, 18, 30, 60, 60, 0, 0, 0, 0, 0, 1, 2, 21, 36, 100, 120, 35, 0, 0, 0, 0
Offset: 0
Comments
The matrices (A345197) count the integer compositions of n of length k with alternating sum i, where 1 <= k <= n, and i ranges from -n + 2 to n in steps of 2. The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.
Examples
Triangle begins: 1 0 0 0 1 0 0 1 2 0 0 1 2 0 0 0 1 2 3 0 0 0 1 2 6 6 0 0 0 1 2 9 12 0 0 0 0 1 2 12 18 10 0 0 0 0 1 2 15 24 30 20 0 0 0 0 1 2 18 30 60 60 0 0 0 0 0 1 2 21 36 100 120 35 0 0 0 0 0 1 2 24 42 150 200 140 70 0 0 0 0 0 1 2 27 48 210 300 350 280 0 0 0 0 0 0 1 2 30 54 280 420 700 700 126 0 0 0 0 0
Crossrefs
The first nonzero element in each column appears to be A001405.
These are the diagonals of the matrices given by A345197.
Antidiagonals of the same matrices are A345907.
Row sums are A345908.
A011782 counts compositions.
A097805 counts compositions by alternating (or reverse-alternating) sum.
Compositions of n, 2n, or 2n+1 with alternating/reverse-alternating sum k:
Programs
-
Mathematica
ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}]; Table[Table[Length[Select[Join@@Permutations/@IntegerPartitions[n,{k}],k==(n+ats[#])/2&]],{k,n}],{n,0,15}]
Comments
Examples
References
Links
Crossrefs
Programs
Maple
Mathematica
PARI
PARI
PARI
Python
Sage
Formula
Extensions