cmlabs.interpolate.gaussbd
- cmlabs.interpolate.gaussbd(xvals, x, yvals=None, coef=None, m=None)[source]
Gauss’s backward interpolation formula.
\[\begin{split}\begin{aligned} P_n(x_m + th) &= \nabla^0 f(x_m) + \\ &+ \frac{t}{1!} \nabla^1 f(x_m) + \\ &+ \frac{t(t+1)}{2!} \nabla^2 f(x_{m+1}) + \\ &+ \frac{(t-1)t(t+1)}{3!} \nabla^3 f(x_{m+1}) + \\ &+ \frac{(t-1)t(t+1)(t+2)}{4!} \nabla^4 f(x_{m+2}) + \\ &+ \frac{(t-2)(t-1)t(t+1)(t+2)}{5!} \nabla^5 f(x_{m+2}) + \\ &+ \frac{(t-2)(t-1)t(t+1)(t+2)(t+3)}{6!} \nabla^6 f(x_{m+3}) + \ldots \end{aligned}\end{split}\]where \(x_m\) is the midpoint of the data point (\(m = n // 2 + n % 2\)) and \(t = \frac{x-x_m}{h}\).
- Parameters:
xvals (array_like, 1-D) – The sorted x-coordinates of the data points.
x (float) – The x-coordinate at which to evaluate the polynomial.
yvals (array_like, 1-D, optional, default: None) – The y-coordinates of the data points, i.e., \(f(x)\).
coef (array_like, 2-D, optional, default: None) – The backward differences table. If not provided, the function will compute the finite differences table using the finite_differences(yvals) function.
m (int, optional, default: None) – The index of the midpoint of the data points.
- Returns:
res – The value of the polynomial at \(x\).
- Return type:
float
See also
Notes
Gauss’s backward interpolation formula is best applicable for determining the values near the middle of the table.
\[x = x_m + t h, \quad -\frac{1}{2} < t < 0\]Examples
>>> import numpy as np >>> from cmlabs.interpolate import gaussbd >>> xvals = np.array([0, 1, 2, 3]) >>> yvals = np.array([1, 3, 2, 5]) >>> x = np.float32(0.75) >>> gaussbd(xvals, x, yvals=yvals) >>> 3.0546875