Re: nth differences
- To: mathgroup at smc.vnet.net
- Subject: [mg39877] Re: nth differences
- From: Daniel Reeves <dreeves at umich.edu>
- Date: Sun, 9 Mar 2003 05:30:22 -0500 (EST)
- Organization: University of Michigan Engineering
- References: <b4c9lo$nqg$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
difs[x_] := (#2-#1&) @@@ Partition[x, 2, 1]
For the nth differences, you can do
Nest[difs, x, n]
--- \/ FROM Zachary Turner AT 03.03.08 08:29 (Today) \/ ---
> Say I have a list of k integers and I want to produce a list containing the
> first differences? For example, given {1, 2, 5, 7, 8, 9} the first
> differences are {1, 3, 2, 1, 1}, and the second differences are {2, -1, -1,
> 0}, the third are {-3, 0, 1}, etc
--
Daniel Reeves -- http://ai.eecs.umich.edu/people/dreeves/
Mathematicians do it continuously and discretely.
-- bumper sticker by Robert L Dawes