Re: iterative function query
- To: mathgroup@smc.vnet.net
- Subject: [mg10620] Re: iterative function query
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Tue, 27 Jan 1998 03:09:48 -0500
- References: <6a1r14$q71@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))))
Eric:
Nest[(b +a(#))&,0, 5]
b + a (b + a (b + a (b + a b)))
%/.{a->.97, b->45}
211.899
or, in one line
Nest[(45 +.97(#))&,0, 5]
211.899
--
Allan Hayes
Training and Consulting
Leicester, UK
hay@haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642