# Why does RSolve not give what I expect?

I have a model based on a digraph G. I construct a system of difference equations, modelFull, as seen below.

ClearAll[n, d, G, aG, aGsym, Xt, gama, teta, tao, alfa, one, eta,
onePlusEta, Aterm, Bterm, Cterm, Dterm, Xt1];
SeedRandom[14];
n = 10;
d = 0.3;
G = RandomGraph[{Round[n], Round[n*(n - 1)*d]}, DirectedEdges -> True];
aGsym = BitAnd[aG, Transpose[aG]]; (* by @Coolwater *)

Xt = DiagonalMatrix[Array[Subscript[x, #][t] &, n]];
alfa = Transpose@Array[\[Alpha][#] &, {n, n}];
eta = Array[\[Eta][#] &, n];
gama = Transpose[Array[\[Gamma][#] &, {n, n}]]*aG;
tao = Array[\[Tau][#] &, {n, n}];
teta = Transpose[Array[\[Theta][#] &, {n, n}]*aG];
one = Array[1 &, n];

onePlusEta = DiagonalMatrix[one + eta]*Xt;
Aterm = (gama + teta).Xt;
Bterm = Xt.((alfa*tao)*aG);
Cterm = ((alfa*alfa)*aGsym)*(Xt.Array[Diagonal[Xt] &, {n}])*aGsym;
Dterm = ((gama*gama)*aGsym)*Transpose[Array[(Subscript[x, #][t])^2 &, {n, n}]*aGsym];

Xt1 = Array[Subscript[x, #][t + 1] &, n];
eqs = Total[onePlusEta - Aterm + Bterm + Cterm - Dterm];


So far, everything works fine. I have all my difference equations in modelFull. Then I parametrize the modelFull as follows:

ClearAll[params, parameters, sol];
params = {abs, random, absCost, trsCost, trs} =
{
RandomReal[{0.01, 1}, n],
RandomReal[{-0.5, 0.5}, n],
RandomReal[{0.01, 1}, n],
RandomReal[{0.01, 1}, n],
RandomReal[{0.01, 1}, n]
};
{\[Alpha], \[Eta], \[Gamma], \[Tau], \[Theta]} ->params]];


Then I construct RSolve as:

  sol = RSolve[{modelFull /. parameters, Array[Subscript[x, #][0] == 1 &, n]} // Flatten,
Array[Subscript[x, #][t] &, n], t] // Flatten


The output from this RSolve is:

ReplaceAll::reps: {RSolve[{Subscript[x, 1][1+t]==-2.84077 Subscript[x, 1][t]-0.38506 Subscript[<<2>>][<<1>>]^2+0.441027 Subscript[x, 2][t]+0.513668 Subscript[x, 3][t]+0.818674 Subscript[x, 4][t]+0.343748 Subscript[x, 7][t]+0.977052 Subscript[x, 1][t] Subscript[x, 7][t]+0.817954 Subscript[x, 8][t]+0.977052 Subscript[x, 1][t] Subscript[x, 8][t]+0.101168 Subscript[x, 9][t],<<18>>,Subscript[x, 10][0]==1},{Subscript[x, 1][t],Subscript[x, 2][t],Subscript[x, 3][t],<<5>>,Subscript[x, 9][t],Subscript[x, 10][t]},t]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>

RSolve::dsvar: 1.0001838571428572 cannot be used as a variable. >>

What is missing/wrong in my code?

• I cannot reproduce the error. Try running your code in a fresh notebook. However, RSolve appears to be unable to solve the nonlinear problem. – bbgodfrey Oct 29 '18 at 2:08
• @bbgodfrey: I will do your suggestion now and let you know. Thanks. – Tugrul Temel Oct 29 '18 at 2:11
• TIP: don't use subscripts. – AccidentalFourierTransform Oct 29 '18 at 2:17
• @TugrulTemel For example, Array[x[#][t] &, 3]. – AccidentalFourierTransform Oct 29 '18 at 2:27
• I'm glad that your code is running now. As I already mentioned, RSolve returns unevaluated. RecurrenceTable`, on the other hand, yields numerical values, although they grow exponentially in magnitude. – bbgodfrey Oct 29 '18 at 2:31