[gnumeric] ERF: Fix accuracy of 2-argument version.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ERF: Fix accuracy of 2-argument version.
- Date: Wed, 26 Jun 2013 01:01:11 +0000 (UTC)
commit b2370227582f4da4116d9fe3b880acd9cc39b27e
Author: Morten Welinder <terra gnome org>
Date: Tue Jun 25 21:00:51 2013 -0400
ERF: Fix accuracy of 2-argument version.
NEWS | 3 +++
plugins/fn-eng/ChangeLog | 4 ++++
plugins/fn-eng/functions.c | 15 +++++++--------
3 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index 39f1152..dff0766 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.12.4
+Morten:
+ * Improve accuracy for 2-argument ERF.
+
--------------------------------------------------------------------------
Gnumeric 1.12.3
diff --git a/plugins/fn-eng/ChangeLog b/plugins/fn-eng/ChangeLog
index f302082..773528c 100644
--- a/plugins/fn-eng/ChangeLog
+++ b/plugins/fn-eng/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-25 Morten Welinder <terra gnome org>
+
+ * functions.c (gnumeric_erf): Fix accuracy for 2-argument version.
+
2013-06-25 Morten Welinder <terra gnome org>
* Release 1.12.3
diff --git a/plugins/fn-eng/functions.c b/plugins/fn-eng/functions.c
index 963aa4a..3763a94 100644
--- a/plugins/fn-eng/functions.c
+++ b/plugins/fn-eng/functions.c
@@ -1077,6 +1077,7 @@ static GnmFuncHelp const help_erf[] = {
{ GNM_FUNC_HELP_DESCRIPTION, F_("ERF returns 2/sqrt(\xcf\x80)* integral from @{lower} to @{upper} of
exp(-t*t) dt") },
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible if two arguments are supplied and
neither is negative.") },
{ GNM_FUNC_HELP_EXAMPLES, "=ERF(0.4)" },
+ { GNM_FUNC_HELP_EXAMPLES, "=ERF(6,10)" },
{ GNM_FUNC_HELP_EXAMPLES, "=ERF(1.6448536269515/SQRT(2))" },
{ GNM_FUNC_HELP_SEEALSO, "ERFC" },
{ GNM_FUNC_HELP_EXTREF, F_("wiki:en:Error_function") },
@@ -1086,16 +1087,14 @@ static GnmFuncHelp const help_erf[] = {
static GnmValue *
gnumeric_erf (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- gnm_float ans, lower, upper;
-
- lower = value_get_as_float (argv[0]);
- ans = gnm_erf (lower);
+ gnm_float lower = value_get_as_float (argv[0]);
+ gnm_float ans;
if (argv[1]) {
- /* FIXME: This is suboptimal. */
- upper = value_get_as_float (argv[1]);
- ans = gnm_erf (upper) - ans;
- }
+ gnm_float upper = value_get_as_float (argv[1]);
+ ans = 2 * pnorm2 (lower * M_SQRT2gnum, upper * M_SQRT2gnum);
+ } else
+ ans = gnm_erf (lower);
return value_new_float (ans);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]