Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to know if it is possible to use NestList on a regular function of several arguments, such as:

fc[x_, y_] := {x + y, x - y};
res = NestList[ fc[x,y], {100, 75}, 50]

I just started learning Mathematica at my university, read about pure functions, but from the homework's text it doesn't look like I should use that. Roughly translated, it would be "Define a function of 2 arguments (...) and apply NestList on this function."

share|improve this question
I discussed a similar example here,may possibly be relevant as another illustration. – Leonid Shifrin Oct 1 '12 at 20:35
up vote 16 down vote accepted

One way to deal with "multiple inputs" to a function like NestList is to express the many inputs as a single vector. For example:

f[{x_, y_}] := {x + y, x - y};
NestList[f, {100, 75}, 5]

does what you are looking for

{{100, 75}, {175, 25}, {200, 150}, {350, 50}, {400, 300}, {700, 100}}
share|improve this answer
I didn't know I could specify arguments of the function in such manner. Neat. Thank you – Martin Melka Oct 1 '12 at 20:19

I suggest to look at this :

fc[x_, y_] := {x + y, x - y}
NestList[fc @@ # &, {100, 75}, 5]
{{100, 75}, {175, 25}, {200, 150}, {350, 50}, {400, 300}, {700, 100}}

First, after SetDelayed (:=) you don't have to use ;, look at CompoundExpression. Second, fc has to be applied (Apply) to the list of arguments.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.