nd4j-common/src/main/java/org/nd4j/linalg/util/BigDecimalMath.java
static public double zeta1(final int n) {
        /* precomputed static table in double precision
         */
        final double[] zmin1 = {0., 0., 6.449340668482264364724151666e-01, 2.020569031595942853997381615e-01,
                        8.232323371113819151600369654e-02, 3.692775514336992633136548646e-02,
                        1.734306198444913971451792979e-02, 8.349277381922826839797549850e-03,
                        4.077356197944339378685238509e-03, 2.008392826082214417852769232e-03,
                        9.945751278180853371459589003e-04, 4.941886041194645587022825265e-04,
                        2.460865533080482986379980477e-04, 1.227133475784891467518365264e-04,
                        6.124813505870482925854510514e-05, 3.058823630702049355172851064e-05,
                        1.528225940865187173257148764e-05, 7.637197637899762273600293563e-06,
                        3.817293264999839856461644622e-06, 1.908212716553938925656957795e-06,
                        9.539620338727961131520386834e-07, 4.769329867878064631167196044e-07,
                        2.384505027277329900036481868e-07, 1.192199259653110730677887189e-07,
                        5.960818905125947961244020794e-08, 2.980350351465228018606370507e-08,
                        1.490155482836504123465850663e-08, 7.450711789835429491981004171e-09,
                        3.725334024788457054819204018e-09, 1.862659723513049006403909945e-09,
                        9.313274324196681828717647350e-10, 4.656629065033784072989233251e-10,
                        2.328311833676505492001455976e-10, 1.164155017270051977592973835e-10,
                        5.820772087902700889243685989e-11, 2.910385044497099686929425228e-11,
                        1.455192189104198423592963225e-11, 7.275959835057481014520869012e-12,
                        3.637979547378651190237236356e-12, 1.818989650307065947584832101e-12,
                        9.094947840263889282533118387e-13, 4.547473783042154026799112029e-13,
                        2.273736845824652515226821578e-13, 1.136868407680227849349104838e-13,
                        5.684341987627585609277182968e-14, 2.842170976889301855455073705e-14,
                        1.421085482803160676983430714e-14, 7.105427395210852712877354480e-15,
                        3.552713691337113673298469534e-15, 1.776356843579120327473349014e-15,
                        8.881784210930815903096091386e-16, 4.440892103143813364197770940e-16,
                        2.220446050798041983999320094e-16, 1.110223025141066133720544570e-16,
                        5.551115124845481243723736590e-17, 2.775557562136124172581632454e-17,
                        1.387778780972523276283909491e-17, 6.938893904544153697446085326e-18,
                        3.469446952165922624744271496e-18, 1.734723476047576572048972970e-18,
                        8.673617380119933728342055067e-19, 4.336808690020650487497023566e-19,
                        2.168404344997219785013910168e-19, 1.084202172494241406301271117e-19,
                        5.421010862456645410918700404e-20, 2.710505431223468831954621312e-20,
                        1.355252715610116458148523400e-20, 6.776263578045189097995298742e-21,
                        3.388131789020796818085703100e-21, 1.694065894509799165406492747e-21,
                        8.470329472546998348246992609e-22, 4.235164736272833347862270483e-22,
                        2.117582368136194731844209440e-22, 1.058791184068023385226500154e-22,
                        5.293955920339870323813912303e-23, 2.646977960169852961134116684e-23,
                        1.323488980084899080309451025e-23, 6.617444900424404067355245332e-24,
                        3.308722450212171588946956384e-24, 1.654361225106075646229923677e-24,
                        8.271806125530344403671105617e-25, 4.135903062765160926009382456e-25,
                        2.067951531382576704395967919e-25, 1.033975765691287099328409559e-25,
                        5.169878828456431320410133217e-26, 2.584939414228214268127761771e-26,
                        1.292469707114106670038112612e-26, 6.462348535570531803438002161e-27,
                        3.231174267785265386134814118e-27, 1.615587133892632521206011406e-27,
                        8.077935669463162033158738186e-28, 4.038967834731580825622262813e-28,
                        2.019483917365790349158762647e-28, 1.009741958682895153361925070e-28,
                        5.048709793414475696084771173e-29, 2.524354896707237824467434194e-29,
                        1.262177448353618904375399966e-29, 6.310887241768094495682609390e-30,
                        3.155443620884047239109841220e-30, 1.577721810442023616644432780e-30,
                        7.888609052210118073520537800e-31};


        if (n <= 0) {
            throw new ProviderException("Unimplemented zeta at negative argument " + n);
        }


        if (n == 1) {
            throw new ArithmeticException("Pole at zeta(1) ");
        }


        if (n < zmin1.length) /* look it up if available */ {
            return zmin1[n];
        } else {
            /* Result is roughly 2^(-n), desired accuracy 18 digits. If zeta(n) is computed, the equivalent accuracy
             * in relative units is higher, because zeta is around 1.
             */
            double eps = 1.e-18 * Math.pow(2., (double) (-n));
            MathContext mc = new MathContext(err2prec(eps));


            return zeta(n, mc).subtract(BigDecimal.ONE).doubleValue();


        }
    }
