I am trying to solve a system of equations in Mathematica where the variables are recursively defined. The system represents a probability distribution, and I want to find the values of the variables that satisfy the equations. However, I am encountering a recursion depth error, and I'm having difficulty resolving it.
Here is the Mathematica code I am using:
Clear[Y, p, pi]
equations = {
pi[1] == p,
Table[pi[i] == p (1 - p)^(i - 1) (Sum[pi[j], {j, 1, Y - i + 1}]), {i, 2, Y - 1}],
pi[Y] == p (1 - p)^(Y - 1) pi[1],
pi[Y + i] == p (1 + p) (1 - p)^(Y + i - 1), {i, 1, Infinity},
Sum[pi[i], {i, 1, Infinity}] == 1
}
(* Solve the system of equations *)
solution = Solve[equations, Table[pi[i], {i, 1, Infinity}]]
Upon running this code, I encounter the error: $RecursionLimit: Recursion depth of 1024 exceeded.
I suspect that there might be an issue with the recursive definition of the variables. Could someone please help me understand how to properly set up and solve a system of equations with such recursive definitions?
Table
is missing). Second, what areY
andp
? Are these just two parameters? Do you know their values? Lastly, only firstY
equations are recursive, the remaining ones are explicit. So you should separate the two. For example, solving the firstY=5
equations: $\endgroup$With[{Y = 5},equations = Flatten@{pi[1] == p,Table[pi[i] == p (1 - p)^(-1 + i) (Sum[pi[j], {j, 1, Y - i + 1}]), {i, 2, Y - 1}]};Echo[equations // Column, "Equations"];solution = Solve[equations, {p}~Join~Table[pi[i], {i, 1, Y - 1}]] ]
$\endgroup$Y
andp
are symbolic system parameters and I am trying to analytically solve for the steady-state distribution of a Markov Chain. Your example withY=5
does seem to give the right equations, but could you suggest how would I extend this to an arbitraryY
? $\endgroup$