}
@Test
public void testCompose() {
double[] epsilon = new double[] { 1.0e-20, 5.0e-14, 2.0e-13, 3.0e-13, 2.0e-13, 1.0e-20 };
PolynomialFunction poly =
new PolynomialFunction(new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 });
for (int maxOrder = 0; maxOrder < 6; ++maxOrder) {
PolynomialFunction[] p = new PolynomialFunction[maxOrder + 1];
p[0] = poly;
for (int i = 1; i <= maxOrder; ++i) {
p[i] = p[i - 1].polynomialDerivative();
}
for (double x = 0.1; x < 1.2; x += 0.001) {
DerivativeStructure dsX = new DerivativeStructure(1, maxOrder, 0, x);
DerivativeStructure dsY1 = dsX.getField().getZero();
for (int i = poly.degree(); i >= 0; --i) {
dsY1 = dsY1.multiply(dsX).add(poly.getCoefficients()[i]);
}
double[] f = new double[maxOrder + 1];
for (int i = 0; i < f.length; ++i) {
f[i] = p[i].value(x);
}