# solve recursion equation with condition

How can I find $f(x)$ in terms of $x$ in the following equation?

$-k\, x \,f(x) + k \, (x + 1)\, f(x + 1) - r \, f(x) + r\, f(x - 1) =0$

$r$ and $k$ are constants and $f(x)$ should satisfy:

$\sum_0^{\infty} f(x)=1$

Solve just find $f(x)$ in terms of other statements:

Solve[-k x f[x] + k (x + 1) f[x + 1] - r f[x] + r f[x - 1] == 0, f[x]]

{{f[x] -> (2 f[-1 + x] + f[1 + x] + x f[1 + x])/(2 + x)}}


What you have is basically a nonlinear second order recursion, and in this case it can be solved by:

sol = RSolve[-k x f[x] + k (x + 1) f[x + 1] - r f[x] + r f[x - 1] == 0, f[x], x]


The answer is fairly large, and besides having variables r and k, it also has two constants C[1] and C[2], so there may be enough flexibility to enforce your desired constraint. The two constants are basically caused by the initial conditions of the recursion. For example, if you let f[0] and f[1] both be zero you can enforce a very simple solution

RSolve[-k x f[x] + k (x + 1) f[x + 1] - r f[x] + r f[x - 1] == 0
&& f[0] == 0 && f[1] == 0, f[x], x]


that unfortunately violates your constraint. Nonetheless, since we are free to choose the two constants, let's make our lives easy and choose C[2]=0. In this case the solution is summable:

Sum[sol[[1, 1, 2]] //. C[2] -> 0, {x, 0, Infinity}]

(2 E^(r/k) k C[1])/r


So now, for any specified r and k, you just need to pick C[1] so that this is 1. Thus

Solve[(2 E^(r/k) k C[1])/r == 1, C[1]]

C[1] -> (E^(-(r/k)) r)/(2 k)

• Thanks bill, but is it possible to put the mentioned constraint and then find the solution? Jan 30, 2015 at 13:43
• Yes, by judicious choice of the constants C[1] and C[2]. See update. Jan 30, 2015 at 13:54