public static String rewrite ( String expression ) throws InvalidExpressionException { ExpressionTree expTree = parseToTree ( expression ) ; expTree . reduce ( ) ; return expTree . toString ( ) ; }
Rewrite the expression to eliminate redundant terms and simplify the expression .