<s>[INST] Closed form sought for $a_1 = a_2 = 1, a_n = 1 + \frac{2}{n} \sum_{i=1}^{n-2} a_i $ where $n>2$ I've been working through a problem that I've got as far as getting a recursive answer to. I was hoping to turn this into more of a "closed form" answer, but haven't really gotten anywhere. I'm hoping that someone can help with this, though anything would be greatly appreciated.

The recursive answer I have is a sequence of real numbers given by $$\begin{gather}
a_1 = a_2 = 1 \\
a_n = 1 + \frac{2}{n} \sum_{i=1}^{n-2} a_i \qquad  (n > 2)
\end{gather}$$
The first few non-trivial members of this sequence are

*

*$a_3 = \frac{5}{3}$

*$a_4 = 2$

*$a_5 = \frac{37}{15}$

*$a_6 = \frac{26}{9}$

*$a_7 = \frac{349}{105}$
I've tried to express these in terms of $a_1$ and $a_2$ and and constants and arrived at

*

*$a_3 = 1 + \frac{2}{3} a_1$

*$a_4 = 1 + \frac{2}{4} a_1 + \frac{2}{4} a_2$

*$a_5 = (1 + \frac{2}{5}) + (\frac{2}{5} + \frac{2^2}{3\cdot5} ) a_1 + \frac{2}{5} a_2$

*$a_6 = (1 + \frac{2}{6} + \frac{2}{6}) + (\frac{2}{6} + \frac{2^2}{3 \cdot 6} + \frac{2^2}{4 \cdot 6}) a_1 + (\frac{2}{6} + \frac{2^2}{4 \cdot 6}) a_2$

*$a_7 = (1 + \frac{2}{7} + \frac{2}{7} + \frac{2}{7} + \frac{2^2}{5 \cdot 7}) + (\frac{2}{7} + \frac{2^2}{3\cdot7} + \frac{2^2}{4 \cdot 7} + \frac{2^2}{5 \cdot 7} + \frac{2^3}{3 \cdot 5 \cdot 7}) a_1 + (\frac{2}{7} + \frac{2^2}{4 \cdot 7} + \frac{2^2}{5 \cdot 7}) a_2$
I am not seeing a pattern developing here.
I also rearranged the above noting that $a_1 = a_2 = 1$ and got

*

*$a_3 = 1 + \frac{2}{3} $

*$a_4 = 1 + 2 (\frac{2}{4})$

*$a_5 = 1 + 3 (\frac{2}{5}) + \frac{2^2}{3\cdot5}$

*$a_6 = 1 + 4 (\frac{2}{6}) + \frac{2^2}{3 \cdot 6} + 2 (\frac{2^2}{4 \cdot 6})$

*$a_7 = 1 + 5 (\frac{2}{7}) + \frac{2^2}{3 \cdot 7} + 2 (\frac{2^2}{4 \cdot 7}) + 3 (\frac{2^2}{5 \cdot 7}) + \frac{2^3}{3 \cdot 5 \cdot 7}$
Here I do notice a couple of things

*

*The expression for $a_n$ begins with "$1 + (n-2) \frac{2}{n}$".

*The remaining terms of the expression look like "$k \dfrac{2^{i+1}}{b_1 \cdots b_{i} \cdot n}$" where each $b_j$ is between $3$ and $n-2$ and consecutive numbers cannot appear among them. The $k$ seems to be determined by the smallest number among the $b_j$, but this is more of a guess than anything right now.

These observations are not really helping me much at all.
 [/INST] This might help by converting it into an order 2 recurrence:
