       # 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 will go into an
infinite forward recursion.  However, if you have a definite value of
taxes (it appears to be 45 from your question) then

taxes=45

will produce the desired value for taxes.

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 is undefined, the value of taxes
would be
45 + 0.97(45+0.97(45+0.97(45+0.97(taxes))))

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