MathGroup Archive 2006

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

Search the Archive

Re: calculate Recurrence Equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68791] Re: [mg68713] calculate Recurrence Equations
  • From: gardyloo <gardyloo at mail.wsu.edu>
  • Date: Fri, 18 Aug 2006 03:12:50 -0400 (EDT)
  • References: <200608170818.EAA24918@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The timing for that function fits very nicely to
    time[n]=10^(-5)*2^n
with the prefactor of 10^-5 specific to my machine and the time in
seconds. On my computer, at least, I'd estimate that anteil[30] would
take almost exactly 3 hours.

   I had to look up how to define the functions so that Mathematica
remembers the values of the functions as previously-calculated
(otherwise it has to recalculate the things all over again each time it
hits one). It takes only one little addition to your definition. Try this:

anteil[0] = 1
anteil[n_] := anteil[n] = anteil[n - 1] + (anteil[n - 1]*5 - 1)/100


    Now the thing should be virtually instantaneous (you could also
define things to use numeric values rather than exact calculations by
defining anteil[0] to be 1.0 or whatever, but I don't think it'll buy
you much performance unless you're going up to n much larger than 30).

         Hope that helps! It helped me, by the way, by forcing me to
look up how to define these things, which I'll need to do very shortly.

                 C.O.


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
>
>
>   

-- 
==========================================================
Curtis Osterhoudt          
gardyloo at mail.remove_this.wsu.and_this.edu
PGP Key ID: 0x088E6D7A
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
==========================================================


  • Prev by Date: Re: word problem
  • Next by Date: Re: word problem
  • Previous by thread: Re: calculate Recurrence Equations
  • Next by thread: Re: calculate Recurrence Equations