Re: Graphing Difference Equation
- To: mathgroup at smc.vnet.net
- Subject: [mg91415] Re: Graphing Difference Equation
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 21 Aug 2008 04:13:53 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <g8gj3h$eso$1@smc.vnet.net>
Walkman wrote:
> I have a trouble in graphing differece equation using mathematica.
>
> For instance, I get a difference equation,
>
> y_{t} = 1.5y_{t-1} - .5y_{t-2} = 0
>
> Since I don't know how to input the code for graphics and just want
>
> to check how the graph looks like,
>
> I input the solution instead, A(-1.2)^t + B(.5)^t where A and B
>
> constants
>
> For simplicity, I choose A = B = 1.
>
> Plot[(-1.2)^t + (.5)^t,{t,0,20}]
>
> The problem is that it doesn't work at all.
>
> If anyone who know exact way to graph difference equation, plz
>
> tell me.
The plotting function *ListPlot* [1], combined with *Table* [2], should
generate the desired graph. For instance,
In[1]:= pts = Table[{t, (-1.2)^t + (.5)^t}, {t, 0, 20}]
ListPlot[pts, Filling -> Axis]
Out[1]= {{0, 2}, {1, -0.7}, {2, 1.69}, {3, -1.603}, {4,
2.1361}, {5, -2.45707}, {6, 3.00161}, {7, -3.57537}, {8,
4.30372}, {9, -5.15783}, {10, 6.19271}, {11, -7.4296}, {12,
8.91634}, {13, -10.6992}, {14, 12.8392}, {15, -15.407}, {16,
18.4884}, {17, -22.1861}, {18, 26.6233}, {19, -31.948}, {20,
38.3376}}
Out[2]= [... graphic displayed w/ points above & below the x-axis ...]
Also, note that difference equations can be solved with *RSolve* [3].
Regards,
-- Jean-Marc
[1] http://reference.wolfram.com/mathematica/ref/ListPlot.html
[2] http://reference.wolfram.com/mathematica/ref/Table.html
[3] http://reference.wolfram.com/mathematica/ref/RSolve.html