MathGroup Archive 2003

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

Search the Archive

Re: Plot a recurrence relation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40169] Re: Plot a recurrence relation
  • From: "John Jowett" <John.Jowett at cern.ch>
  • Date: Tue, 25 Mar 2003 03:01:47 -0500 (EST)
  • Organization: CERN
  • References: <b5mj14$rsa$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Here's one way:

ListPlot[
             NestList[{#1[[1]] + 1, #1[[2]]/(2*#1[[1]] - 1)} & , {0, 6},
20],
           PlotRange -> All, PlotJoined -> True]

If that's too cryptic, define a function to do a step of your iteration, on
the pair {n,a}

f[{n_,a_}]={n+1,a/(2n-7)}

This calculates 20 iterations from your starting point

iters=NestList[f,{0,6},20]

and this plots the results with some appropriate options

ListPlot[iters,PlotRange->All,Prolog -> PointSize[0.03]]

Of course there are 101 other ways, but this is an example of Mathematica's
functional programming style, avoiding loops. The first version also avoids
the need to define any function or variable names.

John Jowett


"David" <davidol at hushmail.com> wrote in message
news:b5mj14$rsa$1 at smc.vnet.net...
> How can I get mathematica to plot a sequence that's defined recursively
e.g.
>
> a_0 = 6
> a_(n+1) = a_n / (2n - 7)
>
> Cheers.
>
>
>




  • Prev by Date: Memory Use growth
  • Next by Date: Re: Strange behavior of Simplify
  • Previous by thread: RE: Plot a recurrence relation
  • Next by thread: Re: Plot a recurrence relation