You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2017/05/11 12:03:35 UTC
[07/18] commons-numbers git commit: NUMBERS-35: Typo (sign error).
NUMBERS-35: Typo (sign error).
Unit tests are missing (see JIRA issue).
Thanks to Stian Soiland-Reyes for spotting that the code did not
agree with the referenced formula.
Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/14f6f851
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/14f6f851
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/14f6f851
Branch: refs/heads/master
Commit: 14f6f851b179249cb74b6dfa5b3c8d193e607186
Parents: f271063
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Mon May 8 12:15:07 2017 +0200
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Mon May 8 12:15:07 2017 +0200
----------------------------------------------------------------------
.../main/java/org/apache/commons/numbers/gamma/Digamma.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/14f6f851/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
----------------------------------------------------------------------
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
index ddcee55..a10f1df 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/Digamma.java
@@ -30,11 +30,11 @@ public class Digamma {
/** S limit. */
private static final double S_LIMIT = 1e-5;
/** Fraction. */
- private static final double F_1_12 = 1d / 12;
+ private static final double F_M1_12 = -1d / 12;
/** Fraction. */
private static final double F_1_120 = 1d / 120;
/** Fraction. */
- private static final double F_1_252 = 1d / 252;
+ private static final double F_M1_252 = -1d / 252;
/**
* Computes the digamma function.
@@ -80,7 +80,7 @@ public class Digamma {
// 1 1 1 1
// log(x) - --- - ------ + ------- - -------
// 2 x 12 x^2 120 x^4 252 x^6
- digamma += Math.log(x) - 0.5 / x - inv * (F_1_12 + inv * (F_1_120 - F_1_252 * inv));
+ digamma += Math.log(x) - 0.5 / x + inv * (F_M1_12 + inv * (F_1_120 + F_M1_252 * inv));
return digamma;
}