diff options
Diffstat (limited to 'nuttx/libc/math/lib_asinh.c')
-rw-r--r-- | nuttx/libc/math/lib_asinh.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/nuttx/libc/math/lib_asinh.c b/nuttx/libc/math/lib_asinh.c index 7b573fcdd..5a30ac1aa 100644 --- a/nuttx/libc/math/lib_asinh.c +++ b/nuttx/libc/math/lib_asinh.c @@ -49,6 +49,20 @@ #ifdef CONFIG_HAVE_DOUBLE double asinh(double x) { - return log(x + sqrt(x * x + 1)); + double y; + double z = x * x; + + if (z < 1E-9) + { + /* x - 1/6 * x^3 + 3/40 * x^5 - 5/112 * x^7 + ... */ + + y = x * (1 - z / 6.0); + } + else + { + y = log(x + sqrt(z + 1)); + } + + return y; } #endif |