function [p,flin,fval]=rect_underestimator(Asqr,b,Acol,Arow,U,V,rect)

options=optimset('Display','off');

assert(size(U,2)==size(rect,1));
assert(size(U,2)==size(V,1));

%rectangular constriants
Arec=kron([-1;1],U');
brec=[-rect(:,1);rect(:,2)];

f=b;
cnt=0;%constant
for ii=1:size(U,2)
    f=f-V(ii)*(rect(ii,1)+rect(ii,2))*U(:,ii);%linearization of quadratic terms
    cnt=cnt+V(ii)*rect(ii,1)*rect(ii,2);%constant term
end
[p,flin]=linprog(f,...
    [Arec;Acol],[brec;ones(size(Acol,1),1)],...
    Arow,ones(size(Arow,1),1),...
    zeros(size(U,1),1),ones(size(U,1),1),[],options);
flin=flin+cnt;%linear lower bound
fval=b'*p-sumsqr(Asqr*p);%function value