MathGroup Archive 2006

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

Search the Archive

Re: calculate Recurrence Equations


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


  • Prev by Date: RE: product formula in mathematica
  • Next by Date: Re: product formula in mathematica
  • Previous by thread: Re: calculate Recurrence Equations
  • Next by thread: Re: calculate Recurrence Equations