Log(1+x) ======== Author: Momchil Ivanov Date : 2014.11.05 Introduction ------------ This article contains notes on the numerical stability of log(1+x). There are claims that directly computing log(1+x) is inaccurate for small x when 1+x=1 in machine arithmetic. Method 1 -------- Trivial method to compute: z=1.0+x y=log(z) Method 2 -------- Claims to cancel errors with IEEE arithmetic [2]: z=1.0+x y=log(z)-((z-1.0)-x)/z Method 3 -------- Uses Taylor expansion for small x [1]: if (abs(x) > 1e-4) y=log(1.0+x) else y=(1.0-0.5*x)*x References ---------- 1: http://www.johndcook.com/cpp_log_one_plus_x.html 2: http://www.davidgsimpson.com/software/invhyp_f90.txt