Mathematical Definition

\[f(x, y) = x^2 + 2y^2 -0.3cos(3\pi x)-0.4cos(4\pi y)+0.7\]

Plots

Bohachevskyn N. 1 Function

Bohachevskyn N. 1 Function

The contour of the function: Bohachevskyn N. 1 Function Contour

Description and Features

  • The function is continuous.
  • The function is convex.
  • The function is defined on 2-dimensional space.
  • The function is unimodal.

Input Domain

The function can be defined on any input domain but it is usually evaluated on $x_i \in [-100, 100]$ for $i = 1, 2$.

Global Minima

The function has one local minimum at: $f(\textbf{x}^{\ast}) = 0$ at $\textbf{x}^{\ast} = (0, 0)$

Implementation

Python

For Python, the function is implemented in the benchmarkfcns package, which can be installed from command line with pip install benchmarkfcns.

from benchmarkfcns import bohachevsky1

print(bohachevsky1([[0, 0],
              [1, 1]]))

MATLAB

An implementation of the Bohachevskyn N. 1 Function with MATLAB is provided below.

% Computes the value of Bohachevsky N. 1 benchmark function.
% SCORES = BOHACHEVSKYN1FCN(X) computes the value of the Bohachevsky N. 1
% function at point X. BOHACHEVSKYN1FCN accepts a matrix of size M-by-N and 
% returns a vetor SCORES of size M-by-1 in which each row contains the 
% function value for each row of X.
% 
% Author: Mazhar Ansari Ardeh
% Please forward any comments or bug reports to mazhar.ansari.ardeh at
% Google's e-mail service or feel free to kindly modify the repository.
function scores = bohachevskyn1fcn(x)
    n = size(x, 2);
    assert(n == 2, 'The Bohachevsky N. 1 function is only defined on a 2D space.')
    X = x(:, 1);
    Y = x(:, 2);
    
    scores = (X .^ 2) + (2 * Y .^ 2) - (0.3 * cos(3 * pi * X)) - (0.4 * cos(4 * pi * Y)) + 0.7;
end

The function can be represented in Latex as follows:

f(x, y) = x^2 + 2y^2 -0.3cos(3\pi x)-0.4cos(4\pi y)+0.7

References:

  • http://www.sfu.ca/~ssurjano/boha.html