Re: calculate Recurrence Equations
- To: mathgroup at smc.vnet.net
- Subject: [mg68759] Re: calculate Recurrence Equations
- From: albert <awnl at arcor.de>
- Date: Fri, 18 Aug 2006 03:12:03 -0400 (EDT)
- References: <ec1a1u$omo$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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 > perfect problem for a function that remembers values it has already calculated (see the mathematica book, section 2.5.9) Try the following: anteil[n_] := anteil[n] = anteil[n - 1] + (anteil[n - 1]*5-1)/100 if you need even more speed and an approximate result is o.k., the following might be even faster for large n, but could probably give you wrong results (it does not for n=10,20,30): anteil[n_] := anteil[n] = anteil[n - 1] + (anteil[n - 1]*5.-1.)/100. hth, albert