explicit formula for sequence with multiple rules? e.g.: $a_n=\{1,2,3, 5,10,15, 25,50,75, … 5^kn,5^k(n+1),5^k(n+2), 5^{k+1}n,..\}$ What is the formula for the sequence obeying that pattern? A base-10 analog could be $\{1,2,3,4,5,6,7,8,9, 10,20,30,.., … 10^kn,10^k(n+1),10^k(n+2),..10^{k+1}n, 10^{k+1}(n+1),10^{k+1}(n+2), . . .\}$, where k is an integer starting with 0 stepping by 1.
What if the sequence doesn't increase or decrease locally over the entire domain, such as with a subsequence of {4,5,3} or a rule using sign-flipping or periodicity (e.g. $(-k)^n$ for subsequences with both even and odd or non-integer or $(-k)^{n+1}$ for sequence otherwise without) and it could feature duplicate values; is there a way to apply a rule admitting only the first (or for that matter, only the second, third, or or any rank of choice, preculuding more and more) instances of a value? E.g.: $b_n$={4,5,3, 3,5,1,-3,1} with a rule of |2n|-5 of $n_i$ and simply eliminating duplicate value then continuing to $n_{i+1}$ (instead of continuing to iterate until a valid value arises from operating on $n_i$. The possibility exists also to include omitted(duplicate/sub-duplicate) in the input sequence of (could call it) $n_j$. What is the mathematical or programming way to formulate this? What if you want to take a discrete sequence with rules such as these and regress it to a smooth curve, is that possible?
 A: There are several ways how to achieve what you ask. It depends on what you want from such representation.

*

*If you want your reader to understand how the sequence behaves, then nothing really beats the piecewise bracket:
$$
a_k = \begin{cases}
1\cdot 5^{\lfloor k/3\rfloor}&\text{if }k\equiv 0\mod 3,\\
2\cdot 5^{\lfloor k/3\rfloor}&\text{if }k\equiv 1\mod 3,\\
3\cdot 5^{\lfloor k/3\rfloor}&\text{if }k\equiv 2\mod 3,
\end{cases}
$$


*If you want to compress this to a single line, you might use unit function $\delta[n]$ or $\mathbb 1_{cond}$:
$$
a_k=5^{\lfloor k/3\rfloor}\big(\delta[k\mathop{\mathrm{mod}} 3]+2\delta[(k\mathop{\mathrm{mod}} 3)-1]+3\delta[(k\mathop{\mathrm{mod}} 3)-2]\big)


*If you want something that looks continuous, then you can use the following trick. If your sequence has a period of 3, take 3 roots of $x^3=1$ and solve the equation:
$$
\begin{cases}
a +b+c=1,\\
a x_1^1+bx_2^1+cx_3^1=2,\\
a x_1^2+bx_2^2+cx_3^2=3.
\end{cases}
$$
with $x_1=1$, $x_2=e^{i2\pi/3}$ and $x_3=e^{-i2\pi/3}$, we get $a=2$, $b=-(i/\sqrt3 + 1)/2$, $c=(i/\sqrt3 - 1)/2$. Thus the sequence:
$$
u_k=2-\left(\frac{i}{2\sqrt3}+\frac12\right)e^{\frac{2\pi i}3 k}+\left(\frac{i}{2\sqrt3}-\frac12\right)e^{-\frac{2\pi i}3 k}
$$
will be periodic: 1,2,3,1,2,3...
You can do a similar trick with powers of 5. They go 0,0,0,1,1,1,2,2,2... By subtracting the asymptote $k/3$, you will get $0,-\frac13,-\frac23,0,-\frac13,-\frac23,0,-\frac13,-\frac23...$ a periodic sequence again. You can find that this sequence is:
$$
v_k = -\frac13+\frac16\left(1-\frac i{\sqrt3}\right)e^{\frac{2\pi i}3 k}+\frac16\left(1+\frac i{\sqrt3}\right)e^{-\frac{2\pi i}3 k}.
$$
And finally $a_k=u_k 5^{v_k+k/3}$. If you don't like complex numbers, you can express this with trigonometric functions.
