# Rastrigin function

Rastrigin function of two variables
In 3D
Contour

In mathematical optimization, the Rastrigin function is a non-convex function used as a performance test problem for optimization algorithms. It is a typical example of non-linear multimodal function. It was first proposed by Rastrigin [1] as a 2-dimensional function and has been generalized by Mühlenbein et al.[2] Finding the minimum of this function is a fairly difficult problem due to its large search space and its large number of local minima.

On an n-dimensional domain it is defined by:

${\displaystyle f(\mathbf {x} )=An+\sum _{i=1}^{n}\left[x_{i}^{2}-A\cos(2\pi x_{i})\right]}$

where ${\displaystyle A=10}$ and ${\displaystyle x_{i}\in [-5.12,5.12]}$. It has a global minimum at ${\displaystyle \mathbf {x} =\mathbf {0} }$ where ${\displaystyle f(\mathbf {x} )=0}$.