Re: calculate Recurrence Equations
- To: mathgroup at smc.vnet.net
- Subject: [mg68781] Re: calculate Recurrence Equations
- From: "Norbert Marxer" <marxer at mec.li>
- Date: Fri, 18 Aug 2006 03:12:38 -0400 (EDT)
- References: <ec1a1u$omo$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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