# Finding a good difficult example function to minimize

I am comparing some code for non-linear function minimization in multiple variables, like quasi-Newton methods etc. I am looking for a nice function to use as a test case.

So far I have been using $f(\bf x) = \frac{1}{2} {\bf x}^T A {\bf x}$ where $\bf A$ is a random symmetric positive definite matrix. This is nice because I can easily compute the gradient and Hessian and condition number. However it is too easy.

I'm looking for a function of two or more variables where one can analytically compute the gradient and Hessian. It does not need to be convex, so long as I can start the minimization with an initial point so that simple gradient descent will find a well known minimum. Ideally I'd like the function to have a narrow valley that is curved and not a straight shot from the starting point to the minimum, so I can test how well algorithms deal with following such narrow valleys without excessive zig zagging function evaluations.

• Ooh thats pretty good... Mar 15, 2015 at 2:02
• Shame you didn't put those in an answer. Great pointer! Mar 15, 2015 at 22:11
• I don't understand to whom you are answering and what pointer you are speaking about ? Has an answer been cancellated ? Jul 6, 2016 at 22:10

Peter Spellucci's test cases for DONLP2. The documents on that page provide both text examples and the results from DONLP2, so you can check your answers against his. Many of his examples are constrained optimization problems, but quite are few are not, so they should be usable.

One interesting example is the Rosenbrock "banana" function $$f(x,y) = (1 - x)^2 + 100 (y - x^2)^2$$ Oh -- I see that this function was already mentioned in the comment above. I'll leave it here in my answer, anyway, because I don't think the site's search function looks at comments.

You can compare your results with Mathematica here.

Wikipedia has a nice list of test functions for optimization, including "long valley" variations as well as functions with several local minima, sometimes separated by steep walls.

Here, a list of functions, given the shape, you can see, it's difficult to optimize.....

Griewank Function: http://i.stack.imgur.com/8dLq0.png

Kursawe Function: http://i.stack.imgur.com/qvrBD.png