MathGroup Archive 1998

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

Search the Archive

Re: iterative function query



Eric Walters wrote:
--------------------------
> Can someone explain the best way to code:
> 
> starting at x=1 and going to x=5;
> taxes[x_]:= 45 + 0.97(taxes[x+1])/; 
> 
> so that the following is generated:
> 
> 45 + 0.97(45+0.97(45+0.97(45+0.97(45))))
> 
> Thanks,
> 
> Eric Walters
> ewalters@bio.fsu.edu
Eric:

If you haven't assigned a value for taxes[k] where k >= 1 then  if 
taxes[x_]:= 45 + 0.97(taxes[x+1]), then taxes[1] will go into an
infinite forward recursion.  However, if you have a definite value of
taxes[5] (it appears to be 45 from your question) then

taxes[5]=45

will produce the desired value for taxes[1].

In your definition above you had 
	taxes[x_]:= 45 + 0.97(taxes[x+1])/; The "/;" at the end is a short form
for Condition and should have been followed by a condition.  If the
condition had been x<5  then this would be another way to avoid an
infinite recursion and if taxes[5] is undefined, the value of taxes[1]
would be 
	 45 + 0.97(45+0.97(45+0.97(45+0.97(taxes[5]))))

Ken Levasseur

P. S. If you or any of your students are interested in an on-line
3-credit university course in Mathematica that begins next week, visit
http://www.uml.edu/Dept/Math/m419.html



  • Prev by Date: Fuzzy Logic Pack
  • Next by Date: Re: Contour plot of irregularly spaced data
  • Prev by thread: iterative function query
  • Next by thread: Re: iterative function query