Hi!
Is there a reason that Nest[] applies a function n times but NestList[] applies a function 0 to n times?
Nest[]
NestList[]
Thank you!
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]
Great thinking Ahmed. That does make sense to me.
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.
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.
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]
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.
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
There is no difference.
Can you show an example that demonstrates a difference?