MathGroup Archive 2000

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

Search the Archive

Re: Sequence of functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24091] Re: [mg24065] Sequence of functions
  • From: BobHanlon at aol.com
  • Date: Fri, 23 Jun 2000 02:26:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 6/22/2000 1:17:41 AM, s-banerjee at nwu.edu writes:

>I am having a problem with defining a sequence of functions. A highly
>simplified version of the problem is given below:
>
>Suppose I define a function as follows, where the argument B is another
>function and ls is a list of numbers:
>
>Fx[ft_] := Block[ {g, h},
>    Do[
>      g[i][t_] := Sum[h[j][t], {j, i - 1}]; (* usually a more complicated
>function of h[j][t], j=1,...,i-1 here *)
>      Plot[g[i][t], {t, 0, 4}];
>      h[i][t_] := g[i][t]; (* usually a more complicated function of g[i][t]
>here *)
>      Plot[h[i][t], {t, 0, 4}],
>      {i, 1, 3}]
>    ]
>
>and then suppose we call Fx as
>Fx[{1, 2, 3}]
>
>Then at the beginning of the second iteration it says that the recursion
>depth is exceeded. I believe that this is happening because when it tries
>to
>evaluate g[2][t] it looks for h[1][t], but now h[1][t] is getting (wrongly)
>defined in terms of the current i (= 2) and hence goes into the recursion.
>
>How to get around this problem?
>

Try something along this line:

Fx[t_] := Block[ {g, h},
      g[1][x_] = x;
      g[i_][x_] := Sum[h[j][x], {j, i - 1}];
      h[i_][x_] := g[i][x]; 
      Table[g[i][t], {i, 1, 6}]];

Fx[t]

{t, t, 2*t, 4*t, 8*t, 16*t}


Bob Hanlon


  • Prev by Date: RE: mean of geometric and negative binomial distributions
  • Next by Date: RE: Appearance of Pasted Text in Input Cells
  • Previous by thread: Sequence of functions
  • Next by thread: Re: Sequence of functions