MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: RE: nth differences

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39887] Re: [mg39862] RE: [mg39852] nth differences
  • From: Dr Bob <drbob at bigfoot.com>
  • Date: Sun, 9 Mar 2003 18:39:27 -0500 (EST)
  • References: <200303091027.FAA07451@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

Try this:

differences[a_List] := NestList[
   Subtract @@@ Partition[#, 2, 1] &,
   -a,
   Length@a - 1]
s = {1, 2, 5, 7, 8, 9};
differences@s // TableForm

Bobby

On Sun, 9 Mar 2003 05:27:13 -0500 (EST), Harvey P. Dale <hpd1 at nyu.edu> 
wrote:

>
> Zachary:
> 	After entering the list of k integers, evaluate the following:
> 				#[[2]]-#[[1]]&/@Partition[%,2,1]
> Then you can evaluate exactly the same expression again, and again,
> until the nth difference is a single number.  The easiest way to do that
> is to type <ctrl>+L, which automatically inserts, for evaluation, the
> prior input.
> 	Hope that helps.
> 	Best,
> 	Harvey
>
> -----Original Message-----
> From: Zachary Turner [mailto:_NOzturnerSPAM_ at cyberonic.com]
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
> Subject: [mg39887] [mg39862] [mg39852] nth differences
>
> 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
>
>
>
>



-- 
majort at cox-internet.com
Bobby R. Treat



  • Prev by Date: Re: your reply in comp.soft-sys-math.mathematica
  • Next by Date: Re: presentation layout
  • Previous by thread: RE: nth differences
  • Next by thread: RE: nth differences