1
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ Welcome to Mathematica StackExchange! First, there seems to be some syntacti errors in your definition of equations (for example, a Table is missing). Second, what are Y and p? Are these just two parameters? Do you know their values? Lastly, only first Y equations are recursive, the remaining ones are explicit. So you should separate the two. For example, solving the first Y=5 equations: $\endgroup$ Commented Dec 28, 2023 at 17:45
  • 2
    $\begingroup$ 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$ Commented Dec 28, 2023 at 17:45
  • $\begingroup$ Thank you for your help. Y and p are symbolic system parameters and I am trying to analytically solve for the steady-state distribution of a Markov Chain. Your example with Y=5 does seem to give the right equations, but could you suggest how would I extend this to an arbitrary Y? $\endgroup$ Commented Dec 28, 2023 at 19:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.