How to evaluate an algebraic expression