diff_test


diff_test, an Octave code which calls diff(), which computes differences in a vector of data, which can be scaled to estimate derivatives of equally spaced data.

The diff() function is built in. If y is a vector of n data values, then diff(y) is the vector of n-1 differences of consecutive pairs of data. If the y values were computed at evenly spaced x values, then each entry of diff(y)/h is an approximation to the derivative of y(x) at the midpoint of the corresponding pair of consecutive x values.

Again, if equal spacing is used in x, diff(y,1)/h, diff(y,2)/h^2, and diff(y,3)/h^3 are vectors of length n-1, n-2, and n-3 that approximate first, second and third derivatives of y(x).

Licensing:

The computer code and data files described and made available on this web page are distributed under the MIT license

Languages:

diff_test is available in a MATLAB version and an Octave version.

Related Data and Programs:

diff_center, an Octave code which interactively uses centered differences to estimate the derivative of a function f(x), using a stepsize h.

diff_forward, an Octave code which interactively uses forward differences to estimate the derivative of a function f(x), using a stepsize h.

diff2_center, an Octave code which interactively uses centered differences to estimate the second derivative of a function f(x), using a stepsize h.

Source Code:


Last revised on 02 July 2023.