function Q = dmoment(b)

% Input: b      kx1 parameter vector
% Output: Q     l x k x n matrix of the derivative of the moment condition

global x

n = length(x(:,1));
k = length(b);
m = moment(b);
l = length(m(1,:));

Q = zeros(l,k,n);

for i = 1:n
    Q(:,:,i) = [-1,-2*(x(i)-b)]';
end