How can I find the exact-closed form solution of this recurrence?
$$f(n) = (1/2)f(n-2) + n/2,$$ where n is even, $f(0)=1$
My answer:
I try to guess a solution by unwinding the formula for f(n)
$f(n) = (1/2)f(n-2) + n/2$$
$= (1/2) ((1/2)f(n-4) + ((n-2)/2) )+n/2$
$=(1/2)^2f(n-4)+n/2^2+n/2 -2/2^2$
$=(1/2)^3f(n-6)+n/2^3+n/2^2+n/2 -2/2^2-4/2^3$
$=(1/2)^4f(n-8)+n/2^4+n/2^3+n/2^2+n/2 -2/2^2-4/2^3-6/2^4$
Continuing in this manner suggest the sum:
$f(n)=1/2^{(n/2)}f(0)+n(1/2^{n/2}+1/2^{(n/2)-1}+...+1/2)-(2/2^2+4/2^3+6/2^4+...)$
$f(n)=1/2^{(n/2)}+n(1-(1/2)^{n/2})-(2/2^2+4/2^3+6/2^4+...)$
How could I solve the expression $(2/2^2+4/2^3+6/2^4+...)$ and find the exact-closed form solution of this recurrence?
Hint: Look for a solution in the form $$f(n) = A r^n + B n + C$$