% Find min of q(x)=x^2+bx+c given b,c,L,R

b= 2;  c= -1.5;  % coefficients of q(x)
L= -3;  R= 5;    % left & right ends of interval 

xc = -b/2;  % critical value

if (L<=xc && xc<=R)
   qMin= -b*b/4+c;  % q(xc)
else
   qL= L*L + b*L + c;  % q(L)
   qR= R*R + b*R + c;  % q(R)
   if (qL < qR)
      qMin= qL;
   else
      qMin= qR;
   end
end

fprintf('Min value is %.4f\n', qMin)