How to find the generating function from recurrence relation $t_n=(1+c~q^{n-1})~p~t_{n-1}+a +b+nbq, ~~n\ge 2$? How to find the generating function $T(z)=\sum_{n=0}^{\infty} t_n~z^n$ from the recurrence relation $$t_n=(1+c~q^{n-1})~p~t_{n-1}+a +b+nbq,\qquad n\ge 2.$$ given that  $$t_1=b+(1+c~p)(a~q^{-1}+b),$$ and $$t_0=\frac{a}{q}+b,$$ where $a, b, c$ are constants and $p+q=1.$
 A: Consider $t_{n+1} = (1+c~q^{n})~p~t_{n} + a + b + (n+1)bq$ for which
\begin{align}
\sum_{n=0}^{\infty} t_{n+1} \, x^{n} &= p \, T(x) + c \, p \, T(q x) + \frac{a + b}{1-x} + b q \, \partial_{x} \left( \sum_{n=0}^{\infty} x^{n} \right) \\
\frac{T(x) - t_{0}}{x} &= p \, T(x) + c \, p \, T(q x) + \frac{a + b}{1-x} + b q \, \partial_{x} \frac{1}{1-x}
\end{align}
or
\begin{align}
c p x \, T(q x) + (p x -1) T(x) + \frac{(a + b) x}{1- x} + \frac{b q \, x}{(1-x)^{2}} + t_{0} = 0 
\end{align}
where $T(x) = \sum_{n=0}^{\infty} t_{n} \, x^{n}$. 
By working out term by term it can be determined that
\begin{align}
t_{1} &= p(1+c) \, t_{0} + (bq + a + b) \\
t_{2} &= p^{2} \, (1+c)(1+cq) \, t_{0} + (bq + a + b)(p(1+cq) + 1) + bq \\
\cdots &= \cdots
\end{align}
where the general form is 
\begin{align}
t_{n} = t_{0} \, p^{n} \, \prod_{k=1}^{n} \{ 1 + c q^{k-1} \} + (bq + a + b) \, \sum_{r=1}^{n} p^{n-r} \, \left(\prod_{k=r+1}^{n} \{ 1 + c q^{k-1} \}\right) + bq \, \sum_{r=2}^{n} a_{r} \, p^{n-r} \, \left(\prod_{k=r+1}^{n} \{1 + c q^{k-1} \} \right)
\end{align}
where the terms indicate that $a_{r}$ may be $r-1$ (based upon $n=1,2,3,4$).
