.
f[x_,y_]=x+y;
aa={{-1,2},{-1,2}};nn=2;s1=10000;z=0;jd=0.01;uu={{1,2,3,4}, {5,6,7,8}};
While[((uu[[1,4]]-uu[[1,1]])?jd)||((uu[[2,4]]-uu[[2,1]])?jd),For[i=1,i?nn,i++,For[j=1,j?4,j++,uu[[i,j]]=aa[[i,1]]+(j-1)*(aa[[i,2]]-aa[[i,1]])/3]];
For [ii=1,ii?4,ii++, For[jj=1,jj?4,jj++,
s2=f[uu[[1,ii]],uu[[2,jj]]];If[s2<=s1,z=s2;s2=s1;s1=z;kk={ii,jj}]];For[iii=1,iii?nn,iii++,If[kk[[iii]]?1,aa[[iii,1]]=uu[[iii,1]];aa[[iii,2]]=uu[[iii,2]],If[kk[[iii]]==4,aa[[iii,1]]=uu[[iii,3]];aa[[iii,2]]=uu[[iii,4]],aa[[iii,1]]=uu[[iii,kk[[iii]]-1]];aa[[iii,2]]=uu[[iii,kk[[iii]]+1]]]]]];]Print[z];Print[\t[\
..