Re: calculate Recurrence Equations
- To: mathgroup at smc.vnet.net
- Subject: [mg68768] Re: calculate Recurrence Equations
- From: "Stratocaster" <stotz1 at verizon.net>
- Date: Fri, 18 Aug 2006 03:12:14 -0400 (EDT)
- References: <ec1a1u$omo$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Frank Hechtner" <frank.hechtner at rub.de> wrote in message news:ec1a1u$omo$1 at smc.vnet.net... > 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... Short answer: Redefine the function as follows. (notice the extra = ???) anteil[0] = 1 anteil[n_] := anteil [n] = anteil[n - 1] + (anteil[n - 1]*5 - 1)/100 Longer Answer: They way you've inputed it, Mathematica needs to recalculate a[0 through n], every time it increments "n". Adding the extra syntax; a[n_]:=a[n]= "the function" forces Mathematica to commit all calculations to the cache, so as not to re-evaluate what has already been evaluated. This will significantly decrease processing time.