# Plotting system of recursive sequences [duplicate]

If I have a system of recursive sequences like

x[n+1]=2x[n]+5(y[n])^2

y[n+1]=.5x[n]-3(y[n])^2


How can I plot it as a curves {x[n],n} and {y[n],n} in the same figure?? When I work with this code, I get the error as in the image ]1

• – zhk Jan 19 '17 at 5:37
• What initial conditions, {x, y} do you wish? – bbgodfrey Jan 19 '17 at 5:50
• Thank you very much! "But when I copied this code in Mathematica 7. I get the error message: ListLinePlot::optx: Unknown option PlotLegends in ListLinePlot[{{1.,22.,705.25},{2.,-11.5,-385.75}},<<4>>,PlotLegends->{x,y}]. >>" – Raafat Jan 19 '17 at 14:25
• @Raafat Load the package. << PlotLegends  – zhk Jan 19 '17 at 15:23
• @Raafat Mathematica 7 does not have PlotLegends; you will need to load the package as MMM says but also use PlotLegend with no s, and parameters for the two options are not the same. – Mr.Wizard Jan 19 '17 at 23:29

RecurrenceTable will be useful here. Note, I choose random initial conditions.

sol = RecurrenceTable[{x[n + 1] == 2  x[n] + 5 (y[n])^2,
y[n + 1] == 0.5  x[n] - 3 (y[n])^2, x == 1, y == 2}, {x,
y}, {n, 0, 2}, WorkingPrecision -> MachinePrecision];

ListLinePlot[Transpose@sol,
PlotStyle -> {Directive[Red, Thick],
Directive[Blue, AbsoluteDashing[{10, 10}]]}, Joined -> True,
Frame -> True, FrameLabel -> (Style[#, 22, Bold] & /@ {"n", ""}),
PlotLegends -> {x,  y}] You can also use @David G. Stork method.

x[n_] := 2  x[n - 1] + 5 (y[n - 1])^2;
y[n_] := 0.5  x[n - 1] - 3 (y[n - 1])^2;
x := 1;
y := 2;
ListLinePlot[Transpose@Table[{x[n], y[n]}, {n, 0, 2}],
PlotLegends -> {"x", "y"}]

• No, but I have an error when i do! – Raafat Jan 19 '17 at 14:56
• @Raafat Doing what produces an error? – zhk Jan 19 '17 at 14:57
• I have copied the code and use it in mathematica. But it gives the error message: " ListLinePlot::optx: Unknown option PlotLegends in ListLinePlot[{{1,22,705.25},{2,-11.5,-385.75}},PlotLegends->{x,y}]. >>" – Raafat Jan 19 '17 at 15:01
• Thank you for help! the code does work. But without "PlotLegends -> {"x", "y"}"!! Do you have a solution to that ?! – Raafat Jan 19 '17 at 15:23
• @Raafat load the package. << PlotLegends` – zhk Jan 19 '17 at 15:24