function [f,j]=fun_wrong(x) f = x(:).^2; j = 2*x(:); end