Ternary words with given trace and subtrace

Here we consider the number $S(n;t,s)$ of length $n$ words $a_1 a_2\ldots a_n$ over the alphabet $\{0,1,\ldots,k-1\}$ with $k=3$ that have trace $t$ and subtrace $s$. The trace of a $k$-ary word is the sum of its digits mod $k$, i.e., $t=a_1+a_2+\cdots+a_n \pmod{k}$. The subtrace is the sum of the products of all $n(n-1)/2$ pairs of digits taken mod $k$, i.e., $s=\sum_{1\leq i\lt j\leq n} a_i a_j$.

(trace,subtrace)
$n$ (0,0) (0,1) (0,2) (1,0)
(2,0)
(1,1)
(2,1)
(1,2)
(2,2)
1 100 100
2 102 210
3 306 333
4 9612 9612
5 213030 302130
6 639090 818181
7 225252252 225252252
8 729756702 702729756
9 218722682106 218721872187
10 656166426480 656166426480
11 198451960219602 196021984519602
12 595355880658806 590495904959049
13 177633176904176904 177633176904176904
14 531441530712532170 532170531441530712
15 159432315921361596510 159432315943231594323
16 478296947807824785156 478296947807824785156
17 143445331435109414351094 143510941434453314351094
18 430335994305328243053282 430467214304672143046721
19 129127041129146724129146724 129127041129146724129146724
20 387420489387440172387400806 387400806387420489387440172

Examples

The one ternary string of trace 2, subtrace 1 and length 2 is $\{11\}$. The three ternary strings of trace 0, subtrace 0 and length 3 are $\{000, 111, 222\}$. The three ternay strings of trace 1, subtrace 2 and length 3 are $\{112, 121, 211\}$.

Enumeration (OEIS)

  • The number $S(n;t,s)$ can be computed from the following recurrence relation \begin{align} S(n;t,s) &= S(n-1;t,s) + S(n-1;t-1,s-(t-1)) + S(n-1;t-2,s-2(t-2)) \\ &= S(n-1;t,s) + S(n-1;t+2,s+2t+1) + S(n-1;t+1,s+t+1). \end{align}
  • Column (0,0) is OEIS A073947. The sequence has the rational generating function $(x-1)^2 ((x-1)^3 +5x^3 ) / (3x-1)(3x^2 +1)(3x^2 -3x+1)$.
  • Column (0,1) is OEIS A073948. The sequence has the rational generating function $6x^4 (x-1) / (3x-1)(3x^2 +1)(3x^2 -3x+1)$.
  • Column (0,2) is OEIS A073949. The sequence has the rational generating function $2x^2 ((x-1)^3 +2x^3 ) / (3x-1)(3x^2 +1)(3x^2 -3x+1)$.
  • Column (1,0),(2,0) is OEIS A073950. The sequence has the rational generating function $-x(x-1)((x-1)^3 +2x^3 ) / (3x-1)(3x^2 +1)(3x^2 -3x+1)$.
  • Column (1,1),(2,1) is OEIS A073951. The sequence has the rational generating function $x^2 ((x-1)^3 - 4x^3 ) / (3x-1)(3x^2 +1)(3x^2 -3x+1)$.
  • Column (1,2),(2,2) is OEIS A073952. The sequence has the rational generating function $-3x^3 (x-1)^2 / (3x-1)(3x^2 +1)(3x^2 -3x+1)$.
  • These numbers are defined and used in a more general setting in the papers [MR04a] and [MR04b].

    References