Recurrence Relation with two variables and boundary conditions - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-10-13T23:57:46Z https://mathematica.stackexchange.com/feeds/question/187373 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/187373 0 Recurrence Relation with two variables and boundary conditions Jannik https://mathematica.stackexchange.com/users/61034 2018-12-05T14:23:26Z 2019-01-04T16:00:55Z <p>I try to express the following recurrence relation in Mathematica:</p> <p>I am very sorry but for any reason I am not allowed to embed math code here...</p> <p><span class="math-container">\begin{align*} x_{1,t} &amp;= \frac{1}{2} x_{1,t-1} + \frac{1}{2} x_{2,t-1} \\ x_{i,t} &amp;= \frac{1}{2} x_{i-1,t-1} + \frac{1}{2} x_{i+1,t-1} &amp; 1 &lt; i &lt; n \\ x_{n,t} &amp;= \frac{1}{2} x_{n-1,t-1} + \frac{1}{2} x_{n,t-1} \end{align*}</span> </p> <p>This is my approach but it does not work. Does anyone know how to fix this? Thanks a lot!</p> <pre><code>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 &amp; 2*x[n, t - 1] + 1/2*x[n - 1, t - 1]}, x[1, n], x] </code></pre> https://mathematica.stackexchange.com/questions/187373/-/187384#187384 1 Answer by TheDoctor for Recurrence Relation with two variables and boundary conditions TheDoctor https://mathematica.stackexchange.com/users/2263 2018-12-05T15:43:33Z 2018-12-05T15:43:33Z <p>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).</p> <p>Although you write <code>x[i, 0] == 1</code>, since <span class="math-container">$1&lt;i&lt;n$</span> you also need to give the initial values for <code>x[0, 0]</code> and <code>x[n, 0]</code>. </p> <p>Assuming an initial array of the form</p> <pre><code>start = Join[Join[{0}, ConstantArray[1, {10}]], {0}] </code></pre> <p>you can use <code>NestList</code> and <code>ListConvolve</code> to perform the iteration, e.g.</p> <pre><code>NestList[ListConvolve[{1/2, 1/2}, #, 1], start, 10] </code></pre> <p>And you can use options to <code>ListConvolve</code> to control the alignment and overhangs.</p>