<s>[INST] How to solve this recurrence relation? $f(1) = a; f(2) = b; f(x) = 2f(x-1)-f(x-2)+2;$ How to solve this recurrence relation?


*

*$f(1) = a;$

*$f(2) = b;$

*$f(x) = 2f(x-1)-f(x-2)+2;$


Where $a$ and $b$ are positive integers
I want to find $f(x)$ representation with $a$ and $b$ only
Also I am sorry, I really not familiar with it, I got into this as part of my development project
 [/INST] By combining all the above clues, we have
\begin{equation}
f(n) = (n-1)b - (n-2)a + (n-1)(n-2)
\end{equation}
To verify this, it is clear that $f(1) = a$ and $f(2) = b$.
Also the simple calculation reveals that
\begin{align}
2f(x-1) - f(x-2) +2 &= 2[(x-2)b - (x-3)a + (x-2)(x-3)] \\
&\hspace{0.2cm} ...- [(x-3)b - (x-4)a + (x-3)(x-4)] + 2 \\
&= (x-1)b - (x-2)a + (x-1)(x-2) = f(x).
\end{align} 
</s>