Linear Optimization of Polynomials and Rational Functions over Boxes