Math 4452 (Peh Ng)

Here are a few examples of how to solve a class of discrete dynamical system, using mathematica

First,  clear all functions:

Clear[a,b,c]

Then type in the commands followed by Shift-Return

RSolve[{a[n]==a[n-1]+a[n-2],a[0]==a[1]==1},a[n],n]

If you need a table of numerical values, use Table, and we can also name our Table:

P=Table[{n, (a[n]/.%)[[1]]},{n,0,10}]//Expand

Since we named our Table of values as P, we can now plot P:

ListPlot[P,PlotStyle -> {RGBColor[0,0,1],PointSize[0.02]}, AxesLabel -> {"n", " a_n"} ]

This is a linear, homogeneous DDS   with variable coefficients.

RSolve[{a[0]==a[1]==2,(n+1) (n+2) a[n+2]-2 (n+1) a[n+1]-3 a[n]==0},a[n],n]

The following command solves a pair of coupled equations.Notice that it is possible to get the solution in pure\[Hyphen]function form,by specifying{a, b}rather than{a[n], b[n]}.

RSolve[{a[n+1]-3 b[n]-4 a[n]==1,a[n+1]+b[n+1]+b[n]==n,a[0]==b[0]==0},{a,b},n]

Table[({a[n],b[n]}/.%)[[1]],{n,0,10}]//Expand

RSolve[{a[n+1]-8 b[n]-7 a[n]==0,b[n+1]-6b[n]==0,a[0]==2,b[0]==3},{a,b},n]

If you cannot find the solution in closed form, as in:

RSolve[{a[n+1]-2 (b[n])* (a[n])==0,b[n+1]-6b[n]==0,a[0]==2,b[0]==3},{a,b},n]

then, you need a table of several values of a[n] and b[n], as in:

a[0]=2.0
b[0]=3.0
Table[{a[n+1]=2*a[n]*b[n], b[n+1]=6*b[n]},{n,0,15}]//Expand//TableForm

We could also name our Table of plots as P:

a[0]=2.0
b[0]=3.0
P=Table[{a[n+1]=0.15*a[n]*b[n], b[n+1]=0.9*b[n]},{n,0,10}]

then plot P as a list of points:

ListPlot[P, PlotStyle -> {RGBColor[1,0,0],PointSize[0.02]},  AxesLabel -> {"a_n", "b_n "}]

a[0]=2.0
b[0]=3.0
P=Table[{a[n+1]=0.85*a[n] + 0.8*b[n], b[n+1]=-0.1a[n] + 0.9*b[n]},{n,0,20}]

ListPlot[P,PlotStyle -> {RGBColor[1,0,1],PointSize[0.02]},  AxesLabel -> {"a_n", "b_n "}]

a[0]=5.0
b[0]=2.0
P=Table[{a[n+1]=5*a[n] + 2*b[n] +1, b[n+1]=6*b[n]},{n,0,10}]

ListPlot[P, PlotStyle -> {RGBColor[0.5,0,1],PointSize[0.02]},  AxesLabel -> {"a_n", "b_n "}]

a[0]=45.0
b[0]=80.0
P=Table[{a[n+1]=0.5*a[n] + 0.4*b[n] +1, b[n+1]=-0.104*a[n] + 1.1*b[n]},{n,0,30}]

ListPlot[P, PlotStyle -> {RGBColor[0,1,0.5],PointSize[0.02]},  AxesLabel -> {"a_n", "b_n "}]

a[0]=140.0
b[0]=50.0
P=Table[{a[n+1]=0.5*a[n] + 0.4*b[n] +1, b[n+1]=-0.104*a[n] + 1.1*b[n]},{n,0,50}]

ListPlot[P, PlotStyle -> {RGBColor[0.5,0,1],PointSize[0.02]},  AxesLabel -> {"a_n", "b_n "}]