⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zeta.c

📁 开放gsl矩阵运算
💻 C
📖 第 1 页 / 共 2 页
字号:
/* specfunc/zeta.c *  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman *  * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* Author:  G. Jungman */#include <config.h>#include <gsl/gsl_math.h>#include <gsl/gsl_errno.h>#include "gsl_sf_elementary.h"#include "gsl_sf_exp.h"#include "gsl_sf_gamma.h"#include "gsl_sf_pow_int.h"#include "gsl_sf_zeta.h"#include "error.h"#include "chebyshev.h"#include "cheb_eval.c"#define LogTwoPi_  1.8378770664093454835606594728111235279723/*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*//* chebyshev fit for (s(t)-1)Zeta[s(t)] * s(t)= (t+1)/2 * -1 <= t <= 1 */static double zeta_xlt1_data[14] = {  1.48018677156931561235192914649,  0.25012062539889426471999938167,  0.00991137502135360774243761467, -0.00012084759656676410329833091, -4.7585866367662556504652535281e-06,  2.2229946694466391855561441361e-07, -2.2237496498030257121309056582e-09, -1.0173226513229028319420799028e-10,  4.3756643450424558284466248449e-12, -6.2229632593100551465504090814e-14, -6.6116201003272207115277520305e-16,  4.9477279533373912324518463830e-17, -1.0429819093456189719660003522e-18,  6.9925216166580021051464412040e-21,};static cheb_series zeta_xlt1_cs = {  zeta_xlt1_data,  13,  -1, 1,  8};/* chebyshev fit for (s(t)-1)Zeta[s(t)] * s(t)= (19t+21)/2 * -1 <= t <= 1 */static double zeta_xgt1_data[30] = {  19.3918515726724119415911269006,   9.1525329692510756181581271500,   0.2427897658867379985365270155,  -0.1339000688262027338316641329,   0.0577827064065028595578410202,  -0.0187625983754002298566409700,   0.0039403014258320354840823803,  -0.0000581508273158127963598882,  -0.0003756148907214820704594549,   0.0001892530548109214349092999,  -0.0000549032199695513496115090,   8.7086484008939038610413331863e-6,   6.4609477924811889068410083425e-7,  -9.6749773915059089205835337136e-7,   3.6585400766767257736982342461e-7,  -8.4592516427275164351876072573e-8,   9.9956786144497936572288988883e-9,   1.4260036420951118112457144842e-9,  -1.1761968823382879195380320948e-9,   3.7114575899785204664648987295e-10,  -7.4756855194210961661210215325e-11,   7.8536934209183700456512982968e-12,   9.9827182259685539619810406271e-13,  -7.5276687030192221587850302453e-13,   2.1955026393964279988917878654e-13,  -4.1934859852834647427576319246e-14,   4.6341149635933550715779074274e-15,   2.3742488509048340106830309402e-16,  -2.7276516388124786119323824391e-16,   7.8473570134636044722154797225e-17};static cheb_series zeta_xgt1_cs = {  zeta_xgt1_data,  29,  -1, 1,  17};/* assumes s >= 0 and s != 1.0 */inlinestatic intriemann_zeta_sgt0(double s, gsl_sf_result * result){  if(s < 1.0) {    gsl_sf_result c;    cheb_eval_e(&zeta_xlt1_cs, 2.0*s - 1.0, &c);    result->val = c.val / (s - 1.0);    result->err = c.err / fabs(s-1.0) + GSL_DBL_EPSILON * fabs(result->val);    return GSL_SUCCESS;  }  else if(s <= 20.0) {    double x = (2.0*s - 21.0)/19.0;    gsl_sf_result c;    cheb_eval_e(&zeta_xgt1_cs, x, &c);    result->val = c.val / (s - 1.0);    result->err = c.err / (s - 1.0) + GSL_DBL_EPSILON * fabs(result->val);    return GSL_SUCCESS;  }  else {    double f2 = 1.0 - pow(2.0,-s);    double f3 = 1.0 - pow(3.0,-s);    double f5 = 1.0 - pow(5.0,-s);    double f7 = 1.0 - pow(7.0,-s);    result->val = 1.0/(f2*f3*f5*f7);    result->err = 3.0 * GSL_DBL_EPSILON * fabs(result->val);    return GSL_SUCCESS;  }}inlinestatic intriemann_zeta1m_slt0(double s, gsl_sf_result * result){  if(s > -19.0) {    double x = (-19 - 2.0*s)/19.0;    gsl_sf_result c;    cheb_eval_e(&zeta_xgt1_cs, x, &c);    result->val = c.val / (-s);    result->err = c.err / (-s) + GSL_DBL_EPSILON * fabs(result->val);    return GSL_SUCCESS;  }  else {    double f2 = 1.0 - pow(2.0,-(1.0-s));    double f3 = 1.0 - pow(3.0,-(1.0-s));    double f5 = 1.0 - pow(5.0,-(1.0-s));    double f7 = 1.0 - pow(7.0,-(1.0-s));    result->val = 1.0/(f2*f3*f5*f7);    result->err = 3.0 * GSL_DBL_EPSILON * fabs(result->val);    return GSL_SUCCESS;  }}/* zeta(n) */#define ZETA_POS_TABLE_NMAX   100static double zeta_pos_int_table[ZETA_POS_TABLE_NMAX+1] = { -0.50000000000000000000000000000,       /* zeta(0) */  0.0 /* FIXME: DirectedInfinity() */,   /* zeta(1) */  1.64493406684822643647241516665,       /* ...     */  1.20205690315959428539973816151,  1.08232323371113819151600369654,  1.03692775514336992633136548646,  1.01734306198444913971451792979,  1.00834927738192282683979754985,  1.00407735619794433937868523851,  1.00200839282608221441785276923,  1.00099457512781808533714595890,  1.00049418860411946455870228253,  1.00024608655330804829863799805,  1.00012271334757848914675183653,  1.00006124813505870482925854511,  1.00003058823630702049355172851,  1.00001528225940865187173257149,  1.00000763719763789976227360029,  1.00000381729326499983985646164,  1.00000190821271655393892565696,  1.00000095396203387279611315204,  1.00000047693298678780646311672,  1.00000023845050272773299000365,  1.00000011921992596531107306779,  1.00000005960818905125947961244,  1.00000002980350351465228018606,  1.00000001490155482836504123466,  1.00000000745071178983542949198,  1.00000000372533402478845705482,  1.00000000186265972351304900640,  1.00000000093132743241966818287,  1.00000000046566290650337840730,  1.00000000023283118336765054920,  1.00000000011641550172700519776,  1.00000000005820772087902700889,  1.00000000002910385044497099687,  1.00000000001455192189104198424,  1.00000000000727595983505748101,  1.00000000000363797954737865119,  1.00000000000181898965030706595,  1.00000000000090949478402638893,  1.00000000000045474737830421540,  1.00000000000022737368458246525,  1.00000000000011368684076802278,  1.00000000000005684341987627586,  1.00000000000002842170976889302,  1.00000000000001421085482803161,  1.00000000000000710542739521085,  1.00000000000000355271369133711,  1.00000000000000177635684357912,  1.00000000000000088817842109308,  1.00000000000000044408921031438,  1.00000000000000022204460507980,  1.00000000000000011102230251411,  1.00000000000000005551115124845,  1.00000000000000002775557562136,  1.00000000000000001387778780973,  1.00000000000000000693889390454,  1.00000000000000000346944695217,  1.00000000000000000173472347605,  1.00000000000000000086736173801,  1.00000000000000000043368086900,  1.00000000000000000021684043450,  1.00000000000000000010842021725,  1.00000000000000000005421010862,  1.00000000000000000002710505431,  1.00000000000000000001355252716,  1.00000000000000000000677626358,  1.00000000000000000000338813179,  1.00000000000000000000169406589,  1.00000000000000000000084703295,  1.00000000000000000000042351647,  1.00000000000000000000021175824,  1.00000000000000000000010587912,  1.00000000000000000000005293956,  1.00000000000000000000002646978,  1.00000000000000000000001323489,  1.00000000000000000000000661744,  1.00000000000000000000000330872,  1.00000000000000000000000165436,  1.00000000000000000000000082718,  1.00000000000000000000000041359,  1.00000000000000000000000020680,  1.00000000000000000000000010340,  1.00000000000000000000000005170,  1.00000000000000000000000002585,  1.00000000000000000000000001292,  1.00000000000000000000000000646,  1.00000000000000000000000000323,  1.00000000000000000000000000162,  1.00000000000000000000000000081,  1.00000000000000000000000000040,  1.00000000000000000000000000020,  1.00000000000000000000000000010,  1.00000000000000000000000000005,  1.00000000000000000000000000003,  1.00000000000000000000000000001,  1.00000000000000000000000000001,  1.00000000000000000000000000000,  1.00000000000000000000000000000,  1.00000000000000000000000000000};#define ZETA_NEG_TABLE_NMAX  99#define ZETA_NEG_TABLE_SIZE  50static double zeta_neg_int_table[ZETA_NEG_TABLE_SIZE] = { -0.083333333333333333333333333333,     /* zeta(-1) */  0.008333333333333333333333333333,     /* zeta(-3) */ -0.003968253968253968253968253968,     /* ...      */  0.004166666666666666666666666667, -0.007575757575757575757575757576,  0.021092796092796092796092796093, -0.083333333333333333333333333333,  0.44325980392156862745098039216, -3.05395433027011974380395433027,  26.4562121212121212121212121212, -281.460144927536231884057971014,  3607.5105463980463980463980464, -54827.583333333333333333333333,  974936.82385057471264367816092, -2.0052695796688078946143462272e+07,  4.7238486772162990196078431373e+08, -1.2635724795916666666666666667e+10,  3.8087931125245368811553022079e+11, -1.2850850499305083333333333333e+13,  4.8241448354850170371581670362e+14, -2.0040310656516252738108421663e+16,  9.1677436031953307756992753623e+17, -4.5979888343656503490437943262e+19,  2.5180471921451095697089023320e+21, -1.5001733492153928733711440151e+23,  9.6899578874635940656497942895e+24, -6.7645882379292820990945242302e+26,  5.0890659468662289689766332916e+28, -4.1147288792557978697665486068e+30,  3.5666582095375556109684574609e+32, -3.3066089876577576725680214670e+34,  3.2715634236478716264211227016e+36, -3.4473782558278053878256455080e+38,  3.8614279832705258893092720200e+40, -4.5892974432454332168863989006e+42,  5.7775386342770431824884825688e+44, -7.6919858759507135167410075972e+46,  1.0813635449971654696354033351e+49, -1.6029364522008965406067102346e+51,  2.5019479041560462843656661499e+53, -4.1067052335810212479752045004e+55,  7.0798774408494580617452972433e+57, -1.2804546887939508790190849756e+60,  2.4267340392333524078020892067e+62, -4.8143218874045769355129570066e+64,  9.9875574175727530680652777408e+66, -2.1645634868435185631335136160e+69,  4.8962327039620553206849224516e+71,    /* ...        */ -1.1549023923963519663954271692e+74,    /* zeta(-97)  */  2.8382249570693706959264156336e+76     /* zeta(-99)  */};/* coefficients for Maclaurin summation in hzeta() * B_{2j}/(2j)! */static double hzeta_c[15] = {  1.00000000000000000000000000000,  0.083333333333333333333333333333, -0.00138888888888888888888888888889,  0.000033068783068783068783068783069, -8.2671957671957671957671957672e-07,  2.0876756987868098979210090321e-08, -5.2841901386874931848476822022e-10,  1.3382536530684678832826980975e-11, -3.3896802963225828668301953912e-13,  8.5860620562778445641359054504e-15, -2.1748686985580618730415164239e-16,  5.5090028283602295152026526089e-18, -1.3954464685812523340707686264e-19,  3.5347070396294674716932299778e-21, -8.9535174270375468504026113181e-23};#define ETA_POS_TABLE_NMAX  100static double eta_pos_int_table[ETA_POS_TABLE_NMAX+1] = {0.50000000000000000000000000000,  /* eta(0) */M_LN2,                            /* eta(1) */0.82246703342411321823620758332,  /* ...    */0.90154267736969571404980362113,0.94703282949724591757650323447,0.97211977044690930593565514355,0.98555109129743510409843924448,0.99259381992283028267042571313,0.99623300185264789922728926008,0.99809429754160533076778303185,0.99903950759827156563922184570,0.99951714349806075414409417483,0.99975768514385819085317967871,0.99987854276326511549217499282,0.99993917034597971817095419226,0.99996955121309923808263293263,0.99998476421490610644168277496,0.99999237829204101197693787224,0.99999618786961011347968922641,0.99999809350817167510685649297,0.99999904661158152211505084256,0.99999952325821554281631666433,0.99999976161323082254789720494,0.99999988080131843950322382485,0.99999994039889239462836140314,0.99999997019885696283441513311,0.99999998509923199656878766181,0.99999999254955048496351585274,0.99999999627475340010872752767,0.99999999813736941811218674656,0.99999999906868228145397862728,0.99999999953434033145421751469,0.99999999976716989595149082282,0.99999999988358485804603047265,0.99999999994179239904531592388,0.99999999997089618952980952258,0.99999999998544809143388476396,0.99999999999272404460658475006,0.99999999999636202193316875550,0.99999999999818101084320873555,0.99999999999909050538047887809,0.99999999999954525267653087357,0.99999999999977262633369589773,0.99999999999988631316532476488,0.99999999999994315658215465336,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -