function [z1,mul] = min_eng(s,t,x,y,z,k,m,n,kappa,lambda)
tic;
z1 = z;
E1 = energy3d(x,y,z1,kappa,lambda);
mul = ones(size(z));
for ct=1:k
    for i=0:m
        for j=0:n
            if (j ~= 1)
                test = s.^(j).*cos(2*(i)*t);
                z0 = z1.*(mul+0.0001*test);
                E0 = energy3d(x,y,z0,kappa,lambda);
                dE = E1 - E0;
                dm = 0.1;
                decide = true;
                while (decide)
                    z0 = z1.*(mul + sign(dE)*dm*test);
                    E0 = energy3d(x,y,z0,kappa,lambda);
                    if (E0 < E1)
                        mul = mul + sign(dE)*dm*test;
                        E1 = E0;
                    else
                        dm = dm/10;
                    end
                    if (dm < 0.00001)
                        decide = false;
                    end
                end
                [ct,i,j,E1]
                toc;
                figure(1); close(1); figure(1);
                surf(x,y,z1.*mul,'edgecolor','none'); hold on;
                surf(-x,y,z1.*mul,'edgecolor','none'); hold on;
                axis equal; axis([-max(max(x)),max(max(x)),-max(max(y)),max(max(y)),0,lambda/kappa]);
                view([0,90]); light;
                pause(5);
            end
        end
    end
end
z1 = mul.*z;