Differences

Differences[list]

gives the successive differences of elements in list.

Differences[list,n]

gives the n^(th) differences of list.

Differences[list,n,s]

gives the differences of elements step s apart.

Differences[list,{n1,n2,}]

gives the successive nk^(th) differences at level k in a nested list.

Details

Examples

open allclose all

Basic Examples  (2)

First differences:

Second differences:

Scope  (3)

Differences of rows, within each column:

Differences of columns, within each row:

Differences of a regularly sampled TimeSeries:

Compare to differencing the values:

Applications  (3)

Deduce the degree of a sequence by seeing when successive differences become constant:

Finite difference approximation to the Laplacian of a Gaussian:

Prices of a stock at close:

Find the daily differences between stock values at close:

Find the proportion of days with increase in price at close:

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:

Now the value differences agree:

Neat Examples  (2)

Successive differences mod 2 of a sequence based on the primes:

Pattern resembling Pascal's triangle:

Wolfram Research (2007), Differences, Wolfram Language function, https://reference.wolfram.com/language/ref/Differences.html (updated 2012).

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_2024_differences, author="Wolfram Research", title="{Differences}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/Differences.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_differences, organization={Wolfram Research}, title={Differences}, year={2012}, url={https://reference.wolfram.com/language/ref/Differences.html}, note=[Accessed: 22-December-2024 ]}