Schwefel’s function is often used as a benchmark problem for minimization problems. The function is defined as
f(x,y) = (-x * sin(sqrt(abs(x)))) + (-y * sin(sqrt(abs(y))))
The function has a minimum value of 2 * -418.9829 = -837.9658 when both x = 420.9687 and y = 420.9687. The minimum value is hard to find because it is relatively far from the second best solution.
Here are commands to visualize Schwefel’s function using SciLab, a free open source program similar to MatLab:
x1 = linspace(-500,500,100);
x2 = linspace(-500,500,100);
[X1,X2] = meshgrid(x1,x2);
Z = (-1 * X1. * sin(sqrt(abs(X1)))) + (-1 * X2. * sin(sqrt(abs(X2))));
f = scf();
f.color_map = jetcolormap(64);
SciLab code is close to MatLab code and both are a bit obscure. I generate two vectors of 100 values using linspace, create a cross product of those values using meshgrid (SciLab is case sensitive so X1 is different from x1), defined a function Z (where the dot operator means do a value by value multiplication rather than matrix multiplication), and plot the graph (where the ‘ operator is the transpose operator). The result is shown below. The minimum value is in the far left corner.