function [J,X,Y] = precompute_cost(A, b, num_pts, xmin,xmax,ymin,ymax)

xmin=-3;
xmax=6;
ymin=-3;
ymax=6;


x=[(xmin:((xmax-xmin)/num_pts):xmax)' (ymin:((ymax-ymin)/num_pts):ymax)']';
for i=1:length(x(1,:)),
    for j=1:length(x(2,:)),
        J(i,j) = 0.5*[x(1,i); x(2,j)]'*A*[x(1,i); x(2,j)] - b'*[x(1,i); x(2,j)];
    end
end

[X,Y]=meshgrid(x(1,:),x(2,:));

