Solving a recurrence relation using generating functions My recurrence relation is 
D(n) = D(n - 1) + D(n - 2) + 5(n - 1);
with the initial conditions D(2),D(3) being 6, 17 respectively.
The generating function G(z) for the sequence D(n) is given

I don't know how i got this. Please can anyone give explanation for this?
Thank you.

Define the generating function:
$$
G(z) = \sum_{n \ge 0} D(n) z^n
$$
Take your recurrence written as:
$$
D(n + 2) = D(n + 1) + D(n) + 5 (n + 1)
$$
Multiply by $z^n$, sum over $n \ge 0$ and recognize some sums:
$$
\frac{G(z) - D(0) - D(1) z}{z^2}
  = \frac{D(z) - D(0)}{z} + G(z) + \frac{5}{(1 - z)^2}
$$
Solve for $G(z)$, split into partial fractions:
$\begin{align}
G(z)
  &= \frac{D(0) + (D(1) - 3 D(0)) z 
                - (2 D(1) - 3 D(0) - 5) z^2
                + (D(1) - D(0)) z^3}
          {(1 - z)^2 (1 - z - z^2)} \\
  &= \frac{(D(0) + 10) + (D(1)- D(0) + 5) z}{1 - z - z^2}
       - \frac{5}{1 - z} - \frac{5}{(1 - z)^2}
\end{align}$
Now we know that the Fibonacci numbers $F_n$ are defined by:
$$
F_{n + 2} = F_{n + 1} + F_n \qquad F_0 = 0, F_1 = 1
$$
with generating function:
$$
F(z) = \sum_{n \ge 0} F_n z^n = \frac{z}{1 - z - z^2}
$$
so that $1 / (1 - z - z^2)$ corresponds to the sequence of the $F_{n + 1}$, and so:
$$
D(n)
  = (D(0) + 10) F_{n + 1}
      + (D(1) - D(0) + 5) F_n
      - 5 - 5 (n + 1)
$$
Plug in the known values of $D(2)$ and $D(3)$ to get a system of equations for the missing $D(0)$ and $D(1)$, and you are done.
