Differences
Differences[list]
gives the successive differences of elements in list.
Differences[list,n]
gives the n differences of list.
Differences[list,n,s]
gives the differences of elements step s apart.
Differences[list,{n1,n2,…}]
gives the successive nk differences at level k in a nested list.
Details
- Differences[list] is equivalent to ListConvolve[{1,-1},list].
- If list has length l, Differences[list,n] has length l-n. »
- If list has length l, Differences[list,n,s] has length l-ns.
- Differences[m,{1,0}] or Differences[m,1] finds the successive differences of rows in a 2D array or matrix m. Differences[m,{0,1}] finds the differences of columns.
- Differences[list,{n1,n2}] is equivalent to Differences[Differences[list,n1],{0,n2}].
Examples
open allclose allScope (3)
Differences of rows, within each column:
Differences of columns, within each row:
Differences of a regularly sampled TimeSeries:
Applications (3)
Properties & Relations (4)
First differences are constant for a linear function:
Second differences are constant for a quadratic function:
Successive differences are progressively shorter:
FoldList acts as an inverse of Differences:
Possible Issues (1)
Differences of an irregularly sampled TimeSeries may differ from differences of the values:
Compare with Differences of the values:
Set TemporalRegularity to True and compute differences of the new time series:
Text
Wolfram Research (2007), Differences, Wolfram Language function, https://reference.wolfram.com/language/ref/Differences.html (updated 2012).
CMS
Wolfram Language. 2007. "Differences." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/Differences.html.
APA
Wolfram Language. (2007). Differences. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Differences.html