* <p>
* |expm1^(n)(zeta)| <= e, zeta in [-1, 1]
*/
@Test
public void testExpm1Function() {
UnivariateFunction f = new Expm1();
UnivariateInterpolator interpolator = new DividedDifferenceInterpolator();
double x[], y[], z, expected, result, tolerance;
// 5 interpolating points on interval [-1, 1]
int n = 5;
double min = -1.0, max = 1.0;
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 = FastMath.E;
UnivariateFunction p = interpolator.interpolate(x, y);
z = 0.0; expected = f.value(z); result = p.value(z);
tolerance = FastMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
z = 0.5; expected = f.value(z); result = p.value(z);
tolerance = FastMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
z = -0.5; expected = f.value(z); result = p.value(z);
tolerance = FastMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
}