0. To help debug the SplineInterpolater (PR #28019 et al), I need to expose the coefficients in o.a.c.m.analysis.Polynomial as a read-only property (returning an array copy). Any objections to adding this?

While reviewing the code, I also noticed that the current impl uses "naive" evaluation (using Math.pow, etc.). I would like to change this to use Horner's Method. Here is what I have ready to commit:

1. Add protected static double evaluate(double[] coefficients, double argument) implementing Horner to get the function value; and change value(double) to just call this.

2. Add protected static double[] differentiate(double[] coefficients) to return the coefficients of the derivative of the polynomial with coefficients equal to the actual parameter. Then change firstDerivative(x) to just return
evaluate(differentiate(coefficients), x). Similar for secondDerivative.
I could adapt Horner for the derivatives, but that seems messy to me and the slight memory cost to create the temp arrays seems worth it.


3. I would also like to add
public PolynomialFunction derivative() {
  return new PolynomialFunction(differentiate(coefficients));
}

Any objections to this?

Interestingly, while Horner's method should give better numerics, it actually fails to get within 1E-15 for one of the quintic test cases, performing worse than the "naive" impl. The error is in the 16th significant digit, which is not surprising. I would like to change the tolerance to 1E-12 (current tests actually succeed at 1E-14).

Phil


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to