double div = (i + 1) / 29.0;
DerivativeStructure s1 = variables[0].getField().getZero();
DerivativeStructure dx = variables[0].getField().getOne();
for (int j = 1; j < n; ++j) {
s1 = s1.add(dx.multiply(j).multiply(variables[j]));
dx = dx.multiply(div);
}
DerivativeStructure s2 = variables[0].getField().getZero();
dx = variables[0].getField().getOne();
for (int j = 0; j < n; ++j) {
s2 = s2.add(dx.multiply(variables[j]));