The Michalewicz function is a strange math function that is sometimes used to test the effectiveness of numerical optimization algorithms. In math terms, the function is:
The function can accept one or more input values. The function is tricky because there are several local minimum values and several flat areas which make the one global minimum value hard to find for algorithms. I decided to graph the Michalewicz function in with two variables, x and y; therefore the dimension of the function is two, but the graph appears in 3D.
I used SciLab, which is a free alternative to the very pricey MatLab. The SciLab statements I used to create the graph were:
-->[x,y]=meshgrid(0:.05:3.2,0:.05:3.2); -->z=-( (sin(x) .* (sin((1 * x.^2)/%pi)).^20) + (sin(y) .* (sin((2 * y.^2)/%pi)).^20) ); -->g=scf(); -->g.color_map=jetcolormap(64); -->surf(x,y,z);
It took me quite some time to correctly translate the math version of the function into the corresponding SciLab statement, mostly getting my parentheses correct. The first statement above sets up X and Y values from 0 to 3.2 (just a bit less than of pi) every 0.05. The second statement defines the Michalewicz function for two variables. Statements three, four, and five create the graph shown below. For two variables, x and y, the global minimum value is approximately z = -1.8013 when x = 2.20319 and y = 1.57049.