NestList
- To: mathgroup at smc.vnet.net
- Subject: [mg61391] NestList
- From: "Dr A.H. Harker" <a.harker at ucl.ac.uk>
- Date: Tue, 18 Oct 2005 02:44:32 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Dear All,
I suspect I have missed something, but what I would really like is
a function similar to NestList, but where I can specify a function f that
takes more than one argument. Then, if at any step of the new function the
list of previous results is ll, whereas NestList will append to ll
f[ll[[-1]]], the new function would return f[ll[[-1]],ll[[-2]]...].
Of course I can do this with the existing NestList, but as far as I can
see only by defining my f to work with a list {last,lastbutone,...}, in
which case I end up storing a lot of duplicate information in the
accumulated list.
The particular application I have in mind is a simple finite difference
solution of the wave equation, where I might want to use NestList rather
than Nest so that I can animate the results. If the simulation involves two
spatial dimensions, storing duplicate copies of the information is a
significant problem. In fact in my application it's better to collect the
animation frames at rather lower frequency than they are calculated, to get
a reasonable compromise between accuracy and visual impact, so I tend not to
use NestList, but might this extension be useful in other areas. Or have I
just missed a clever trick?
Tony Harker
Department of Physics and Astronomy
University College London
Gower Street
LONDON
WC1E 6BT
(44)(0)207 679 3404
a.harker at ucl.ac.uk