Let's summarize the problem first. The recursive formula is
A(n+ 1) = q* an+f(n), and the structural geometric series is
a(n+ 1)+g(n+ 1)= q(an+g(n)),
So there is
f(n) = q*g(n) - g(n+ 1).
1.f(n) = a*n+b, if q ≠ 1, consider g(n) = c*n+d, c and d to be determined,
So q * (c * n+d)-(c * (n+1)+d) = a * n+b.
Generally speaking, if f(n) gives a polynomial of degree m, then g(n) will be determined as a polynomial of degree m..
2.f(n) = a*n+b, if q = 1, consider f (n f (n) = c * n 2+d * n * n.
Generally speaking, if f(n) gives a polynomial of degree m, g(n) will be determined as a polynomial of degree m+/kloc-0.
3 . f(n)= a^n; If q ≠ a, consider g (n) = c * a n, and c is to be determined.
If q = a, consider g (n g (n) = c * n * a n, that is, multiplying by a linear polynomial in the above example.
4.f (n) = a n+b * n+c, because the condition is linear, it is enough to add up the results of 1 (or 2) and 3.
5.f (n) = p(n) * a n, where p(n) is a polynomial of degree m, if q ≠ a, consider g (n) = q (n) * a n, q(n) is a polynomial of degree m, otherwise q(n) is m+ 1 degree.
In fact, you have seen some patterns, right?
In fact, there are many other ways to promote sales. For example, the recursive sequence of second order or even higher order, f(n) = sin(p*n*x), f(n) = cos(p*n*x), or the arbitrary product of trigonometric function, exponential function and polynomial function and the method similar to the above. For details, please refer to the theory of higher order linear ordinary differential equations.