2
$\begingroup$

I am trying to find a[0] by solving the following system of equations where n can get 1,2,3,...,m-1

RSolve[{a[m]==(v+b a[m-1], 
a[n] ==  n/m (v + b a[n - 1]) + (1 - n/m) (v - p + b a[n + 1]),  
a[0] == v - p + b a[1]}, a[n], n]

But it doesn't produce any results, any idea how to make this work?

This is an example with m= 4:


Solve[{a0 == v - p + b a1 && 
     a1 == 1/4 (v + b a0) + (1 - 1/4) (v - p + b a2) && 
     a2 == 2/4 (v + b a1) + (1 - 2/4) (v - p + b a3) && 
     a3 == 3/4 (v + b a2) + (1 - 3/4) (v - p + b a4) && 
     a4 == 4/4 (v + b a3) }, {a0, a1, a2, a3,a4}] 

````
$\endgroup$
6
  • $\begingroup$ Recurrence is of order 2, so you need one more initial condition. $\endgroup$ – Vaclav Kotesovec Mar 26 at 19:41
  • $\begingroup$ I don't think that's the issue; adding one doesn't produce a result, and mathematica usually includes undetermined constants if the solution is underdetermined anyway, so that shouldn't be an issue. It might simply be not solvable by mathematica... $\endgroup$ – thorimur Mar 26 at 19:56
  • $\begingroup$ The start condition you specify is simply the recursion, therefore you can not determine a[0] from this information. More info is needed. The start condition must be independent from the recursion. $\endgroup$ – Daniel Huber Mar 26 at 20:01
  • $\begingroup$ Thanks for the comments. I do not have any other conditions to add. Say m = 4, we will have 5 equations in this series with five unknowns: a[0], a[1], a[2], a[3], a[4]. Why we would need any additional info? $\endgroup$ – Monire Jalili Mar 26 at 20:22
  • $\begingroup$ I believe you only have 4 equations in the original, relating the following sets of variables: a[0], a[1]; a[0], a[1], a[2]; a[1], a[2], a[3]; a[2], a[3], a[4]. The example seems to include a3 twice in the final equation. $\endgroup$ – thorimur Mar 26 at 20:55
2
$\begingroup$

I'm not totally sure RSolve is the best way to approach this; I'm also not sure the below is the best way to approach it either! But I was able to get it to work:

a0[m_] := Block[{a},
  a[-1] = 0; a[m + 1] = 0; 
  With[{eqs = Table[a[n] == n/m (v + b a[n - 1]) + (1 - n/m) (v - p + b a[n + 1]), {n, 0, m}],
        vars = Table[a[n], {n, 0, m}]}, 
       a[0] /. First @ Solve[eqs, vars]]]
$\endgroup$
1
  • $\begingroup$ This was super helpful. Thanks alot $\endgroup$ – Monire Jalili Mar 27 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.