[gnumeric] ACOTH: Fix accuracy for |x| near 1.



commit 5afb1a13bfd9116da635ff751e0703b1f0317fcc
Author: Morten Welinder <terra gnome org>
Date:   Wed Nov 6 19:47:47 2013 -0500

    ACOTH: Fix accuracy for |x| near 1.

 ChangeLog      |    4 ++++
 NEWS           |    1 +
 src/mathfunc.c |    6 ++++--
 3 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c033233..1d743c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-11-06  Morten Welinder  <terra gnome org>
+
+       * src/mathfunc.c (gnm_acoth): Improve accuracy for |x| near 1.
+
 2013-11-06  Jean Brefort  <jean brefort normalesup org>
 
        * src/workbook-view.c: add more introspection related comments.
diff --git a/NEWS b/NEWS
index 569f9d9..fe8647d 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Morten:
        * Improve accuracy of R.QBETA, R.QF, R.QTUKEY, R.QSNORM, and R.QST.
        * Improve accuracy of COMBIN, PERMUT, POCHHAMMER, FACT, GAMMA.
        * Improve accuracy of bessel functions with large non-integer alpha.
+       * Improve accuracy of acoth.
 
 Xabier Rodríguez Calvar:
        * Fix dialog button order. [#710378]
diff --git a/src/mathfunc.c b/src/mathfunc.c
index 3cb8cb7..2799b4d 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -124,8 +124,10 @@ gnm_coth (gnm_float x)
 
 gnm_float
 gnm_acoth (gnm_float x)
-{
-       return gnm_atanh (1 / x);
+{      
+       return (gnm_abs (x) > 2)
+               ? gnm_log1p (2 / (x - 1)) / 2
+               : gnm_log ((x - 1) / (x + 1)) / -2;
 }
 
 /* ------------------------------------------------------------------------- */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]