function [f,g] = fg4(n,x) %FG4 function and gradient for f4.CMSC 764 HW1. % [f,g] = fg4(n,x) gives the function value f and % gradient g for the vector x of dimension n for % test problem f4. % % See also Hf4. % Geping Liu 09-21-06 f = (x(1,:) + x(2,:)) .^4 + x(2,:) .^2; g = [4 .* (x(1,:) + x(2,:)) .^3; 4 .* (x(1,:) + x(2,:)) .^3 + 2 .* x(2,:)];