Re: nth differences
- To: mathgroup at smc.vnet.net
- Subject: [mg39860] Re: [mg39852] nth differences
- From: Ken Levasseur <klevasseur at mac.com>
- Date: Sun, 9 Mar 2003 05:26:46 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
These definitions generate the lists you want in "traditional form" for differences: Differences[input_] := Partition[input, 2, 1] /. {{a_, b_} -> b - a}; DifferencesTable[input_] := DT[FixedPointList[Differences, input, Length[input] - 1, SameTest -> (Length[Union[#2]] == 1 & )]] DT[e_] := TableForm[Transpose[ (MapThread[Prepend[#1, \[CapitalDelta]^StringJoin["(", ToString[#2 - 1], ")"]] & , {#1, Range[Length[#1]]}] & )[ (PadRight[#1, Length[e[[1]]], " "] & ) /@ e]]] Ken Levasseur Math. Sci. UMass Lowell > From: "Zachary Turner" <_NOzturnerSPAM_ at cyberonic.com> To: mathgroup at smc.vnet.net > Date: Sat, 8 Mar 2003 02:52:13 -0500 (EST) > To: mathgroup at smc.vnet.net > Subject: [mg39860] [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 > > >