Quadratic Functions, Optimization, and Quadratic Forms