Solve recursive equation $ f_n = \frac{2n-1}{n}f_{n-1}-\frac{n-1}{n}f_{n-2} + 1$ 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?
 A: 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.
A: Let's take a shot at this:
$$
f_n - f_{n - 1} = \frac{n - 1}{n} (f_{n - 1} - f_{n - 2}) + 1
$$
This immediately suggests the substitution $g_n = f_n - f_{n - 1}$, so $g_1 = f_1 - f_0 = 1$:
$$
g_n - \frac{n - 1}{n} g_{n - 1} = 1
$$
First order linear non-homogeneous recurrence, the summing factor $n$ is simple to see here:
$$
n g_n - (n - 1) g_{n - 1} = n
$$
Summing:
$$
\begin{align*}
\sum_{2 \le k \le n} (k g_k - (k - 1) g_{k - 1}) &= \sum_{2 \le k \le n} k \\
n g_n - 1 \cdot g_1 &= \frac{n (n + 1)}{2} - 1 \\
  g_n               &= \frac{n + 1}{2} \\
  f_n - f_{n - 1}   &= \frac{n + 1}{2} \\
\sum_{1 \le k \le n} (f_n - f_{n - 1}) 
                    &= \sum_{1 \le k \le n} \frac{k + 1}{2} \\
f_n - f_0           &= \frac{1}{2} \left( \frac{n (n + 1)}{2} + n \right) \\
f_n                 &= \frac{n (n + 3)}{4}
\end{align*}
$$
Maxima tells me this checks out. Pretty!
A: Did you try difference equations? The original expression can be rewritten as (denote $\Delta f_k=f_{k}-f_{k-1}$)
$$
\Delta f_{k}=\frac{k-1}{k}\Delta f_{k-1}+1 =\frac{k-1}{k} \cdot \frac{k-2}{k-1} \Delta f_{k-2} + \frac{k-1}{k}+1= \ldots =\frac{1}{k} \Delta f_1 + \frac{k-1}{k} \\
+ \frac{k-2}{k-1}+\ldots + 1 = \frac{1}{k} \Delta f_1 + k - H_k
$$
By summing both sides over $k$ and using boundary values you should get something like (I haven't checked the algebra!)
$$
f_n= H_n + \frac{n(n+1)}{2}-(n+1)(H_n-1)
$$
