github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/mathext/zeta_test.go (about)

     1  // Copyright ©2016 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mathext
     6  
     7  import (
     8  	"math"
     9  	"testing"
    10  )
    11  
    12  func TestZeta(t *testing.T) {
    13  	t.Parallel()
    14  	for i, test := range []struct {
    15  		x, q, want float64
    16  	}{
    17  		// Results computed using scipy.special.zeta
    18  		{1, 1, math.Inf(1)},
    19  		{1.00001, 0.5, 100001.96352290553},
    20  		{1.0001, 25, 9996.8017690244506},
    21  		{1.001, 1, 1000.5772884760117},
    22  		{1.01, 10, 97.773405639173305},
    23  		{1.5, 2, 1.6123753486854886},
    24  		{1.5, 20, 0.45287361712938717},
    25  		{2, -0.7, 14.28618087263834},
    26  		{2.5, 0.5, 6.2471106345688137},
    27  		{5, 2.5, 0.013073166646113805},
    28  		{7.5, 5, 7.9463377443314306e-06},
    29  		{10, -0.5, 2048.0174503557578},
    30  		{10, 0.5, 1024.0174503557578},
    31  		{10, 7.5, 2.5578265694201971e-9},
    32  		{12, 2.5, 1.7089167198843551e-5},
    33  		{17, 0.5, 131072.00101513157},
    34  		{20, -2.5, 2097152.0006014798},
    35  		{20, 0.75, 315.3368689825316},
    36  		{25, 0.25, 1125899906842624.0},
    37  		{30, 1, 1.0000000009313275},
    38  	} {
    39  		if got := Zeta(test.x, test.q); math.Abs(got-test.want) > 1e-10 {
    40  			t.Errorf("test %d Zeta(%g, %g) failed: got %g want %g", i, test.x, test.q, got, test.want)
    41  		}
    42  	}
    43  }