Mathematical Definition
f(x, y)=\sum_{i=1}^{n}[b (x_{i+1} - x_i^2)^ 2 + (a - x_i)^2]
Description and Features

Dimensions: d

The Rosenbrock function, also referred to as the Valley or Banana function, is a popular test problem for gradient-based optimization algorithms. It is shown in the plot above in its two-dimensional form.

The function is unimodal, and the global minimum lies in a narrow, parabolic valley. However, even though this valley is easy to find, convergence to the minimum is difficult (Picheny et al., 2012).

  • The function is continuous.
  • The function is convex.
  • The function is defined on n-dimensional space.
  • The function is multimodal.
  • The function is differentiable.
  • The function is non-separable.
Input Domain

The function is usually evaluated on the hypercube $x_i \in [-5, 10]$, for all $i=1, …, d$, although it may be restricted to the hypercube $x_i \in [-2.048, 2.048]$, for all $i=1, …, d$.

Global Minima

The function has one global minimum $f(\textbf{x}^{\ast})=0$ at $\textbf{x}^{\ast} = (1, …, 1)$.

Python Code

def function(x):
    x = np.array(x)
    return np.sum([((1. - x[i]) ** 2)
                    + (100 * (x[i + 1] - x[i] ** 2) ** 2)
                    for i in range(len(x) - 1)])