MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: question RE: difference equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26111] Re: [mg26066] question RE: difference equations
  • From: BobHanlon at aol.com
  • Date: Tue, 28 Nov 2000 01:55:58 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 11/22/00 2:44:07 AM, john.mcarthur at brasenose.oxford.ac.uk 
writes:

>I am a new Mathematica user so apologize for the basic nature of my
>question:
>
>I want to set up a system of simultaneous difference equations but am
>having trouble with the syntax. Essentially I would like to map the growth
>of a system as follows:
>
>y1(t)=y1(t-1) + a*y2(t-1) + b*y3(t-1)... + xx*yn(t-1)
>y2(t)=y2(t-1) + c*y1(t-1) + d*y3(t-1)... + yy*yn(t-1)
>...
>yn(t)=yn(t-1) + x*y1(t-1) + z*y2(t-1)... + zz*y[n-1](t-1)
>
>I know how to set up a univariate recursive equation, but am not clear
>on
>how to set up a multivariate form. My most common error message is one
>of
>"recursion limit reached."  Any suggestions (and possibly advice
>on the simplest way to set up a system like the one above) would be
>greatly appreciated.
>

dim = 3;

var = Table[ToExpression["y" <> ToString[k]], {k, dim}];

coef = {{1, 2, -3}, {1, 0, 1}, {1, -2, 2}};

Clear[Evaluate[Sequence @@ var]];

Initialize recursion:

(#[0] = 1) & /@ var;

Thread[Evaluate[#[t_?Positive] & /@ var] := 
      Evaluate[coef.(#[t - 1] & /@ var)]];

For example, the definition of y1 is

?y1

"Global`y1"

y1[0] = 1
 
y1[(t_)?Positive] := y1[-1 + t] + 2*y2[-1 + t] - 3*y3[-1 + t]

Table[#[k] & /@ var, {k, -1, 5}] // ColumnForm

{y1[-1], y2[-1], y3[-1]}
{1, 1, 1}
{0, 2, 1}
{1, 1, -2}
{9, -1, -5}
{22, 4, 1}
{27, 23, 16}


Bob Hanlon


  • Prev by Date: "up" in 3D animations
  • Next by Date: Re: question RE: difference equations
  • Previous by thread: Re: question RE: difference equations
  • Next by thread: Re: question RE: difference equations