# Solve 2D Difference Equations

If I have a system of difference equations

$$\begin{cases} x(n + 1) = x(n) + x(n) y(n) + y(n)^2 \\ y(n + 1) = y(n) - x(n)^2 + y(n)^2 \end{cases}, \text{ with } \begin{cases} x(0) = 1\\ y(0) = 2 \end{cases}.$$

How can I solve it by Mathematica?

I tried this but I do not know if it is correct

RSolve[{x[n + 1] == x(n) + x(n) y(n) + y(n)^2,
y[n + 1] == y(n) - x(n)^2 + y(n)^2},
{x[n], y[n]}, n
]


Thank you for help!

• I think you need to use [] and not (). But when I tried it, it could not solve it. eq1 = x[n + 1] == x[n] + x[n]*y[n] + y[n]^2; eq2 = y[n + 1] == y[n] - x[n]^2 + y[n]^2; ic = {x[0] == 1, y[0] == 2}; RSolve[{eq1, eq2, ic}, {x[n], y[n]}, n] because it is non-linear, it returned unevaluated. – Nasser Jun 27 at 4:37
• Dear Nasser. you are right for linear.. but my broblem with not linear. Thank you for the reply ... Saud – S A Jun 27 at 5:13

Mathematica can not solve it since they are non-linear. The correct syntax is

eq1 = x[n + 1] == x[n] + x[n]*y[n] + y[n]^2;
eq2 = y[n + 1] == y[n] - x[n]^2 + y[n]^2;
ic  = {x[0] == 1, y[0] == 2};
sol = RSolve[{eq1, eq2, ic}, {x[n], y[n]}, n]


Another possibility is to try RecurrenceTable. Which gives you numerical value of x[n] and y[n] for as n increases. This shows your equations are not stable.

tbl = RecurrenceTable[{eq1, eq2, ic}, {x[n], y[n]}, {n, 0, 5}];


which gives

{{1., 2.}, {7., 5.}, {67., -19.}, {-845., -4147.},
{2.0701*10^7, 1.64794*10^7}, {6.12712*10^14, -1.56959*10^14}}


You can see the solutions blow up very quickly. After only 4 iterations.

Graphics[Line[tbl], Axes -> True, AxesLabel -> {"x", "y"}, BaseStyle -> 12]


So you might want to look at how you generated these equations. May be your model is wrong somewhere.