Derivative

Syntax: vout = DERIV(x,y)

The DERIV function evaluates the first derivatives of the vector y, the dependent variable, with respect to the vector x, the independent variable, at the x locations. The vector x must be strictly monotonically increasing. The result of this function is a vector with the same length as the vectors x and y. Currently, the derivatives are calculated using interpolating cubic splines, but more algorithms, such as Lagrange interpolating polynomials, will be added in the future.

Interpolating splines

This integration method utilizes an interpolating spline under tension. The spline tension used is the current value of TENSION, which may be changed with the SET TENSION command. The nature of the interpolating curve varies continuously from pure cubic splines, for TENSION = 0, to a piecewise linear curve, that is, points joined by straight line segments, for large TENSION.

Example

The following code produces the picture below (except for the text which was added interactively).

 clear
 defaults
 !
 pi=acos(-1)
 generate x 0,,2*pi 100
 y = cos(x)^3+sin(x)^3
 graph x y
 !
 set linecolor red
 graph/overlay x deriv(x,y)
 set linecolor black
 replot