Rewriting logarithmic expressions