Spline Interpolant (G Dataflow)

Version:

Returns an array of length n, which contains the second derivatives of the spline interpolating function g(x) at the tabulated points xi, where i = 0, 1, ..., n - 1.

Programming Patterns

You can use interpolant as an input to the Spline Interpolation node to interpolate y at any value of ${x}_{0}\le x\le {x}_{n-1}$.

Y

Dependent values.

If the number of elements in X is different from the number of elements in Y, this node sets the output interpolant to an empty array and an error.

X

Independent values.

If the number of elements in X is different from the number of elements in Y, this node sets the output interpolant to an empty array and an error.

initial boundary

The first derivative of interpolating function g(x) at x0, g'(x0).

Default: 1E+30, which causes this node to set the initial boundary condition for a natural spline.

final boundary

The first derivative of interpolating function g(x) at xn - 1, g'(xn - 1).

Default: 1E+30, which causes this node to set the final boundary condition for a natural spline.

error in

Error conditions that occur before this node runs. The node responds to this input according to standard error behavior.

Default: No error

interpolant

The second derivative of interpolating function g(x) at points xi, i = 0, 1, ..., n - 1.

error out

Error information. The node produces this output according to standard error behavior.

Algorithm for Calculating the Interpolant

Input arrays X and Y are of length n and contain a tabulated function where x0 < x1 < ... < xn-1, as shown in the following equation:

$f\left({x}_{i}\right)={y}_{i}$

The interpolating function g(x) is a piecewise function in the following equation:

$g\left(x\right)=\left\{\begin{array}{c}{p}_{0}\left(x\right)\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}{x}_{0}\le x\le {x}_{1}\\ ⋮\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}⋮\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\\ {p}_{n-2}\left(x\right)\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}{x}_{n-2}\le x\le {x}_{n-1}\end{array}$

The function pi(x) is a third-order polynomial that must satisfy the following conditions:

1. $g\left({x}_{i}\right)={y}_{i}={p}_{i}\left({x}_{i}\right)$
2. $g\left({x}_{i}\right)={y}_{i}={p}_{i-1}\left({x}_{i}\right)$
3. The first and second derivatives, where i = 1, …, n - 2, at each interior xi is continuous:
1. $g\prime \left({x}_{i}\right)={p\prime }_{i}\left({x}_{i}\right)={p\prime }_{i-1}\left({x}_{i}\right)$
2. $g\prime \prime \left({x}_{i}\right)={p\prime \prime }_{i}\left({x}_{i}\right)={p\prime \prime }_{i-1}\left({x}_{i}\right)$

With the third condition, you can derive the following equation:

$\frac{{x}_{i}-{x}_{i-1}}{6}g\prime \prime \left({x}_{i-1}\right)+\frac{{x}_{i+1}-{x}_{i-1}}{3}{g}^{.}\left({x}_{i}\right)+\frac{{x}_{i+1}-{x}_{i}}{6}g\prime \prime \left({x}_{i+1}\right)=\frac{{y}_{i+1}-{y}_{i}}{{x}_{i+1}-{x}_{i}}-\frac{{y}_{i}-{y}_{i-1}}{{x}_{i}-{x}_{i-1}}$

where i = 1, ..., n - 2. According to this equation, n - 2 linear equations exist for n unknown g"(xi).

This node computes two equations for the derivatives at xo and xn-1 in the following equation:

$g\prime \left(x\right)=\frac{{y}_{k+1}-{y}_{k}}{{x}_{k+1}-{x}_{k}}-\frac{3{A}^{2}-1}{6}\left({x}_{k+1}-{x}_{k}\right)g\prime \prime \left({x}_{k}\right)+\frac{3{B}^{2}-1}{6}\left({x}_{k+1}-{x}_{k}\right)g\prime \prime \left({x}_{k+1}\right)$

Consider the following equations:

$A=\frac{{x}_{k+1}-x}{{x}_{k+1}-{x}_{k}}$
$B=1-A=\frac{x-{x}_{k}}{{x}_{k+1}-{x}_{k}}$

The initial boundary is the equation

$g\prime \left({x}_{0}\right)=g\prime \left(x\right){|}_{k=0,\text{\hspace{0.17em}}x={x}_{0}}$

and the final boundary is the equation

$g\prime \left({x}_{n-1}\right)=g\prime \left(x\right){|}_{k=n-2,\text{\hspace{0.17em}}x={x}_{n-1}}$

For these equations, initial boundary and final boundary are the first derivative of g(x) at points x0 and xn - 1, respectively. If initial boundary and final boundary are equal to or greater than 1030, this node sets the corresponding boundary condition for a natural spline, with no second derivatives on the boundary.

This node solves g"(xi) from n equations when i = 0, 1, …, n - 1. g"(xi) is the interpolant output.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported