Improved definition of log to be more consistent when the argument includes negative values.