Compute a Chebyshev polynomial approximation of function f on [a, b] using n terms. Samples f at Chebyshev nodes and computes coefficients via the discrete cosine transform. Evaluates using Clenshaw\
Syntax
chebyshevApprox(f | a | b
Type Signatures
function, number, number, number
Parameters
Name
Type
Description
f
Function
Function to approximate
a
number
Left endpoint of interval
b
number
Right endpoint of interval
n
number
Number of Chebyshev terms (degree = n-1)
Returns
Object — Object with `coefficients` array and `evaluate(x)` method
Compute the condition number of a matrix. p=2 (default) uses the ratio of largest to smallest singular value; p=1 and p=Infinity use the respective matrix norms.
Compute a natural cubic spline through a set of data points. Returns an object with an evaluate(t) method for smooth interpolation. Natural boundary conditions: second derivative is zero at both endpoints.
Syntax
cspline(x | y)
Type Signatures
Array, Array
Parameters
Name
Type
Description
x
Array
Array of x-coordinates (strictly increasing)
y
Array
Array of y-coordinates (same length as x)
Returns
Object — Object with `evaluate(t)` method and `coefficients` array
Fit an exponential model y = a * exp(b * x) to data using linear regression on log-transformed data. All y values must be strictly positive. Returns an object with a, b, and predict(x).
Syntax
expfit(x | y)
Type Signatures
Array, Array
Parameters
Name
Type
Description
x
Array
Array of x-coordinates
y
Array
Array of y-coordinates (all must be > 0)
Returns
Object — Object with `a`, `b`, and `predict(x)` method
Find the global minimum of a function using the differential evolution algorithm, a population-based stochastic method that does not require derivatives. bounds is an array of [lo, hi] pairs for each dimension. Returns an object with x, fval, and iterations.
Syntax
globalMinimize(f | bounds) | globalMinimize(f
Type Signatures
function, Array, function, Array, Object
Parameters
Name
Type
Description
f
Function
Objective function taking an array of numbers, returning a number
Interpolate scattered data at query points using the specified method. Methods: "nearest" (nearest-neighbor), "linear" (inverse distance weighting, IDW), "natural" (IDW with squared distances). Works in any dimension. Returns an array of interpolated values at each query point.
Compute the numerical Hessian matrix of a scalar function at a given point using second-order central differences. H[i][j] = (f(x+h*e_i+h*e_j) - f(x+h*e_i-h*e_j) - f(x-h*e_i+h*e_j) + f(x-h*e_i-h*e_j)) / (4*h^2).
Solve a nonlinear least squares problem using the Gauss-Newton method with backtracking line search and Levenberg-Marquardt regularization. Minimizes the sum of squared residuals returned by f(params, data). Returns an object with x, resnorm, iterations, and converged.
Compute locally weighted scatterplot smoothing (LOESS/LOWESS). For each point x_i, fits a weighted linear regression using neighboring data points with a tricube weight function. The span parameter controls what fraction of the data is used for each local fit.
Syntax
loess(x | y) | loess(x
Type Signatures
Array, Array, Array, Array, number
Parameters
Name
Type
Description
x
Array
Array of x-coordinates (must be sorted ascending)
y
Array
Array of y-coordinates (same length as x)
span
number
Fraction of data to use per local fit (default: 0.75)
Fit a logarithmic model y = a + b * ln(x) to data using linear regression with the substitution u = ln(x). All x values must be strictly positive. Returns an object with a, b, and predict(x).
Syntax
logfit(x | y)
Type Signatures
Array, Array
Parameters
Name
Type
Description
x
Array
Array of x-coordinates (all must be > 0)
y
Array
Array of y-coordinates
Returns
Object — Object with `a`, `b`, and `predict(x)` method
Find a local maximum of a function by negating it and applying the Nelder-Mead simplex minimization. Works for any dimension without requiring derivatives. Returns an object with x, fval, iterations, and converged.
Syntax
maximize(f | x0) | maximize(f
Type Signatures
function, Array, function, Array, Object
Parameters
Name
Type
Description
f
Function
Objective function taking an array of numbers, returning a number
x0
Array
Initial guess (array of numbers)
options
Object
Options: tol (1e-8), maxIter (1000)
Returns
Object — Result with properties: x (array), fval (number), iterations (number), converged (boolean)
Find a local minimum of a function using the Nelder-Mead simplex method. Works for any dimension without requiring derivatives. Returns an object with x, fval, iterations, and converged.
Syntax
minimize(f | x0) | minimize(f
Type Signatures
function, Array, function, Array, Object
Parameters
Name
Type
Description
f
Function
Objective function taking an array of numbers, returning a number
x0
Array
Initial guess (array of numbers)
options
Object
Options: tol (1e-8), maxIter (1000)
Returns
Object — Result with properties: x (array), fval (number), iterations (number), converged (boolean)
Compute the [m/n] Pade approximant from Taylor series coefficients. Given coefficients c[0], c[1], ... of a Taylor series, returns the rational function P(x)/Q(x) where P has degree m and Q has degree n. Often converges faster than Taylor series, especially near poles. Returns an object with numerat
Syntax
padeApproximant(coeffs | m | n)
Type Signatures
Array, number, number
Parameters
Name
Type
Description
coeffs
Array
Taylor series coefficients [c0, c1, c2, ...]
m
number
Degree of numerator polynomial
n
number
Degree of denominator polynomial
Returns
Object — Object with `numerator`, `denominator`, and `evaluate(x)` fields
Compute a Piecewise Cubic Hermite Interpolating Polynomial (PCHIP). Unlike cubic splines, PCHIP preserves monotonicity: the interpolant will not oscillate between data points. Uses the Fritsch-Carlson method to compute shape-preserving slopes. Returns an object with an evaluate(t) method.
Fit a polynomial of given degree to data points using least-squares regression. Returns coefficients [c0, c1, ...] where p(x) = c0 + c1*x + c2*x^2 + ...
Fit a power-law model y = a * x^b to data using linear regression on doubly log-transformed data: ln(y) = ln(a) + b*ln(x). All x and y values must be strictly positive. Returns an object with a, b, and predict(x).
Syntax
powerfit(x | y)
Type Signatures
Array, Array
Parameters
Name
Type
Description
x
Array
Array of x-coordinates (all must be > 0)
y
Array
Array of y-coordinates (all must be > 0)
Returns
Object — Object with `a`, `b`, and `predict(x)` method
Radial Basis Function (RBF) interpolation for scattered data in any dimension. Fits weights by solving a linear system, then evaluates f(x) = sum_i w_i * phi(||x - x_i||). Available kernels: "gaussian", "multiquadric", "inverseMultiquadric", "thinPlateSpline". Returns an object with an evaluate(poin
Syntax
rbfInterpolate(points | values | kernel)
Type Signatures
Array, Array, string
Parameters
Name
Type
Description
points
Array
Array of N coordinate arrays (each has same dimension d)
values
Array
Array of N function values at the corresponding points
Compute the residues and poles of a rational function P(s)/Q(s) given polynomial coefficient arrays (highest power first). For each simple pole p_i: residue = P(p_i) / Q\
Syntax
residue(num | den)
Type Signatures
Array, Array
Parameters
Name
Type
Description
num
Array
Numerator polynomial coefficients [highest power first]
den
Array
Denominator polynomial coefficients [highest power first]