Re: Foldlist Question

• To: mathgroup at smc.vnet.net
• Subject: [mg31430] Re: [mg31423] Foldlist Question
• From: Anton Antonov <antonov at wolfram.com>
• Date: Sat, 3 Nov 2001 18:25:07 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```
Hi Mark,
version to see its correctness.

Best,
Anton

==============================================================
Anton Antonov Antonov, PhD     *****     Wolfram Research Inc.
http://www.imm.dtu.dk/~uniaaa   ***   tel +1 217 398 0700 #782
==============================================================
Give me wings and I will crawl faster!
--------------------------------------------------------------

In[16]:= y[0] = y0; y[1] = y1; y[2] = y2;

In[19]:=
tbl=Table[y[t]=a+b*y[t-1]+c*y[t-2]+d*y[t-3]+e*x1[t]+f*x2[t],{t,3,5}]

Out[19]=
{a+d y0+c y1+b y2+e x1[3]+f x2[3],
a+d y1+c y2+e x1[4]+b (a+d y0+c y1+b y2+e x1[3]+f x2[3])+f x2[4],
a+d y2+e x1[5]+c (a+d y0+c y1+b y2+e x1[3]+f x2[3])+
b (a+d y1+c y2+e x1[4]+b (a+d y0+c y1+b y2+e x1[3]+f x2[3])+f
x2[4])+
f x2[5]}

In[20]:=
fld=FoldList[
Append[Drop[#1,1],a+b*#1[[3]]+c*#1[[2]]+d*#1[[1]]+e*x1[#2]+f*x2[#2]]&,{y0,
y1,y2},Range[3,5]]

Out[20]=
{{y0,y1,y2},{y1,y2,a+d y0+c y1+b y2+e x1[3]+f x2[3]},{y2,
a+d y0+c y1+b y2+e x1[3]+f x2[3],
a+d y1+c y2+e x1[4]+b (a+d y0+c y1+b y2+e x1[3]+f x2[3])+f x2[4]},{a+d
y0+
c y1+b y2+e x1[3]+f x2[3],
a+d y1+c y2+e x1[4]+b (a+d y0+c y1+b y2+e x1[3]+f x2[3])+f x2[4],
a+d y2+e x1[5]+c (a+d y0+c y1+b y2+e x1[3]+f x2[3])+
b (a+d y1+c y2+e x1[4]+b (a+d y0+c y1+b y2+e x1[3]+f x2[3])+f
x2[4])+
f x2[5]}}

In[21]:=
tbl[[-1]]===fld[[-1,-1]]

Out[21]=
True

On Sat, 3 Nov 2001, Coleman, Mark wrote:

> Greetings,
>
> 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[0] = y0, y[1]=y1,y[2]=y2, and x1 and x2 are known?
>
> Thanks,
>
> -Mark
>

```

• Prev by Date: Re: Fitting NormalDistribution to 2D List
• Next by Date: RE: Mathematica 4.0 features
• Previous by thread: Re: Foldlist Question
• Next by thread: Re: Zero does not equal Zero