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:

Introduced in 2007
 (6.0)
 |
Updated in 2012
 (9.0)