# Phase portrait for three dimensional system of nonlinear difference equation using Mathematica

I am a student of M.Phil Mathematics. I am working on a non linear system of difference equations in three dimensions. I want to draw a phase portrait for my system using Mathematica. I was trying different codes for drawing a good phase portrait but nothing to do well. so I need help from you to solve this problem. your answer would be appreciated. If anyone of you have a Mathematica code for system of three nonlinear difference equations please share with me. My system for which I want to draw Phase Portrait:

x[n+1] = ((αx[n]-βx[n]y[n]-γx[n]z[n])/(1+δx[n]))
y[n+1] = ((ζy[n]+ηx[n]y[n]-μy[n]z[n])/(1+εy[n]))
z[n+1] = ((υz[n]+ρx[n]z[n]-σy[n]z[n])/(1+ωz[n]))


Where parameters α,β,γ,δ,ε,ζ,η,μ,ρ,σ,υ,ω ∈R⁺, and initial conditions x₀,y₀ and z₀ are positive real numbers.

• do you have specific values for the parameters and initial conditions? it is always best to provide so one does not have to guess. May 18, 2020 at 0:50
• yes sir. but i think you give me a complete code to draw it. it will be very helpful for me. there are different conditions on parameters which i will try it by your given mathematica code. if i have any problem in this section i will again comment here. Again a bundle of thanks with lot of prayers. May 19, 2020 at 4:43

Since you did not provide numerical values, I made some up.

Basically, what you could do is run RecurrenceTable on the 3 equations starting from some initial conditions, then use Graphics3D to plot the trajectory.

ClearAll["Global*"];
α = 1;
β = 2;
γ = 3;
δ = 4;
ζ = 5;
η = 6;
μ = 7;
ε = 8;
υ = 9;
ρ = 10;
σ = 11;
ω = 12;

eq1 = x[n + 1] == ((α x[n] - β x[n] y[n] - γ x[n] z[n])/(1 + δ x[n]));
eq2 = y[n + 1] == ((ζ y[n] + η x[n] y[n] - μ y[n] z[n])/(1 + ε y[n]));
eq3 = z[n + 1] == ((υ z[n] + ρ x[n] z[n] - σ y[n] z[n])/(1 + ω z[n]));

(*make sure in this below, to add decimal point to one of the
initial conditions numbers, which is 3.0 in this example. This
way computation is done in machine numbers which is much faster
otherwise it will take long time *)

tbl = RecurrenceTable[{eq1, eq2, eq3, x[0] == 1, y[0] == 2,
z[0] == 3.}, {x, y, z}, {n, 1, 100}];

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


The above gives one trajectory, starting from the initial conditions given. For different IC, you get different trajectory.

I have not seen a StreamPlot like function in Mathematica for discrete systems.

i want to draw these trajectotries in three different coloures. how can i change commands for mathematica to draw it in differnt three colours. like red for 'x' blue for 'y' and green for 'z'

The 3D trajectory is the "solution" itself. At each step, there is one single point. This point is in 3D space, so each point has 3 components. The table is just a list of all these points.

To draw x,y,z on each own, then we can use 1D plot, and plot x(n) vs. n and same for y and z. One possible way is below. The variable tbl used is the same one generated in the above code. So just pick the correct entry of each coordinate. First is x, second is y, and third is z.

p1 = ListLinePlot[tbl[[All, 1]], PlotStyle -> Red, BaseStyle -> 12,
PlotLabel -> "X component", AxesLabel -> {"n", "x[n]"}];

p2 = ListLinePlot[tbl[[All, 2]], PlotStyle -> Blue, BaseStyle -> 12,
PlotLabel -> "Y component", AxesLabel -> {"n", "y[n]"}];

p3 = ListLinePlot[tbl[[All, 3]], PlotStyle -> Black, BaseStyle -> 12,
PlotLabel -> "Z component", AxesLabel -> {"n", "z[n]"}];

Grid[{{p1, p2, p3}}, Spacings -> {1, 1}]


To put them all on top of each others:

 Show[{p1, p2, p3}, PlotLabel -> "X,Y,Z solutions"]


can i draw scatter plot of this system

I am not too sure what this should be in this context. May be this is what is needed?

tbl = RecurrenceTable[{eq1, eq2, eq3, x[0] == 1, y[0] == 2,
z[0] == 3.}, {x, y, z}, {n, 1, 500}];
ListPointPlot3D[tbl, PlotStyle -> {Red,PointSize[0.01]}]


You could also use same Graphics3D command above and change Line to Point

Graphics3D[Point[tbl], Axes -> True, AxesLabel -> {"x", "y", "z"},
BaseStyle -> 12]
`

• Thanks a lot sir. you solve my problem. may ALLAH bless you more. May 19, 2020 at 4:33
• @NASEER. sir if i want to draw these trajectotries in three different coloures. how can i change commands for mathematica to draw it in differnt three colours. like red for 'x' blue for 'y' and green for 'z'. May 19, 2020 at 4:59
• @MuhammadShoaib Please see updated answer. May 19, 2020 at 5:41
• @NASEER. Thanks sir. Well done sir. a last question is in my mind and i want to ask. can i draw scatter plot of this system? if draw please share the code. May 19, 2020 at 6:14
• @MuhammadShoaib I am not exactly sure what you mean here by scatter plot. If you mean point plot, then I updated the answer. If this is not what you want, may be you can post a link to an image of what it is supposed to be. May 19, 2020 at 6:37