Re: "Alternating" function

*To*: mathgroup at smc.vnet.net*Subject*: [mg63274] Re: [mg63260] "Alternating" function*From*: Sseziwa Mukasa <mukasa at jeol.com>*Date*: Thu, 22 Dec 2005 00:04:35 -0500 (EST)*References*: <200512210435.XAA14743@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

On Dec 20, 2005, at 11:35 PM, Renan wrote: > Hello, > > I want to make a "nested function" like: x + f[x - f[x + f[x - f[x > + f[x]]]]]. > > I've tried using Nest but I don't find how to keep switching between > Plus and Minus: I would need something that would return an "index" so > I could keep track of when I need to "switch" the operation. (e.g. if > the "index" is odd, the operation is "Plus", otherwise is "Minus") > > How can I make this? I looked in the help but didn't find any > informations. > > Thanks. One way is to use Fold instead of Nest Fold[x+#2 f[#1]&,x,Table[(-1)^i,{i,0,n-1}] where n in is the desired level of nesting. Regards, Ssezi

**References**:**"Alternating" function***From:*Renan <renan.birck@gmail.com>