       Re: Foldlist Question

• To: mathgroup at smc.vnet.net
• Subject: [mg31425] Re: Foldlist Question
• From: Tom Burton <tburton at cts.com>
• Date: Sat, 3 Nov 2001 18:25:02 -0500 (EST)
• Organization: Brahea Consulting
• References: <9s0i2t\$n78\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On Sat, 3 Nov 2001 10:49:01 +0000 (UTC), in comp.soft-sys.math.mathematica you wrote:

>How can I use FoldList to find the values of the recurrence relationship
>like
>
>
>
>   y[t] = a+b*y[t-1]+c*y[t-2]+d*y[t-3] + e*x1[t] + f*x2[t]
>
>
>assuming y = y0, y=y1,y=y2, and x1 and x2 are known?

First I would recast your third-order recurrence relation in a single variable as a first-order relation of three variables, because FoldList looks only one step back:

step[{ym1_, ym2_, ym3_}, {x1_, x2_}] :=
{a + b*ym1 + c*ym2 + d*ym3 + e*x1 + f*x2, ym1, ym2}

Next, prepare a table of variable coefficients. Replace "6" with the last value of t you want to see.

x12 = Table[{x1[t], x2[t]}, {t, 3, 6}]

Then

res = FoldList[step, {y2, y1, y0}, x12];
answer = Join[{y0, y1}, First /@ res]
Tom

```

• Prev by Date: how to limit digits?
• Next by Date: Re: image in PDF file
• Previous by thread: Foldlist Question
• Next by thread: Re: Foldlist Question