# Solving recurrence relations

I have the following recurrence system:

$$\pi_0 =.25\pi_0 + .25q\pi_1+.5q\pi_2 + q\pi_3$$ $$\pi_1 =.25\pi_0 + .25q\pi_1+.5\pi_2 + p\pi_3$$ $$\pi_2 =.25\pi_0 + .25p\pi_1+.5p\pi_2 + 0$$ $$\pi_3 =.25\pi_0 + .25p\pi_1+0 + 0$$ $$1 =\pi_0 + \pi_1+\pi_2 + \pi_3$$

I tried the following to solve this system:

Rsolve[{a[0] == 0.25*a[0] + 0.25 *a[1] *q + 0.5* a[2] *q + a[3] *q, a[1] == 0.25* a[0] + 0.5 *a[2] + p *a[3] + 0.25* a[1] *q, a[2] == .25 *a[0] + 0.25* p *a[1] + 0.5* p *a[2], a[3] = 0.25* a[0] + 0.25*p *a[1], 1 == a[0] + a[1] + a[2] + a[3]}, a, 4]


Which gives the following error:

Set::write: Tag Real in 0.4[3] is Protected.


and I also tried the following:

Solve[{0.25 pi0 + 0.25 pi1 q + 0.5 pi2 q + pi3 q, 0.25 pi0 + 0.5 pi2 + p pi3 + 0.25 pi1 q, 0.25 pi0 + 0.25 p pi1 + 0.5 p pi2, 0.25 pi0 + 0.25 p pi1, pi0 + pi1 + pi2 + pi3} == {pi0, pi1, pi2, pi3, 1}, {pi0, pi1, pi2, pi3}]


but it gave me an empty list:

{}


I substituted p and q with .5 and .5 respectively. Then, I solved the system using MATLAB, and it gave me a solution for $\pi_{i, i={0,..,3}}$ which equals to

0.2951
0.3274
0.2111
0.1594


So, the system does have a solution. But I'm not able to find the solution using Mathematica.

I also tried to convert this into linear system as the following:

$$0 =-.75\pi_0 + .25q\pi_1+.5q\pi_2 + q\pi_3$$ $$0 =.25\pi_0 + (.25q - 1)\pi_1+.5\pi_2 + p\pi_3$$ $$0 =.25\pi_0 + .25p\pi_1+(.5p-1)\pi_2 + 0$$ $$0 =.25\pi_0 + .25p\pi_1+0 -\pi_3$$ $$1 =\pi_0 + \pi_1+\pi_2 + \pi_3$$

and then using this code

Solve[{-.75 pi0 + 0.25 pi1 q + 0.5 pi2 q + pi3 q,
0.25 pi0 + 0.5 pi2 + p pi3 + (1 - 0.25 q) pi1 q,
0.25 pi0 + 0.25 p pi1 + (0.5 p - 1) pi2,
0.25 pi0 + 0.25 p pi1 - pi3, pi0 + pi1 + pi2 + pi3} == {0, 0, 0, 0,
1}, {pi0, pi1, pi2, pi3}]


but it also gave me an empty list

{}

• You have one = that should be an ==. That explains your write error. RSolve is going to find solutions for a in terms of n, not for a in terms of 4. Look at the examples in the help pages to see how RSolve works usually. Reduce[yourSystem,{a[0],a[1],a[2],a[3]}] can find ugly solutions for each of the four a[i] if that is what your are looking for.
– Bill
Apr 22, 2018 at 1:00
• @Bill yes, you're right. I tried to convert it to an ordinary linear system but also it didn't work, see the edit. Apr 22, 2018 at 2:23
• Those values are not solutions. Substitute them and see it. Apr 22, 2018 at 3:01
• This Reduce[{-3 p0+p1 q+2p2 q+4p3 q==0,p0+2p2+4p p3+(4-q)p1 q==0,p0+p p1+(2p-4)p2==0,p0+p p1-4p3==0,p0+p1+p2+p3==1},{p0,p1,p2,p3}] claims that p is any root of a cubic, a condition must be true, q is any root of an 11th degree polynomial and then there are the four values for p0,p1,p2,p3 in terms of p and q. You might try finding those 3x11 pairs of roots one at a time, verify the condition and then verify which of those 33 p0,p1,p2,p3 do satisfy your original problem
– Bill
Apr 22, 2018 at 16:23
• @cyberic The system is inconsistent. I show this below.
– Alan
Apr 22, 2018 at 20:19

There is no reason to expect a 5-equation linear system in 4 variables to have a solution. But the problem is worse because of your parameterization. To see this, let

eqns = {
a[0] == (1/4)*a[0] + (1/4)*a[1]*q + (1/2)*a[2]*q + a[3]*q,
a[1] == (1/4)*a[0] + (1/4)*a[2] + p*a[3] + (1/4)*a[1]*q,
a[2] == (1/4)*a[0] + (1/4)*p*a[1] + (1/2)*p*a[2],
a[3] == (1/4)*a[0] + (1/4)*p*a[1],
1 == a[0] + a[1] + a[2] + a[3]
}


and compare

s1 = Solve[eqns[[1]] && eqns[[2]], {a[2], a[3]}] //Apart


to

s2 = Solve[eqns[[3]] && eqns[[4]], {a[2], a[3]}] //Apart


These cannot both be satisfied for arbitrary values of p and q unless a[0]==0 and a1==0, imply that a[2]==0 and a[3]==0 as well. Seting p==1/2, as you proposed, render this particularly obvious: the trivial (all zero) solution is then evidently the only possible solution to the first four equations.