How to encode a list of integers, how to find an arithmetical formula for a sequence?

712 Views Asked by At

I have the following list of integers : $$t={0, 15, 73, 27, 73, 105, 25, 65, 26, 8, 84, 72, 15, 73, 27, 73, 105, 25, 65}$$ And I want to find a function or (an expression) such that $f(k)$ is always the $k$-th element in the sequence, for example $f(k)=15k$ gives me the first two element and if I added $f(k)=15k(k-1)+73$ gives me the first three elements. I can follow this method it gives me a very big expression at the end.

Is there a way to find a very simple function to do this?: any expression is allowed boolean operations, arithmetic operations, ...

Edit As proposed in the comments we can restrict to the sequence $$15, 73, 27, 73, 105, 25, 65, 26, 8, 84, 72$$ I found an interesting function in Mathematica FindSequenceFunction but it does not produce anything for this sequence .

If someone could find two integers $a,b$ such that $f(k)= a\mod(b+k)$ then it's exactly what I'm looking for

Thank you,

1

There are 1 best solutions below

4
On BEST ANSWER

You could use an inexpensive pairing function $(a, b)\mapsto \langle a,b\rangle$, for example $$ \langle a,b\rangle := \frac {(a+b)(a+b+1)} 2 + a, $$ (this is the Cantor pairing function) and encode a sequence $(s_0, \dotsc s_n)$ by $\langle k, \langle s_0, \langle \dotsc \langle s_{n-1,}s_n\rangle\dotsc\rangle\rangle$. This encodes a sequence as the iteratively/recursively paired elements, tagged with the sequence length. Thus, $$\begin{align} (a) &\mapsto \langle 1, n \rangle \\ (a,b) &\mapsto \langle 2, \langle a,b\rangle \rangle \\ (a,b,c) &\mapsto \langle 3, \langle a,\langle b,c\rangle \rangle\rangle \\ &\,\vdots\\ \end{align}$$

The downside of this approach is that arbitrary indexing becomes relatively expensive, as the nesting has to be undone — it's more expensive to retrieve the $i$-th element for larger indexes $i$ than for smaller $i$. Before indexing a lot into a sequence number (a number regarded as encoding a sequence), you'd probably want to first convert it back to a sequence (/list/tuple...). Depending on the details of your actual problem, this may be an option, or it may make the whole approach pointless.


The wikipedia article on pairing functions cited above derives the inverses of $\langle a,b \rangle$. Here's the result: If $n = \langle a,b \rangle$, then $a, b$ can be recovered from $n$ as follows:

Let $$\begin{align} w &= \big\lfloor \frac {\sqrt {8n+1} - 1} 2 \big\rfloor, \tag{$w = a+b$} \\ t &= \frac {w (w+1)} 2; \tag{$n = t+b$} \\ \end{align}$$ then $$\begin{align} b &= n - t \\ a &= w - b \end{align}$$