I was to solve the discrete functional equation (considering $ a _ k $ is a discrete function) $$ f [ a _ { k + 1 } ] - f [ a _ k ] = 0 $$ where $$ f [ a _ k ] = \sum _ { i = a _ k } ^ { a _ { k + 1 } } n - ( i + 1 ) $$ with boundary conditions $$ \begin {cases} a _ 1 & = 0 \\ a _ { p + 1 } & = n \end {cases} $$ where $ n > 1 $, $ p > 0 $ and $ k = 1 , 2 , 3 , \dots , p $.
The sum can be calculated, and I've arrived at the following non-linear recurrence relation: $$ ( 1 - 2 n ) a _ k + ( 4 n - 2 ) a _ { k + 1 } + a _ { k + 2 } ( a _ { k + 2 } - 2 n + 1 ) + a _ k ^ 2 = 2 a _ { k + 1 } ^ 2 $$
After trying several approaches, I desperately tried brute force, calculating numerical results for different values of the parameters, and with some effort, I found this simple equation: $$ a _ k = \frac 1 { 2 p } \left( - p + 2 p ( n + 1 ) - \sqrt{ p ^ 2 + 4 p ( p + 1 - k ) ( n + 1 ) n } \right) $$ which:
- agrees with the boundary conditions;
- when substituted in the recurrence relation, gives a true statement;
which I believe is enough to prove that this is a solution of the problem.
what I'm asking is whether there is any method for solving this problem that can lead me to the same result without having to make this "ansatz". The solution looks very simple, suggesting a possible analytical method for solving the recurrence relation (the expression seems to be the solution of a certain second order algebraic equation).
Let's rephrase your question as follows:*
To make things look simpler, first define the real function $ g $ with $ g ( w ) = w ( 2 n - w + 1 ) $ for all real numbers $ w $. Then define the finite sequence $ ( b _ k ) _ { k = 0 } ^ p $ of real numbers with $ b _ k = g ( a _ k ) $ for all natural numbers $ k $ no more than $ p $. Now, you can rewrite the "boundary conditions" as $ b _ 0 = 0 $ and $ b _ p = n ( n + 1 ) $, and the recurrence relation \eqref{0} as $$ b _ { k + 2 } - b _ { k + 1 } = b _ { k + 1 } - b _ k \tag 2 \label 2 $$ for any natural number $ k $ less than $ p - 1 $. \eqref{2} means that $ ( b _ k ) _ { k = 0 } ^ p $ is in fact an arithmetic progression, and thus we must have $ b _ k = b _ 0 + k d $ for all natural numbers $ k $ no more than $ p $, where $ d $ is the common difference of the progression. As $ b _ 0 = 0 $ and $ b _ p = n ( n + 1 ) $, we get $ b _ k = \frac { k n ( n + 1 ) } { p } $ for all natural numbers $ k $ no more than $ p $. By definition of $ ( b _ k ) _ { k = 0 } ^ p $, we have $ a _ k ^ 2 - ( 2 n + 1 ) a _ k + \frac { k n ( n - 1 ) } p = 0 $, which shows that $$ a _ k = \frac 1 2 \left( 2 n + 1 \pm \sqrt { ( 2 n + 1 ) ^ 2 - \frac 4 p k n ( n + 1 ) } \right) \text . $$ As $ a _ p = n $, the "$ \pm $" in the above formula must be "$ - $" when $ k = p $. Since the sequence is assumed to be increasing, it follows that this must be true for all natural numbers $ k $ no more than $ p $, which means $$ a _ k = \frac 1 2 \left( 2 n + 1 - \sqrt { ( 2 n + 1 ) ^ 2 - \frac 4 p k n ( n + 1 ) } \right) \text . \tag 3 \label 3 $$
Note:
As you expected, $ a _ k $ is the root of the quadratic polynomial $$ p _ k ( x ) = x ^ 2 - ( 2 n + 1 ) x + b _ k \text . $$ This can be directly derived from the definition of $ g $ and $ b _ k = g ( a _ k ) $. Aside from simplifying the formula you had for $ a _ k $ and finding what $ p _ k $ should look like, an idea for getting a quadratic polynomial which has $ a _ k $ as a root is to look at \eqref{1}: $ f $ is the difference of the values of a certain quadratic polynomial (i.e. $ g $) at the points $ v $ and $ u $.
* There are major problems with the way you've presented the question; so the rephrasing is necessary. I've tried to keep the rephrased version as close to the original one as possible. I try to list the problems, so that you could choose another version, in case you found my choices not suitable. The only unnecessary change that I've made is that I've chosen the index $ k $ to change from $ 0 $ to $ p $ instead of the original $ 1 $ to $ p + 1 $. This was only for the looks of it, and for being more in line with the convention that $ 0 $ is a natural number.