Re: calculate Recurrence Equations
- To: mathgroup at smc.vnet.net
- Subject: [mg68747] Re: [mg68713] calculate Recurrence Equations
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 18 Aug 2006 03:11:47 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
Add memory to the definition
Clear[anteil1];
anteil1[0]=1;
anteil1[n_Integer?Positive]:=
anteil1[n]=
anteil1[n-1]+(anteil1[n-1]*5-1)/100;
anteil1[n_Integer?Negative]:=
anteil1[n]=(1/105)*(100*anteil1[n+1]+1);
anteil1[30]//Timing//N
{0.002837 Second,3.65755}
Clear[anteil2];
anteil2[n_]=anteil2[n]/.RSolve[{
anteil2[n]==anteil2[n-1]+(anteil2[n-1]*5-1)/100,
anteil2[0]==1},anteil2[n],n][[1]]
(1/5)*(1 + 4^(1 - n)*(21/5)^n)
anteil2[30]//Timing//N
{0.000229 Second,3.65755}
Plot[anteil2[n],{n,-10,10},
PlotStyle->Blue,ImageSize\[Rule]432,
Epilog->{Red, AbsolutePointSize[4],
Point/@Table[{n,anteil1[n]},{n,-10,20}]}];
Bob Hanlon
---- Frank Hechtner <frank.hechtner at rub.de> 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
>