function retval = powell(x) % usage: y = powell(x) % description: Returns value of powell function % assuming that x is a column vector of length 4. % Typical starting point for min: (3,-1,0,1) % Minimum at (0,0,0,0) % a little bit of bulletproofing if (~isvector(x) | (length(x) ~= 4)) error('powell: needs a two-dimensional vector argument'); end if (size(x,2) ~= 1) error('powell: needs a column vector'); end % the actual calculation retval = (x(1)+10*x(2))^2+5*(x(3)-x(4))^2+(x(2)-2*x(3))^4+(10*x(1)-x(4))^4;