% ---------- exampleObjAndGrad.m ---------
function [obj, grad] = exampleObjAndGrad(x)
% ---------- compute objective ----------
x1 = x(1);
x2 = x(2);
x3 = x(3);
x4 = x(4);

obj = 1/4*x4^4*x3 + 1/3*x3^3*x2 + 1/2*x2^2 + x1*x3^2 + 1;


% ---------- compute gradient ----------
grad(1) = x3^2;
grad(2) = 1/3*x3^3 + x2;
grad(3) = 1/4*x4^4 + x3^2*x2+x1*2*x3;
grad(4) = x4^3*x3;

return