[Date Index]
[Thread Index]
[Author Index]
Re: iterative method?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg95742] Re: iterative method?
*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
*Date*: Sun, 25 Jan 2009 21:51:24 -0500 (EST)
*Organization*: The Open University, Milton Keynes, UK
*References*: <glhjnu$is$1@smc.vnet.net>
In article <glhjnu$is$1 at smc.vnet.net>, matt <trex1704 at yahoo.com> wrote:
> How to find x_(n+1)=(a*x_n+b*y_n)/c*x_n , y_(n+1)=d*x_n*y_n using
> mathematica?
> I want to find a list of x and y when n=1,2,...,50
> so I defined the function as f[{x_,y_}]:={a*x_n+b*y_n)/c*x_n,d*x_n*y_... }
> and then use the function NestList[f,{2,5},50] with initial value of x is 2
> and y is 5
> with this, I got the list of 50 values of (x,y).
> The problem is I want to plot graphs of x against n and y against n, n from 1
> to 50 because I want to see what happened if n goes to infinity. But if use
> the method I just mentioned, I can only plot x against y.
> So do anyone have a clever method??
> Btw...a,b,c and d are constants and given and x_n is supposed to be x
> (subscript n)...same case with x_(n+1) and the others
You could use recursive definitions for x_n and y_n. For instance,
ClearAll[x, y]; x[1] = 2; y[1] = 5;
x[n_Integer /; n > 1] :=
x[n] = (a*x[n - 1] + b*y[n - 1])/(c*x[n - 1])
y[n_Integer /; n > 1] := y[n] = d*x[n - 1]*y[n - 1]
Block[{a = 2, b = 3, c = 5, d = 7},
Print[Table[{x[n], y[n]}, {n, 1, 5}]];
Print[ListLogPlot[Table[{n, x[n]}, {n, 1, 30}], Filling -> Bottom]];
Print[ListLogPlot[Table[{n, y[n]}, {n, 1, 30}], Filling -> Bottom]];
]
Regards,
--Jean-Marc
Prev by Date:
**Re: Which editor do you use for math articles**
Next by Date:
**Re: Re: Frames on Density Plots in Version 7**
Previous by thread:
**Re: iterative method?**
Next by thread:
**Re: Why does the Shooting Method fail?**
| |