Arithmetic expressions optimizer