static public double zeta1(final int n) {
        /* precomputed static table in double precision
         */
        final double[] zmin1 = {0., 0., 6.449340668482264364724151666e-01, 2.020569031595942853997381615e-01,
                        8.232323371113819151600369654e-02, 3.692775514336992633136548646e-02,
                        1.734306198444913971451792979e-02, 8.349277381922826839797549850e-03,
                        4.077356197944339378685238509e-03, 2.008392826082214417852769232e-03,
                        9.945751278180853371459589003e-04, 4.941886041194645587022825265e-04,
                        2.460865533080482986379980477e-04, 1.227133475784891467518365264e-04,
                        6.124813505870482925854510514e-05, 3.058823630702049355172851064e-05,
                        1.528225940865187173257148764e-05, 7.637197637899762273600293563e-06,
                        3.817293264999839856461644622e-06, 1.908212716553938925656957795e-06,
                        9.539620338727961131520386834e-07, 4.769329867878064631167196044e-07,
                        2.384505027277329900036481868e-07, 1.192199259653110730677887189e-07,
                        5.960818905125947961244020794e-08, 2.980350351465228018606370507e-08,
                        1.490155482836504123465850663e-08, 7.450711789835429491981004171e-09,
                        3.725334024788457054819204018e-09, 1.862659723513049006403909945e-09,
                        9.313274324196681828717647350e-10, 4.656629065033784072989233251e-10,
                        2.328311833676505492001455976e-10, 1.164155017270051977592973835e-10,
                        5.820772087902700889243685989e-11, 2.910385044497099686929425228e-11,
                        1.455192189104198423592963225e-11, 7.275959835057481014520869012e-12,
                        3.637979547378651190237236356e-12, 1.818989650307065947584832101e-12,
                        9.094947840263889282533118387e-13, 4.547473783042154026799112029e-13,
                        2.273736845824652515226821578e-13, 1.136868407680227849349104838e-13,
                        5.684341987627585609277182968e-14, 2.842170976889301855455073705e-14,
                        1.421085482803160676983430714e-14, 7.105427395210852712877354480e-15,
                        3.552713691337113673298469534e-15, 1.776356843579120327473349014e-15,
                        8.881784210930815903096091386e-16, 4.440892103143813364197770940e-16,
                        2.220446050798041983999320094e-16, 1.110223025141066133720544570e-16,
                        5.551115124845481243723736590e-17, 2.775557562136124172581632454e-17,
                        1.387778780972523276283909491e-17, 6.938893904544153697446085326e-18,
                        3.469446952165922624744271496e-18, 1.734723476047576572048972970e-18,
                        8.673617380119933728342055067e-19, 4.336808690020650487497023566e-19,
                        2.168404344997219785013910168e-19, 1.084202172494241406301271117e-19,
                        5.421010862456645410918700404e-20, 2.710505431223468831954621312e-20,
                        1.355252715610116458148523400e-20, 6.776263578045189097995298742e-21,
                        3.388131789020796818085703100e-21, 1.694065894509799165406492747e-21,
                        8.470329472546998348246992609e-22, 4.235164736272833347862270483e-22,
                        2.117582368136194731844209440e-22, 1.058791184068023385226500154e-22,
                        5.293955920339870323813912303e-23, 2.646977960169852961134116684e-23,
                        1.323488980084899080309451025e-23, 6.617444900424404067355245332e-24,
                        3.308722450212171588946956384e-24, 1.654361225106075646229923677e-24,
                        8.271806125530344403671105617e-25, 4.135903062765160926009382456e-25,
                        2.067951531382576704395967919e-25, 1.033975765691287099328409559e-25,
                        5.169878828456431320410133217e-26, 2.584939414228214268127761771e-26,
                        1.292469707114106670038112612e-26, 6.462348535570531803438002161e-27,
                        3.231174267785265386134814118e-27, 1.615587133892632521206011406e-27,
                        8.077935669463162033158738186e-28, 4.038967834731580825622262813e-28,
                        2.019483917365790349158762647e-28, 1.009741958682895153361925070e-28,
                        5.048709793414475696084771173e-29, 2.524354896707237824467434194e-29,
                        1.262177448353618904375399966e-29, 6.310887241768094495682609390e-30,
                        3.155443620884047239109841220e-30, 1.577721810442023616644432780e-30,
                        7.888609052210118073520537800e-31};


        if (n <= 0) {
            throw new ProviderException("Unimplemented zeta at negative argument " + n);
        }


        if (n == 1) {
            throw new ArithmeticException("Pole at zeta(1) ");
        }


        if (n < zmin1.length) /* look it up if available */ {
            return zmin1[n];
        } else {
            /* Result is roughly 2^(-n), desired accuracy 18 digits. If zeta(n) is computed, the equivalent accuracy
             * in relative units is higher, because zeta is around 1.
             */
            double eps = 1.e-18 * Math.pow(2., (double) (-n));
            MathContext mc = new MathContext(err2prec(eps));


            return zeta(n, mc).subtract(BigDecimal.ONE).doubleValue();


        }
    }
Riemann zeta function.

@param n The positive integer argument.
@return zeta(n)-1.