Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > List Manipulation > Math & Counting Operations on Lists >
Mathematica > Data Manipulation > Handling Arrays of Data > Math & Counting Operations on Lists >

Differences

Differences[list]
gives the successive differences of elements in list.
Differences[list, n]
gives the n^(th) differences of list.
Differences[list, {n1, n2, ...}]
gives the successive nk^(th) differences at level k in a nested list.
  • 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.
First differences:
Second differences:
Differences of rows, within each column:
Differences of columns, within each row:
Deduce the degree of a sequence by seeing when successive differences become constant:
Finite difference approximation to the Laplacian of a Gaussian:
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:
Successive differences mod 2 of a sequence based on the primes:
Pascal-triangle-like pattern:
New in 6
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team