Hi,

I have a few questions regarding the implementation of the quadratic problem in 
the 
org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizerTest.

I assume the quadratic is defined as:
f(x) = a*x^2 + b*x + c

This is the implementation of the jacobian function:

        private double[][] jacobian(double[] variables) {
            double[][] jacobian = new double[x.size()][3];
            for (int i = 0; i < jacobian.length; ++i) {
                jacobian[i][0] = x.get(i) * x.get(i);
                jacobian[i][1] = x.get(i);
                jacobian[i][2] = 1.0;
            }
            return jacobian;
        }

It seems like the lines

                jacobian[i][0] = x.get(i) * x.get(i);
                jacobian[i][1] = x.get(i);
                jacobian[i][2] = 1.0;

Really should be:

                jacobian[i][0] = 2 * x.get(i) * variables[0];
                jacobian[i][1] = variables[1];
                jacobian[i][2] = 0;

Does that make sense?

My second question has to do with the value function below:

        public double[] value(double[] variables) {
            double[] values = new double[x.size()];
            for (int i = 0; i < values.length; ++i) {
                values[i] = (variables[0] * x.get(i) + variables[1]) * x.get(i) 
+ variables[2];
            }
            return values;
        }

Should this:

values[i] = (variables[0] * x.get(i) + variables[1]) * x.get(i) + variables[2];

Really be:

values[i] = (variables[0] * x.get(i)*x.get(i) + variables[1]) * x.get(i) + 
variables[2];

Thanks,
- Ole

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to