{
double tolerance = 1e-15;
double x[] = { 0.0, 0.5, 1.0, 1.5 };
double y[] = { 0.0, 0.5, 1.0, 1.5 };
UnivariateInterpolator i = new SplineInterpolator();
UnivariateFunction f = i.interpolate(x, y);
verifyInterpolation(f, x, y);
// Verify coefficients using analytical values
PolynomialFunction polynomials[] = ((PolynomialSplineFunction) f).getPolynomials();
double target[] = {y[0], 1d};
TestUtils.assertEquals(polynomials[0].getCoefficients(), target, coefficientTolerance);
target = new double[]{y[1], 1d};
TestUtils.assertEquals(polynomials[1].getCoefficients(), target, coefficientTolerance);
target = new double[]{y[2], 1d};
TestUtils.assertEquals(polynomials[2].getCoefficients(), target, coefficientTolerance);
// Check interpolation
Assert.assertEquals(0,f.value(0), tolerance);
Assert.assertEquals(1.4,f.value(1.4), tolerance);
Assert.assertEquals(1.5,f.value(1.5), tolerance);
}