Re: iterative function query
- To: mathgroup@smc.vnet.net
- Subject: [mg10617] Re: [mg10579] iterative function query
- From: Levasseur <levasseu@bit-net.com>
- Date: Mon, 26 Jan 1998 04:42:48 -0500
- References: <199801202154.QAA00644@smc.vnet.net.>
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
- References:
- iterative function query
- From: Eric Walters <ewalters@bio.fsu.edu>
- iterative function query