       Re: Recursive Rules

• To: mathgroup at smc.vnet.net
• Subject: [mg31152] Re: [mg31147] Recursive Rules
• From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
• Date: Sun, 14 Oct 2001 04:11:45 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```I depends what you mean. The following are essentially equivalent

In:=
f[t_] :=  a + b*f[t-1]

In:=
f=1;

In:=
f//Expand

Out=
a + a*b + a*b^2 + b^3

and

In:=
Clear[f]

In:=
f=1;

In:=
a+b f//.f[t_/;t>1]-> a + b*f[t-1]//Expand

Out=
a + a*b + a*b^2 + b^3

example was "dynamic programming", produced by the construction
f[t_]:=f[t] = ...  I don't think there is any way to do this using Rule
for after all Rule does not assign any global values. (Maybe someone can
think of some fiendish trick to do so but if so it will probably involve
some sort of cheating, like using = somewhere )

Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/

On Saturday, October 13, 2001, at 03:47  PM, Mark S. Coleman wrote:

> Greetings,
>
> I know that a recurrent/recursive function can be written
>
> f[t_] := f[t] = a + b*f[t-1].
>
> So that once an initial value is stipulated, e.g., f=0, then the
> function "remembers" past values and can correctly calculate f[] for
> any t.
>
> I was wondering if it was possible to do the same thing with a Rule?
>
> Thanks,
>
> -Mark
>
>

```

• Prev by Date: Re: How do I eliminate premultipliers of "1." ?
• Next by Date: Re: How do I eliminate premultipliers of "1." ?
• Previous by thread: Re: Recursive Rules