* <p>
* |sin^(n)(zeta)| <= 1.0, zeta in [0, 2*PI]
*/
@Test
public void testSinFunction() {
UnivariateFunction f = new SinFunction();
UnivariateInterpolator interpolator = new DividedDifferenceInterpolator();
double x[], y[], z, expected, result, tolerance;
// 6 interpolating points on interval [0, 2*PI]
int n = 6;
double min = 0.0, max = 2 * FastMath.PI;
x = new double[n];
y = new double[n];
for (int i = 0; i < n; i++) {
x[i] = min + i * (max - min) / n;
y[i] = f.value(x[i]);
}
double derivativebound = 1.0;
UnivariateFunction p = interpolator.interpolate(x, y);
z = FastMath.PI / 4; expected = f.value(z); result = p.value(z);
tolerance = FastMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
z = FastMath.PI * 1.5; expected = f.value(z); result = p.value(z);
tolerance = FastMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
}