Given the recursive function:
$$f(0) = \frac{x^2}{2} + \frac{x}{2}, f(n) = \frac{f(n-1)}{2} + \frac{x}{2}$$
where $x$ = some integer
How would one rewrite this function to be strictly non-recursive? Eg. the non-recursive counterpart to the recursive function $f(0) = x$, $f(n) = \large \frac{f(n-1)}{2}$ is $f(x)$ = $\large\frac{1}{2^{x}}$.
Thank you.
$f(n)$ will be a linear function of $x^2$ and $x$. Looking at the first few terms $$f(1)=\frac{1}{4}x^2 + \frac{3}{4}x$$ $$f(2)=\frac{1}{8}x^2 + \frac{7}{8}x$$ etc., it is obvious $$f(n)=\frac{1}{2^{n+1}}x^2 + \left(1-\frac{1}{2^{n+1}}\right)x.$$ You can prove this by induction.