$$
a_n = 1 + \frac{2}{n} \sum_{i=1}^{n-2} a_i
$$
$$
a_{n-1} = 1 + \frac{2}{n-1} \sum_{i=1}^{n-3} a_i
$$
therefore
$$
\sum_{i=1}^{n-3} a_i = \frac{(a_{n-1}-1)(n-1)}{2}
$$
and
$$
\sum_{i=1}^{n-2} a_i = a_{n-2} + \sum_{i=1}^{n-3} a_i
$$
$$
a_n = 1 + \frac{2}{n} a_{n-2} + \frac{n-1}{n}(a_{n-1}-1)
$$
I'll see if I can get any further...
Some ideas/notes here:
Formally, the generating function:
$$
G(x) = \sum_{n=1}^\infty a_n x^n = \sum_{n=1}^\infty (1 + \frac{2}{n} a_{n-2} + \frac{n-1}{n}(a_{n-1}-1)) x^n
$$
$$
G(x) = \sum_{n=1}^\infty a_n x^n = \sum_{n=1}^\infty x^n +  \sum_{n=1}^\infty (\frac{2}{n} a_{n-2} + \frac{n-1}{n}(a_{n-1}-1)) x^n
$$
$$
G(x) = \sum_{n=1}^\infty a_n x^n = \frac{x}{1-x} +  \sum_{n=1}^\infty (\frac{2}{n} a_{n-2} + \frac{n-1}{n}(a_{n-1}-1)) x^n
$$
$$
G(x) = \sum_{n=1}^\infty a_n x^n = \frac{x}{1-x} - \log (1-x)-\frac{x}{x-1} + \sum_{n=1}^\infty (\frac{2}{n} a_{n-2} + \frac{n-1}{n}a_{n-1}) x^n
$$
$$
G(x) = \sum_{n=1}^\infty a_n x^n = \frac{2x}{1-x} - \log (1-x) + \sum_{n=1}^\infty (\frac{2}{n} a_{n-2} + \frac{n-1}{n}a_{n-1}) x^n
$$
Now there is a quite interesting interpretation of a term like
$$
H(x) = \sum_{n=1}^\infty \frac{n-1}{n} a_{n-1} x^n
$$
but it requires some kind of 'parallel' or umbral universe.
Normally we differentiate a generating function to get
$$
G'(x) = \frac{d}{dx}\sum_{n=1}^\infty a_n x^n = \sum_{n=1}^\infty n a_{n}x^{n-1}
$$
if we consider a transform where functions are mapped to new functions whose series are ratios of the previous coefficients
$$
\mathcal{T}[G(x)](t) = \sum_{n=1}^\infty \frac{a_n}{a_{n-1}}t^n
$$
where the differential operator ends up turning into a 'shift' operator and the effect on the coefficients looks similar to that in $H(x)$. Seeing as we are apparently already in that domain, it might be worth stepping back out to the domain consistent with differentiation and consider the generating function that takes iterated products of terms
$$
F(x) = \sum_{k=1}^\infty \left(\prod_{l=1}^k a_l\right) x^k
$$
Mathematica has managed to solve the recurrence and I believe for the above reasons, the answer is very ugly. There may be a strategy for simplifying it down.
$$
 a(n)\to \frac{-\frac{2 (8 E_{-n-3}(-2) \Gamma (n+2)+\Gamma (n+4,-2))}{e^2
    \Gamma (n+2)}+n (n+5)+\frac{(-2)^{n+3}}{\Gamma (n+2)}+2}{4
    (n+2)}+\frac{1}{3} (n+3) \sum _{K[1]=0}^{n-1} -\frac{3\ 2^{-K[1]-5} e^{-2-i
    \pi  K[1]} \left(e^2 (-1)^{K[1]} 2^{K[1]+6}+K[1]^2 (-\Gamma (K[1]+5,-2))-8
    K[1] \Gamma (K[1]+5,-2)+K[1] \Gamma (K[1]+6,-2)-15 \Gamma (K[1]+5,-2)+7
    \Gamma (K[1]+6,-2)\right)}{(K[1]+2) (K[1]+3) (K[1]+5)}$$
Edit: Based on @Gary's development the coefficients appear to be
$$
a_n = \frac{e^2 \left((-1)^n 2^{n+1}+\Gamma (n+2)\right)-(n+3) \Gamma (n+1,-2)}{2
    e^2 n!}
$$
this is obtained by the inverse Z-transform of $G(\frac{1}{x})$.
</s>