Generalize the log function