Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Differences between recursions and limit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60552] Re: [mg60509] Differences between recursions and limit
  • From: <bsyehuda at gmail.com>
  • Date: Tue, 20 Sep 2005 05:19:08 -0400 (EDT)
  • References: <200509190845.EAA23449@smc.vnet.net> <76e8f8180509190525636016ea@mail.gmail.com>
  • Reply-to: bsyehuda at gmail.com
  • Sender: owner-wri-mathgroup at wolfram.com

p.s.
RSolve is not able to solve you recursive equation analytically.
However, you can get a numerical estimate by using FixedPoint
FixedPoint[0.25(1+#+#^2+#^3)&,0]
Returns 0.414214
You can also use FixedPointList to look at intermediate values returned by
the evaluation
FixedPointList[0.25(1+#+#^2+#^3)&,0]
this returns

{0, 0.25, 0.332031, 0.36972, 0.389238, 0.399929, 0.40596, 0.409417, 0.411416,
\
0.412579, 0.413258, 0.413654, 0.413886, 0.414022, 0.414101, 0.414148, \
0.414175, 0.414191, 0.4142, 0.414206, 0.414209, 0.414211, 0.414212, 0.414213,
\
0.414213, 0.414213, 0.414213, 0.414213, 0.414213, 0.414214, 0.414214, \
0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, \
0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, \
0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, \
0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, \
0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, 0.414214, \
0.414214}
yehuda

On 9/19/05, bsyehuda at gmail.com <bsyehuda at gmail.com> wrote:
>
> Hi,
> With the first programming style you recalculate each value right from the
> begining, so to calculate x[3] in terms of x[2], x[2] is calculated in terms
> of x[1] which is calculated from x[0], etc.
> The same happens for x[4], x[5], etc.
> The second programming style use a temporaty storage (your recursion is
> only one step back, so for this case it is sufficient), so calculation are
> replaced by looking at the storage, instead of re-computing as in the first
> exaample (one note, replace a:=b with a=b)
>
> You can achieve that automatically by using
> x[0]=0;
> x[k_]:=x[k]= .25 *(1 + x[k-1] + (x[k-1])^2 + (x[k-1])^3);
> This works for any degree of recursion. However you need to be aware that
> it consums memory.
> yehuda
>
> On 9/19/05, anbra1 <xyxanbra1 at tiscalixxxyxxx.it> wrote:
> >
> > Please,
> > I want to know
> > why these two recursions,doing the same thing,
> > are the first one much more slow than the second
> >
> > -------------------------
> >
> > x[0]=0;
> > x[k_] := .25 *(1 + x[k-1] + (x[k-1])^2 + (x[k-1])^3);
> >
> > For[k=1,k<12,Print[k," ",SetPrecision[x[k],30]];k++]
> >
> > -------------------------
> >
> > a=0;
> >
> > For[k=1,k<12,k++,
> >
> > b= .25 (1 + a + a^2 + a^3);a:=b;Print[k," ",SetPrecision[b,30]]]
> >
> > -------------------------
> > Another question
> > How can I calculate
> > the limit of this recursion for k->Infinite ?
> > Thank you all
> >
> >
> >
>



  • Prev by Date: Re: Decimal comma on input
  • Next by Date: Re: A Su Doku solver
  • Previous by thread: Re: Differences between recursions and limit
  • Next by thread: Re: Differences between recursions and limit