# Recurrence Relation with two variables and boundary conditions

I try to express the following recurrence relation in Mathematica:

I am very sorry but for any reason I am not allowed to embed math code here...

\begin{align*} x_{1,t} &= \frac{1}{2} x_{1,t-1} + \frac{1}{2} x_{2,t-1} \\ x_{i,t} &= \frac{1}{2} x_{i-1,t-1} + \frac{1}{2} x_{i+1,t-1} & 1 < i < n \\ x_{n,t} &= \frac{1}{2} x_{n-1,t-1} + \frac{1}{2} x_{n,t-1} \end{align*}

This is my approach but it does not work. Does anyone know how to fix this? Thanks a lot!

RSolve[{x[i, t] == 1/2*x[i - 1, t - 1] + 1/2* x[i + 1, t - 1],
x[i, 0] == 1, x[1, t] = 1/2*x[1, t - 1] + 1/2*x[2, t - 1],
x[n, t] = 1 & 2*x[n, t - 1] + 1/2*x[n - 1, t - 1]}, x[1, n], x]

• Your equations have to be adjusted: RSolve[{x[i, t] == 1/2*x[i - 1, t - 1] + 1/2*x[i + 1, t - 1], x[1, t] == 1/2*x[1, t - 1] + 1/2*x[2, t - 1], x[n, t] == 1/2*x[n, t - 1] + 1/2*x[n - 1, t - 1]}, x[i, t], {i, t}] . Unfortunately MMA can't solve it... – Ulrich Neumann Dec 5 '18 at 14:40
• :-( thanks anyway – Jannik Dec 5 '18 at 14:51

It would be useful to explain first exactly what you are trying to do. It looks like some kind of finite-difference routine (which is built-in).

Although you write x[i, 0] == 1, since $$1 you also need to give the initial values for x[0, 0] and x[n, 0].

Assuming an initial array of the form

start = Join[Join[{0}, ConstantArray[1, {10}]], {0}]


you can use NestList and ListConvolve to perform the iteration, e.g.

NestList[ListConvolve[{1/2, 1/2}, #, 1], start, 10]


And you can use options to ListConvolve to control the alignment and overhangs.