Rewriting and simplifying logarithmic expressions