spline man page

spline — interpolate datasets using splines under tension


spline [ options ] [ files ]


spline reads datasets from standard input or from one or more files, and fits a smooth curve (a "spline") through each dataset. An interpolated version of each dataset, consisting of points from the smooth curve, is written to standard output.

Unless the -a or -A options are used (see below), each dataset should be a sequence of values for a vector-valued function of a single scalar variable. That is, each dataset should be a sequence of data points,  given as alternating t and y values. t is a scalar independent variable, and y is a vector-valued dependent variable. The dimensionality of y is specified with the -d option (the default dimensionality is 1). Between each data point and the next, t should increase.

An input file may contain more than a single dataset. If an input file is in ASCII format (the default), its datasets should be separated by blank lines. The t and y values of the data points in each dataset may be arranged arbitrarily, so long as they are separated by white space. Besides datasets, an input file may contain any number of comment lines, which should begin with the comment character `#'. Comment lines are ignored. They are not treated as blank, i.e., they do not interrupt a dataset in progress.

Options and file names may be interspersed on the command line, but the options are processed before the file names are read. If -- is seen, it is interpreted as the end of the options. If no file names are specified, or the file name - is encountered, the standard input is read.

The type of interpolation, and the format of the input and output files, may be selected by command-line options.


Informational Options


Print a list of command-line options, and exit.


Print the version number of spline and the plotting utilities package, and exit.



echo 0 0 1 1 2 0 | spline

will produce on standard output an interpolated dataset consisting of  101 data points. If graphed, this interpolated dataset will yield a parabola.

It is sometimes useful to interpolate between a sequence of arbitrarily placed points in d-dimensional space, i.e., to "spline a curve" rather than a function. The -a and -s options are used for this. For example,

echo 0 0 1 0 1 1 0 1 | spline -d 2 -a -s

will produce on standard output a 101-point dataset that interpolates between the four points (0,0), (1,0), (1,1), and (0,1). The -d 2 option specifies that the dependent variable y is two-dimensional. The -a option specifies that the t values are missing from the input and should be automatically generated. The -s option specifies that the t values should be stripped from the output.


spline was written by Robert S. Maier (rsm@math.arizona.edu), starting with an earlier version by Rich Murphey (rich@freebsd.org). The algorithms for constructing splines under tension are similar to those used in the FITPACK subroutine library, and are ultimately due to  Alan K. Cline (cline@cs.utexas.edu).

See Also

"The GNU Plotting Utilities Manual".


Email bug reports to bug-gnu-utils@gnu.org.


Dec 1998 FSF GNU Plotting Utilities