Consider the following linear difference equation $$ f_{k} = 1 + \frac{1}{2} f_{k+1} + \frac{1}{2} f_{k-1}, 1\le k \le n-1$$
with $f_0 = f_n = 0$. How do I find the solution? I consider the homogeneous version $$ f_{k+1} - 2f_k + f_{k-1} = -1$$
and found that the solution is $C_1 + C_2 k$. But I don't know how to find a particular solution to the non-homogeneous equation.
Easily you can determine that for the homogeneous recurrence equation
$$ f^h_{k+1}-2f^h_k+f^h_{k-1} = 0 $$
the solution is
$$ f^h_k = c_1 + c_2 k $$
now, a particular solution which should be polynomial, you can propose
$$ f^p_k = c_1 + c_2 k + c_3 k^2 $$
and the coefficient's determination is obtained by substitution in
$$ f^p_{k+1}-2f^p_k+f^p_{k-1} + 1 = 0 $$
obtaining the condition
$$ 1+2c_3 = 0\Rightarrow c_3 = -\frac 12 $$
and finally
$$ f_k = f^h_k + f^p_k = c_1 + c_2 k-\frac 12 k^2 $$