luc.maisonobe@free.fr on 29/05/08 10:24, wrote:
> In the previous message, I called twr what was really twrPrime, and I used a too slow
method to compute it with a double loop. Here is a much simpler and faster way to compute
this derivative:
>
> public class TwrDerivative implements UnivariateRealFunction {
>
> private final double[] a;
>
> public TwrDerivative(double[] pl, double[] b) {
> a = new double[pl.length];
> for (int i = 0; i < a.length; ++i) {
> a[i] = pl[i] / b[i];
> }
> }
>
> public double value(double f) {
> double twr = 1;
> double twrPrime = 0;
> for (int i = 0; i < a.length; ++i) {
> double factor = 1 + a[i] * f;
> twrPrime = twrPrime * factor + twr * a[i];
> twr *= factor;
> }
> return twrPrime;
> }
>
> }
OK, great, I'll replace that. I'm just coding it now. The iteration count for
the solver is 7, which is great considering it would have been 22 by the brute
force algorithm, and potentially 100 with other data.

To unsubscribe, email: userunsubscribe@commons.apache.org
For additional commands, email: userhelp@commons.apache.org
