I am interested in solving the following two variable recursion relation:
$$ S(z,x)\ =q\cdot S(z+1,x-1)+r\cdot S(z+1,x)+p\cdot S(z,x-1) $$ $$ 0\le z\le3 $$ $$ 0\le x\le5 $$ $$ p+q+r=1 $$
For context on how I got this relation and what it means, consider the following problem:
We have the Cartesian z-x plane (z being the vertical axis and x being the horizontal axis). We begin at the point z = 3, x = 0. From any given point, we have probability "p" of moving one unit to the right (in the +x̂ direction), probability "q" of moving one unit right AND one unit down (in the x̂-ẑ direction), and probability "r" of moving one unit down (in the -ẑ direction). Each step is independent and mutually exclusive from one another. We continue this random walk until z = 0 or x = 5. I am looking for a closed form solution for the probability of being at point (z,x) after any given step in the random walk, which I believe can be correctly expressed as S(z,x) in the recursion above.
A couple of potential base cases: $$ S(3,x) = p^x $$ $$ S(z,0) = r^{3-z} $$
My first attempts were focused on finding a generating function in the form of $$ F\left(z,x\right)\ =\sum_{i}^{ }\sum_{j}^{ }S\left(z,x\right)z^{i}x^{j} $$
and try to get a closed form solution for S(z, x), but I have little experience with generating functions, especially in two variables, so did not get very far.
Edit / update:
Upon further inspection, I think the above relation is incomplete. In order to fully model the probability of being at point (z,x), we need to specify the probability of getting to that point in an exact number of steps. This expands our random walk into a third dimension,"step number", which can be labeled with a y-axis orthogonal to the z-x plane. We need to express the probability to be at a certain point as a function of step number as well (ex: probability to move from starting state (z0, x0, y0) = (3, 0 ,0) to state (z1, x1, y1) = (3, 1, 1) is equal to p, while the probability to be back in state (z1, x1, y1) is 0 for all y > 1). I believe we should then update the recursion that describes the random walk to three variables: $$ S(z,x,y)\ =q\cdot S(z+1,x-1,y-1)+r\cdot S(z+1,x,y-1)+p\cdot S(z,x-1,y-1) $$ $$ 0\le z\le3 $$ $$ 0\le x\le5 $$ $$ p+q+r=1 $$
Our minimum number of steps is 1 and our maximum number of steps is 5, before either z=0 or x=5. So, $$ 1\le y\le5 $$ Since we walk one step at a time, and always move from the previous step one unit in the +ŷ direction, we add a y-1 to each term in our relation. We would then solve for a closed form expression as a function of z, x and y. My ultimate goal is to solve for the total probability to make it to x=5, which I imagine can be done by setting x=5 and integrating our expression with respect to z and y using their upper and lower bounds. I realize at this point it is probably easier to solve for the probability to make it to x=5 combinatorially by writing down the possible permutations of steps before we achieve x=5, however I want to generalize the solution as a random walk so I can apply the strategy to more complex walks of the same nature (which become dauntingly difficult to solve by writing down each permutation).