Optimizing Polynomial Expressions by Factoring