Skip to content

Linear.Function.computeLinearPolyCoefficients

Christian d'Heureuse edited this page Sep 25, 2026 · 1 revision

commons-math-interpolation / Linear / computeLinearPolyCoefficients

Function: computeLinearPolyCoefficients()

function computeLinearPolyCoefficients(xVals, yVals): Float64Array<ArrayBufferLike>[];

Defined in: Linear.ts:54

Computes the polynomial coefficients for the linear interpolation of a dataset.

Parameters

xVals

ArrayLike<number>

The arguments of the interpolation points, in strictly increasing order. The values must be finite.

yVals

ArrayLike<number>

The values of the interpolation points.

Returns

Float64Array<ArrayBufferLike>[]

The polynomial coefficients of the xVals.length - 1 segments. Element i contains the coefficients of the segment from xVals[i] to xVals[i + 1], in ascending order ([yVals[i], slope]) and relative to xVals[i]. A zero slope is trimmed, so a segment may contain only one coefficient. The result can be evaluated with evaluatePolySegment.

Throws

Error If xVals and yVals have different lengths, if there are fewer than 2 points, or if xVals contains non-finite values or is not strictly increasing.

Clone this wiki locally