Addressing feedback regarding comments and copyright
MODIFY
gamma_inc_test.go
gamma_inc_test.go
@@ -47,9 +47,9 @@ func TestGammaIncComp(t *testing.T) {
{1, 0, 1},
{1, 1, 0.36787944117144233},
{1, 10, 4.5399929762484861e-05},
- {5, 1, 0.99634015317265634},
{5, 10, 0.029252688076961127},
{100, 10, 1},
+ {1, math.Inf(1), 0},
} {
if got := GammaIncComp(test.a, test.x); math.Abs(got-test.want) > 1e-10 {
t.Errorf("test %d GammaIncComp(%g, %g) failed: got %g want %g", i, test.a, test.x, got, test.want)
@@ -69,7 +69,7 @@ func TestGammaIncCompInv(t *testing.T) {
{0.5, 0.5, 0.22746821155978625},
{0.75, 0.25, 1.0340914067758025},
{1, 0.5, 0.69314718055994529},
- {1, 0, math.MaxFloat64},
+ {1, 0, math.Inf(1)},
{1, 1, 0},
{10, 0.5, 9.6687146147141299},
{100, 0.25, 106.5510925269767},

MODIFY
internal/cephes/unity.go
internal/cephes/unity.go
@@ -11,6 +11,12 @@ package cephes
import "math"
+// Relative error approximations for function arguments near unity.
+// log1p(x) = log(1+x)
+// expm1(x) = exp(x) - 1
+// cosm1(x) = cos(x) - 1
+// lgam1p(x) = lgam(1+x)
+
const (
invSqrt2 = 1 / math.Sqrt2
pi4 = math.Pi / 4

MODIFY
internal/cephes/zeta.go
internal/cephes/zeta.go
@@ -38,12 +38,6 @@ var zetaCoefs = []float64{
// q is either zero or a negative integer, or q is negative and x is not an
// integer.
//
-// The Euler-Maclaurin summation formula is used to obtain the expansion:
-// Zeta(x,q) = \sum_{k=1}^n (k+q)^{-x} + \frac{(n+q)^{1-x}}{x-1} - \frac{1}{2(n+q)^x} + \sum_{j=1}^{\infty} \frac{B_{2j}x(x+1)...(x+2j)}{(2j)! (n+q)^{x+2j+1}}
-// where
-// B_{2j}
-// are Bernoulli numbers.
-//
// Note that:
// zeta(x,1) = zetac(x) + 1
//
@@ -63,7 +57,7 @@ func Zeta(x, q float64) float64 {
panic(badParamFunctionSingularity)
}
if x != math.Floor(x) {
- panic(badParamOutOfBounds) // because q^-x not defined
+ panic(badParamOutOfBounds) // Because q^-x not defined
}
}
@@ -72,8 +66,11 @@ func Zeta(x, q float64) float64 {
return (1/(x-1) + 1/(2*q)) * math.Pow(q, 1-x)
}
- // Euler-Maclaurin summation formula
-
+ // The Euler-Maclaurin summation formula is used to obtain the expansion:
+ // Zeta(x,q) = \sum_{k=1}^n (k+q)^{-x} + \frac{(n+q)^{1-x}}{x-1} - \frac{1}{2(n+q)^x} + \sum_{j=1}^{\infty} \frac{B_{2j}x(x+1)...(x+2j)}{(2j)! (n+q)^{x+2j+1}}
+ // where
+ // B_{2j}
+ // are Bernoulli numbers.
// Permit negative q but continue sum until n+q > 9. This case should be
// handled by a reflection formula. If q<0 and x is an integer, there is a
// relation to the polyGamma function.

Addressing feedback regarding comments and copyright