PatWie / CppNumericalSolvers

a lightweight header-only C++17 library of numerical optimization methods for nonlinear functions based on Eigen
MIT License
878 stars 201 forks source link

Hessian of Rosenbrock function is incorrect #117

Closed chobby closed 5 years ago

chobby commented 5 years ago

I tested Rosenbrock function for my own Newton's solver. It didn't converge because of incorrect Hessian.

    // same for hessian (OPTIONAL)
    // if you want ot use 2nd-order solvers, I encourage you to specify the hessian
    // finite differences usually (this implementation) behave bad
    void hessian(const TVector &x, THessian &hessian) {
        hessian(0, 0) = 1200 * x[0] * x[0] - 400 * x[1] + 1;
        hessian(0, 1) = -400 * x[0];
        hessian(1, 0) = -400 * x[0];
        hessian(1, 1) = 200;
    }

hessian(0, 0) would be 1200 x[0] x[0] - 400 * x[1] + "2". http://www.robots.ox.ac.uk/~az/lectures/b1/answers.pdf

PatWie commented 5 years ago

Yes that is a typo.

PatWie commented 5 years ago

fixed