- See Also
-
Related Guides
- Math & Counting Operations on Lists
- Discrete & Integer Data
- Time Series Processes
- List Manipulation
- Data Transforms and Smoothing
- Arithmetic Functions
- GPU Computing
- Discrete Calculus
- Time Series Processing
- Numerical Data
- Applying Functions to Lists
- Event Series Processing
- GPU Computing with NVIDIA
- Signal Processing
- Signal Visualization & Analysis
-
- See Also
-
Related Guides
- Math & Counting Operations on Lists
- Discrete & Integer Data
- Time Series Processes
- List Manipulation
- Data Transforms and Smoothing
- Arithmetic Functions
- GPU Computing
- Discrete Calculus
- Time Series Processing
- Numerical Data
- Applying Functions to Lists
- Event Series Processing
- GPU Computing with NVIDIA
- Signal Processing
- Signal Visualization & Analysis
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.
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, or 0 if n>l. »
- If list has length l, Differences[list,n,s] has length Ramp[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 all close allBasic Examples (2)
Scope (4)
Differences[{a, b, c, d, e, f}]The same thing, more verbosely:
Differences[{a, b, c, d, e, f}, 1]Compute differences between elements two positions apart:
Differences[{a, b, c, d, e, f}, 1, 2]Compute differences between elements three positions apart:
Differences[{a, b, c, d, e, f}, 1, 3]Differences of rows, within each column:
Differences[(| | | |
| :-- | :-- | :-- |
| a11 | a12 | a13 |
| a21 | a22 | a23 |
| a31 | a32 | a33 |)]//MatrixFormDifferences[(| | | |
| :-- | :-- | :-- |
| a11 | a12 | a13 |
| a21 | a22 | a23 |
| a31 | a32 | a33 |), {1, 0}]//MatrixFormDifferences of columns, within each row:
Differences[(| | | |
| :-- | :-- | :-- |
| a11 | a12 | a13 |
| a21 | a22 | a23 |
| a31 | a32 | a33 |), {0, 1}]//MatrixFormDifferences of a regularly sampled TimeSeries:
v = {1, 3, 9, 3, 2};
ts = TimeSeries[v, Automatic]ts["Path"]diff = Differences[ts]diff["Path"]Compare to differencing the values:
Differences[v] == diff["Values"]Applications (3)
Deduce the degree of a sequence by seeing when successive differences become constant:
Table[n ^ 5 + 2n - 1, {n, 8}]FixedPointList[Differences, %]Finite difference approximation to the Laplacian of a Gaussian:
t = Table[Exp[-x ^ 2 - y ^ 2], {x, -2, 2, 0.1}, {y, -2, 2, 0.1}];ListDensityPlot[Drop[Differences[t, {0, 2}], 2, 0] + Drop[Differences[t, {2, 0}], 0, 2], PlotRange -> All, DataRange -> {{-2, 2}, {-2, 2}}]ts = TimeSeries@FinancialData["SBUX", "Close", {2013, 1, 1}]DateListPlot[ts]Find the daily differences between stock values at close:
diff = Differences[ts]DateListPlot[diff]Find the proportion of days with increase in price at close:
res = Tally[Sign[diff]["Values"]]Select[res, First[#] == 1&][[1, 2]] / ts["PathLength"]//NProperties & Relations (6)
First differences are constant for a linear function:
Table[3i + 6, {i, 10}]Differences[%]Second differences are constant for a quadratic function:
Table[3i ^ 2 + 6, {i, 10}]Differences[%]Differences[%]Successive differences are progressively shorter:
Column[Table[Differences[Range[10], n], {n, 10}]]If list has length l, Differences[list,n,s] has length Ramp[l-ns]:
Table[Length[Differences[Range[10], n, 2]] == Ramp[10 - 2n], {n, 5}]Table[Length[Differences[Range[10], n, 3]] == Ramp[10 - 3n], {n, 5}]Differences[list] is equivalent to Rest[list]-Most[list]:
list = {a, b, c, d, e};
Differences[list] === Rest[list] - Most[list]It is also equivalent to ListConvolve[{1,-1},list]:
Differences[list] == ListConvolve[{1, -1}, list]FoldList acts as an inverse of Differences:
Differences[{a, b, c, d, e}]FoldList[Plus, a, %]Possible Issues (1)
Differences of an irregularly sampled TimeSeries may differ from differences of the values:
v = {1, 3, 9, 3, 2};
t = {0, .3, .4, 1.3, 1.5};
ts = TimeSeries[v, {t}]RegularlySampledQ[ts]diff = Differences[ts]diff["Path"]Compare with Differences of the values:
Differences[v] == diff["Values"]Set TemporalRegularity to True and compute differences of the new time series:
ts1 = TimeSeries[ts, TemporalRegularity -> True];diff1 = Differences[ts1];Now the value differences agree:
diff1["Values"] == Differences[v]Neat Examples (2)
See Also
Subtract Accumulate Ratios ListConvolve FoldList DifferenceDelta RecurrenceTable EstimatedBackground BlockMap
Function Repository: DifferencesBy LogDifferences ArithmeticProgression
Related Guides
-
▪
- Math & Counting Operations on Lists ▪
- Discrete & Integer Data ▪
- Time Series Processes ▪
- List Manipulation ▪
- Data Transforms and Smoothing ▪
- Arithmetic Functions ▪
- GPU Computing ▪
- Discrete Calculus ▪
- Time Series Processing ▪
- Numerical Data ▪
- Applying Functions to Lists ▪
- Event Series Processing ▪
- GPU Computing with NVIDIA ▪
- Signal Processing ▪
- Signal Visualization & Analysis
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
BibTeX
@misc{reference.wolfram_2026_differences, author="Wolfram Research", title="{Differences}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/Differences.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_differences, organization={Wolfram Research}, title={Differences}, year={2012}, url={https://reference.wolfram.com/language/ref/Differences.html}, note=[Accessed: 12-June-2026]}