My task is this;
The function $f:\mathbb{R} \to \mathbb{R}$ is given by $f(x) = \lambda x + k$ where $\lambda, k \in \mathbb{R}$ and $\lambda \neq 1$. Show that when we are iterating $f$ with startingpoint $x_0$, then: $$x_n = \lambda^n \left(x_0 -\frac{k}{1 - \lambda}\right) + \frac{k}{1 - \lambda}.$$
The first thoughts that comes to my mind is to write out some iterations: $x_1 = f(x_0) = \lambda x_0 + k,\: x_2 = f(x_1) = f(f(x_0)) = \lambda(\lambda x_0 + k) + k = \lambda^2 x_0 + \lambda k + k, \: x_3 = f(x_2) = f(f(f(x_0))) = \lambda(\lambda^2x_0 + \lambda k + k) + k = \lambda^3x_0 + \lambda^2k + \lambda k + k$.
So it seems like for $n$ iterations, we get $\lambda^nx_0 + \sum\limits_{i = 1}^{n}\lambda^{i - 1} k = \lambda^n x_0 + \frac{k}{1 - \lambda}$. I think the last step is right, but now i just can't see the path that connects my thoughts to the given expression. Any help would be appriciated.
Thanks in advance!
A subtle, but crucial fact to notice in this exercise as i did rather late is that in the equation given: $$x_n = \lambda^n \left(x_0 -\frac{k}{1 - \lambda}\right) + \frac{k}{1 - \lambda}.$$
It's not assumed that $n \to \infty$, which means that we cannot simply apply the formula for infinite series as i did. This is the correction to my error:$$\lambda^nx_0 + \sum\limits_{i = 1}^{n}\lambda^{i - 1} k = \lambda^n x_0 + k\left(\frac{1 - \lambda^n}{1 - \lambda}\right) = \lambda^nx_0 + \frac{k - \lambda^n k}{1 - \lambda} = \lambda^n\left(x_0 - \frac{k}{1- \lambda}\right) + \frac{k}{1 - \lambda}.$$