MathGroup Archive 2006

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

Search the Archive

Re: calculate Recurrence Equations


Hello

If you modify (your expression) to:

anteil[0] = 1;
anteil[n_] := (anteil[n] = anteil[n - 1] + (anteil[n - 1]*5 - 1)/100 )
anteil[30]//N

you can save the intermediate calculations. But even with this
modification you will run into problems for large n (a few 100),
because you build up your expression starting with the last index = n
and you will get a deeply nested expression (which might use up the
memory of your computer).

I would rather use the following command (which forward calculates the
expression starting with the starting value=1):

n=1000;Nest[(# + (#*5 - 1)/100) &, 1, n]//N

Even 1000 iterations work and need less than a second (on my computer).

Best Regards
Norbert Marxer
www.mec.li


Frank Hechtner wrote:
> hi,
>
> i?m in trouble with my Recurrence Equations:
>
> i?ve defined the following function
>
> anteil[0] = 1
> anteil[n_] := anteil[n - 1] + (anteil[n - 1]*5 - 1)/100
>
> i want mathematica to calculate the values for anteil[30] and so on.
>
> Unfortunately mathematica needs for this calculation over 2 hours (and
> is still running, athlon x2 4600, 2 gb ram).
>
> I don?t see where are the difficulties for mathematica...
> 
> Thanx for your help
> 
> frank


  • Prev by Date: Re: word problem
  • Next by Date: Re: position lists
  • Previous by thread: Re: calculate Recurrence Equations
  • Next by thread: Re: calculate Recurrence Equations