Message Boards Message Boards

1
|
4793 Views
|
7 Replies
|
10 Total Likes
View groups...
Share
Share this post:

Reason for difference between Nest and NestList

Posted 4 years ago

Hi!

Is there a reason that Nest[] applies a function n times but NestList[] applies a function 0 to n times?

Thank you!

POSTED BY: Timo Kuchheuser
7 Replies

Look at it: NestList gives a list of the intermediate results, which may be useful for a bunch of reasons.

Nest[f, x, 3]
NestList[f, x, 3]
POSTED BY: Hans Dolhaine
Posted 4 years ago

Great thinking Ahmed. That does make sense to me.

POSTED BY: Mike Besso

Hi Timo In my personal opinion, I think in Nest the user is only interested in the final answer and whether the step zero is included or not won't make a difference in the final result. However, in NestList, the user is interested to see all the steps of the operation so Wolfram staff thought that it would be useful to also include step zero in the list. Hope this makes sense to you.

POSTED BY: Ahmed Elbanna
Posted 4 years ago

Timo:

That is a great question. But how is the implementation different? It seems to me they just described the function differently in the documentation.

But, I am still very new to all of this. I would really like to understand as well.

THANK YOU for the great question.

POSTED BY: Mike Besso
Posted 4 years ago

Timo:

From what I can tell, the documentation is perhaps a bit misleading one compared side by side.

Next[f, x, 0]

returns

x

While

Next[f, x, 1]

returns

f[x]

So, I think Nest supports n = 0 and works as expected.

I hope that helps.

Have a great and safe rest of your weekend.

POSTED BY: Mike Besso

Hey Mike,

thank you for your answer! I think i phrased my question wrong.

I was asking about the rational behind the decision to implement the parameter to both functions in different ways?!

All the best, Timo

POSTED BY: Timo Kuchheuser

I was asking about the rational behind the decision to implement the parameter to both functions in different ways?!

There is no difference.

Can you show an example that demonstrates a difference?

POSTED BY: Szabolcs Horvát
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract