# How to solve for multiple (cascading) recurrence relations

I am working with recurrence relations with a simple base:

$$$$Y_i = aY_{i-1} + (1-a)X_i \quad \mbox{and if Y_0=0 then} \quad Y_n = (1-a)\sum_{i=1}^n a^{i-1} X_i \tag{1}$$$$

here, $$X_i$$ are identically-distributed independent random variables (although I do not want to specify a distribution type). I am then interested to characterise the series $$Y_n$$ (its moments, correlation structure, etc.) in terms of those of $$X$$ and the parameter $$a$$.

I have done this by hand for (1) and have obtained relationships between $$\mathbf{E}[X_n]$$ and $$\mathbf{E}[Y_n]$$, $$\mathbf{Var}[X_n]$$ and $$\mathbf{Var}[Y_n]$$, $$\mathbf{skew}[X_n]$$ and $$\mathbf{skew}[Y_n]$$, $$\mathbf{Kurt}[X_n]$$ and $$\mathbf{Kurt}[Y_n]$$ and so on, up to order 6 moments. The algebra becomes rather tedious, but just about manageable.

However, I am now interested to feed this recurrence through a subsequent equation:

$$$$Z_{j} = bZ_{j-1} + (1-b)Y_j \quad \mbox{and if Z_0=0 then} \quad Z_n = (1-b)\sum_{j=1}^n b^{j-1} Y_j \tag{2}$$$$

and then find its moments. Having done that, I want to do it again.

My question is this: how (can ?) I use Mathematica to help me do this?

RSolveis the function you're looking for.

The second example evaluates to

Z = RSolveValue[{z[i + 1] == b z[i] + (1 - b) y[i], z[1] == 0}, z , i]
(*Function[{i}, b^(-1 + i) (\!$$\*UnderoverscriptBox[\(\[Sum]$$, $$K[1] = 0$$, $$\(-1$$ +i\)]$$-\((\((\(-1$$ + b)\)\ \*SuperscriptBox[$$b$$, $$-K[1]$$]\ y[K[1]])\)\)\) -y[0] + b y[0])]*)
Z[1]//Simplify
(*0*)


{Y, Z} = RSolveValue[{