Solve recursive equation:
$$ f_n = \frac{2n-1}{n}f_{n-1}-\frac{n-1}{n}f_{n-2} + 1$$ $f_0 = 0, f_1 = 1$
What I have done so far:
$$ f_n = \frac{2n-1}{n}f_{n-1}-\frac{n-1}{n}f_{n-2} + 1- [n=0]$$
I multiplied it by $n$ and I have obtained:
$$ nf_n = (2n-1)f_{n-1}-(n-1)f_{n-2} + n- n[n=0]$$ $$ \sum nf_n x^n = \sum(2n-1)f_{n-1}x^n-\sum (n-1)f_{n-2}x^n + \sum n x^n $$
$$ \sum nf_n x^n = \sum(2n-1)f_{n-1}x^n-\sum (n-1)f_{n-2}x^n + \frac{1}{(1-z)^2} - \frac{1}{1-z} $$
But I do not know what to do with parts with $n$. I suppose that there can be useful derivation or integration, but I am not sure. Any HINTS?
If $g(x)$ is your generating function, then $g'(x)=\sum nf_nx^{n-1}$, so $xg'(x)=\sum nf_nx^n$. Then
$$\sum(2n-1)f_{n-1}x^n=x\sum(2n+1)f_nx^n=2x^2g'(x)+xg(x)\;,$$
and you can handle the remaining summation similarly. I’ve not checked to see whether the resulting differential equation is nice or nasty. Note that your variable name changed from $x$ to $z$ in the last two terms.