Definitions. This is about repeating sequences of natural numbers such as $\overline{6} = 6,6,6, \dots$ or $\overline{2,1,2} = 2,1,2,2,1,2, \dots$. I am aware that these can be faithfully represented as the sequence of coefficients of a power series $f(x)(1 + x^k + x^{2k} + \dots)$ where $k = \deg f + 1$. And conversely, so there is a bijection. However, I have (consider this my attempt) verified that neither power series $+$ nor $\cdot$ represent the below described $\star$ operation.
Given $a = \overline{a_0, a_1, \dots, a_n}$ and $b = \overline{b_0, b_1, \dots, b_m}$ define $a \star b$ by the following algorithm.
We must start at $c_0 = (a\star b)_0$ the first entry of the result $c$.
The Algorithm. $a \star b$:
Input: $a, b$ (finite sequences such that if you index them the index you pass in gets modulo'd by their length).
Output: $c$ another repeating sequence in smallest length finite form.
- Let $i = 0, j=0, k=0, c = []; s = 0, t = 0$
- If $\sum c = \text{LCM}(\sum a, \sum b)$ reduce $c$ if possible and return.
- Let $s = a_i, t=b_j$.
- If $s=t$ let that be the result $c_k = t = s, k = k + 1; i = i +1; j = j + 1; s = 0, t = 0$, loop to step 1.
- else if $s \lt t$ let $s = s + a_{i+1}; i = i + 1$ and test again (loop to step 3),
- else if $s \gt t$ let $t = t + b_{j+1}; j = j + 1$ and test again (loop to step 3).
This can be proven to result in a repeating sequence. And thus we have an operation $\star$ closing such sequences.
Questions.
My question is given $a_1, \dots a_h$ or a total of $h$ repeating sequences, what is a non-trivial upper bound on $(a_1 \star \cdots \star a_h)_0$ that is better than $\text{LCM}(\sum_{i=0}^{n} a_i, \sum_{i=0}^{m} b_i) =$ a trivially known period of the resulting sequence?
Corollary question: what is a terminating condition better than the LCM of the sums of each?
Sometimes LCM of sums will be reached, but I'm wanting to terminate earlier for inputs / outputs where that is possible. Please a solution that doesn't use memoization as that would hide the mathematics of the situation.
Alternative question: Is $\star$ associative?
Worked Example (By inspection).
Notice that the sum of the elements in the result $c$ in the image is $35$. The sum of the elements in $a$ is $5$ and that of $b$ is $7$. So I guess my termination condition is about right, but what about the bound on $(a\star b)_{0}$? Here it is merely $2$.
|instead of comma, in $a$ and $b$ (depending on $a,b$), which break the sequences in pipe-blocks, the entries between two pipes - finite hopefully - so that the sums of the blocks coincide. – dan_fulea Mar 19 '24 at 22:44