# Griewank function

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Griewank_function
> Markdown URL: https://mediated.wiki/source/Griewank_function.md
> Source: https://en.wikipedia.org/wiki/Griewank_function
> Source revision: 1281386829
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

thumb|200px|2D Plot of the one dimensional Griewank function

The '''Griewank [test function](/source/Test_functions_for_optimization)''' is a [smooth](/source/Smoothness) multidimensional mathematical function used in unconstrained optimization. It is commonly employed to evaluate the performance of [global optimization](/source/global_optimization) algorithms.
The function is defined<ref>Griewank, A. O. "Generalized Descent for Global Optimization." J. Opt. Th. Appl. 34, 11–39, 1981</ref> as:

: <math>f(x) = 1 + \tfrac{1}{4000}\sum_{i=1}^n x_i^2 - \prod_{i=1}^n P_i(x_i) \text{ with }  P_i(x_i)=\cos\left(\tfrac{x_i}{\sqrt{i}}\right)</math>

where <math>x = (x_1,\dots,x_n) \in \mathbb{R}^n</math> is a vector of real-valued variables. The nonlinear and nonconvex function is characterized by its unique multimodal structure, featuring multiple local minima and maxima around its single global minimum at <math>x^\ast = 0</math>, where the function has minimal value  <math>f(x^\ast) = 0</math>. The number of stationary points increases as the dimensionality <math>n \in \mathbb{N}</math> grows.

thumb|200px|3D plot of the two dimensional Griewank function

For instance, the one-dimensional Griewank function <math>f(x_1) := 1+(1/4000)\cdot x_1^2-\cos(x_1)</math>
has 6365 [critical points](/source/Critical_point_(mathematics)) in the interval [−10000,10000], where the first derivative vanishes. These points satisfy the equation <math>\nabla f(x_1) = \tfrac{1}{2000} \cdot x_1 + \sin(x_1) = 0</math>.

thumb|200px|Contour plot of the two dimensional Griewank function

The multimodal structure of the Griewank function presents a challenge for many [deterministic](/source/Deterministic_algorithm) optimization algorithms, which may become trapped in one of the numerous local minima. This is particularly problematic for [gradient](/source/gradient)-based methods. The Griewank function is commonly used to benchmark global optimization algorithms, such as [genetic algorithms](/source/genetic_algorithms) or [particle swarm optimization](/source/particle_swarm_optimization). In addition to the original version, there are several variants of the Griewank function specifically designed to test algorithms in high-dimensional optimization scenarios.<ref>Locatelli, M. "A Note on the Griewank Test Function." J. Global Opt. 25, 169–174, 2003</ref>

== Non-Smooth Variant of the Griewank Function ==

A non-smooth version of the Griewank function has been developed<ref>{{Cite journal |last1=Bosse |first1=Torsten F. |last2=Bücker |first2=H. Martin |date=2024-10-29 |title=A piecewise smooth version of the Griewank function |journal=Optimization Methods and Software |language=en |pages=1–11 |doi=10.1080/10556788.2024.2414186 |issn=1055-6788|doi-access=free }}</ref> to emulate the characteristics of objective functions frequently encountered  in optimization problems from [machine learning](/source/machine_learning) (ML). These functions often exhibit [piecewise](/source/piecewise_function) smooth or non-smooth behavior due to the presence of [regularization terms](/source/Regularization_(mathematics)), [activation functions](/source/Activation_function), or constraints in learning models.

A non-smooth variant of the Griewank function is the following:

: <math>
f(x) = 1 + \frac{1}{4000} \sum_{i=1}^n x_i^2 - \prod_{i=1}^n P_i(x_i) \text{ with } P_i(x_i)=\left| \cos\left(\frac{x_i}{2\sqrt{i}}\right) \right| - \left| \sin\left(\frac{x_i}{2\sqrt{i}}\right) \right|.
</math>

By incorporating non-smooth elements, such as absolute values in the cosine and sine terms, this function mimics the irregularities present in many ML loss landscapes. It offers a robust benchmark for evaluating optimization algorithms, especially those designed to handle the challenges of non-convex, non-smooth, or high-dimensional problems, including sub-gradient, hybrid, and evolutionary methods.

The function's resemblance to practical ML objective functions makes it particularly valuable for testing the robustness and efficiency of algorithms in tasks such as [hyperparameter tuning](/source/hyperparameter_tuning), neural network training, and constrained optimization.

==References==
<references/>

Category:Special functions
Category:Test functions for optimization

---
Adapted from the Wikipedia article [Griewank function](https://en.wikipedia.org/wiki/Griewank_function) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Griewank_function?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
