x = y = linspace (-512, 512, 150);
[xx, yy] = meshgrid (x, y);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
#z = sin (r) ./ r + a*sign(xx) ./ xx + b*sign(yy) ./yy;
terma = -(yy .+ 47).*sin(sqrt(abs(yy.+(xx./2).+47)));
termb = - xx.*sin(sqrt(abs(xx.-(yy.+47))));
z =  terma .+ termb

mesh (x, y, z);
hold on;
plot3(512,404.2319,-909,'or;Global minimum;',"markersize", 30);
xlabel ("x");
ylabel ("y");
zlabel ("z");
title ("Eggholder Function");


