Re: Slow iteration in a functional program
- To: mathgroup at smc.vnet.net
- Subject: [mg35686] Re: Slow iteration in a functional program
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 26 Jul 2002 04:16:26 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <ahoeqo$bue$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
DrBob wrote:
>
> Jens' solution will run into problems with $IterationLimit, unless the
> user also calculates values "bottom-up" before asking for values like
> Phi[1000]:
>
> Phi/@Range[1000];Phi[1000]
>
> Where Jens said: "will save the function values for P[n]" he meant G[n]
> and Phi[n], not P[n], since he didn't include a modification of the
> definition for P[n].
No, I mean both ! because
>
> Phi[1] = Flux;
> Phi[n_] :=Phi[n]= Phi[n-1] Exp[-(1-P[n-1])*xsec
^^^^^^^^
> G[n_] := G[n]=ListIntegrate[xsec Phi[n]]
>
> Phi is the only function that needs this treatment, actually; G and P
> are not recursive, so saving their values will be a waste of space
> (contrary to the solution I sent earlier). That determination isn't
> entirely trivial, so be careful in general.
Since I don't kow the full program, I assume that the computational
intesive function is G[]
Regards
Jens