added a new function FormulaElement::optimize().

This patch is one of the preparations to optimize the entire formula
to improve performance.