MathGroup Archive 2005

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

Search the Archive

Re: "Alternating" function


Module[{i = 1},
  Nest[x + ((-1)^i++)*f[#] &, x + f[x], 4]
  ]

This does what you desire to do. Note the increment of i by one in
every Nest-iteration, and so an alternative sign before f. For a shift
in signs by one, change the starting value of i in Module by one.

Greetings from Slovenia,
Borut Levart


  • Prev by Date: Converting Strings to Ints.
  • Next by Date: Re: Convincing Mathematica that Sqrt[a+b]Sqrt[a-b]==Sqrt[a^2+b^2]
  • Previous by thread: Re: "Alternating" function
  • Next by thread: Re: "Alternating" function