/* zetacf.c
*
* Riemann zeta function
*
*
*
* SYNOPSIS :
*
* float x , y , zetacf ( ) ;
*
* y = zetacf ( x ) ;
*
*
*
* DESCRIPTION :
*
*
*
* inf .
* - - x
* zetac ( x ) = > k , x > 1 ,
* -
* k = 2
*
* is related to the Riemann zeta function by
*
* Riemann zeta ( x ) = zetac ( x ) + 1 .
*
* Extension of the function definition for x < 1 is implemented .
* Zero is returned for x > log2 ( MAXNUM ) .
*
* An overflow error may occur for large negative x , due to the
* gamma function in the reflection formula .
*
* ACCURACY :
*
* Tabulated values have full machine accuracy .
*
* Relative error :
* arithmetic domain # trials peak rms
* IEEE 1 , 50 30000 5 . 5 e - 7 7 . 5 e - 8
*
*
*/
/*
Cephes Math Library Release 2 . 2 : July , 1992
Copyright 1984 , 1987 , 1989 , 1992 by Stephen L . Moshier
Direct inquiries to 30 Frost Street , Cambridge , MA 02140
*/
#include "mconf.h"
/* Riemann zeta(x) - 1
* for integer arguments between 0 and 30 .
*/
static float azetacf[] = {
-1 .50000000000000000000 E0,
1 .70141183460469231730 E38, /* infinity. */
6 .44934066848226436472 E-1 ,
2 .02056903159594285400 E-1 ,
8 .23232337111381915160 E-2 ,
3 .69277551433699263314 E-2 ,
1 .73430619844491397145 E-2 ,
8 .34927738192282683980 E-3 ,
4 .07735619794433937869 E-3 ,
2 .00839282608221441785 E-3 ,
9 .94575127818085337146 E-4 ,
4 .94188604119464558702 E-4 ,
2 .46086553308048298638 E-4 ,
1 .22713347578489146752 E-4 ,
6 .12481350587048292585 E-5 ,
3 .05882363070204935517 E-5 ,
1 .52822594086518717326 E-5 ,
7 .63719763789976227360 E-6 ,
3 .81729326499983985646 E-6 ,
1 .90821271655393892566 E-6 ,
9 .53962033872796113152 E-7 ,
4 .76932986787806463117 E-7 ,
2 .38450502727732990004 E-7 ,
1 .19219925965311073068 E-7 ,
5 .96081890512594796124 E-8 ,
2 .98035035146522801861 E-8 ,
1 .49015548283650412347 E-8 ,
7 .45071178983542949198 E-9 ,
3 .72533402478845705482 E-9 ,
1 .86265972351304900640 E-9 ,
9 .31327432419668182872 E-10
};
/* 2**x (1 - 1/x) (zeta(x) - 1) = P(1/x)/Q(1/x), 1 <= x <= 10 */
static float P[9 ] = {
5 .85746514569725319540 E11,
2 .57534127756102572888 E11,
4 .87781159567948256438 E10,
5 .15399538023885770696 E9,
3 .41646073514754094281 E8,
1 .60837006880656492731 E7,
5 .92785467342109522998 E5,
1 .51129169964938823117 E4,
2 .01822444485997955865 E2,
};
static float Q[8 ] = {
/* 1.00000000000000000000E0,*/
3 .90497676373371157516 E11,
5 .22858235368272161797 E10,
5 .64451517271280543351 E9,
3 .39006746015350418834 E8,
1 .79410371500126453702 E7,
5 .66666825131384797029 E5,
1 .60382976810944131506 E4,
1 .96436237223387314144 E2,
};
/* log(zeta(x) - 1 - 2**-x), 10 <= x <= 50 */
static float A[11 ] = {
8 .70728567484590192539 E6,
1 .76506865670346462757 E8,
2 .60889506707483264896 E10,
5 .29806374009894791647 E11,
2 .26888156119238241487 E13,
3 .31884402932705083599 E14,
5 .13778997975868230192 E15,
-1 .98123688133907171455 E15,
-9 .92763810039983572356 E16,
7 .82905376180870586444 E16,
9 .26786275768927717187 E16,
};
static float B[10 ] = {
/* 1.00000000000000000000E0,*/
-7 .92625410563741062861 E6,
-1 .60529969932920229676 E8,
-2 .37669260975543221788 E10,
-4 .80319584350455169857 E11,
-2 .07820961754173320170 E13,
-2 .96075404507272223680 E14,
-4 .86299103694609136686 E15,
5 .34589509675789930199 E15,
5 .71464111092297631292 E16,
-1 .79915597658676556828 E16,
};
/* (1-x) (zeta(x) - 1), 0 <= x <= 1 */
static float R[6 ] = {
-3 .28717474506562731748 E-1 ,
1 .55162528742623950834 E1,
-2 .48762831680821954401 E2,
1 .01050368053237678329 E3,
1 .26726061410235149405 E4,
-1 .11578094770515181334 E5,
};
static float S[5 ] = {
/* 1.00000000000000000000E0,*/
1 .95107674914060531512 E1,
3 .17710311750646984099 E2,
3 .03835500874445748734 E3,
2 .03665876435770579345 E4,
7 .43853965136767874343 E4,
};
#define MAXL2 127
/*
* Riemann zeta function , minus one
*/
extern float MACHEPF, PIO2F, MAXNUMF, PIF;
#ifndef ANSIC
float sinf(), floorf(), gammaf(), powf(), expf();
float polevlf(), p1evlf();
#endif
#ifdef ANSIC
float zetacf(float xx)
#else
float zetacf(xx)
double xx;
#endif
{
int i;
float x, a, b, s, w;
x = xx;
if ( x < 0 .0 )
{
if ( x < -30 .8148 )
{
mtherr( "zetacf" , OVERFLOW );
return (0 .0 );
}
s = 1 .0 - x;
w = zetacf( s );
b = sinf(PIO2F*x) * powf(2 .0 *PIF, x) * gammaf(s) * (1 .0 + w) / PIF;
return (b - 1 .0 );
}
if ( x >= MAXL2 )
return (0 .0 ); /* because first term is 2**-x */
/* Tabulated values for integer argument */
w = floorf(x);
if ( w == x )
{
i = x;
if ( i < 31 )
{
return ( azetacf[i] );
}
}
if ( x < 1 .0 )
{
w = 1 .0 - x;
a = polevlf( x, R, 5 ) / ( w * p1evlf( x, S, 5 ));
return ( a );
}
if ( x == 1 .0 )
{
mtherr( "zetacf" , SING );
return ( MAXNUMF );
}
if ( x <= 10 .0 )
{
b = powf( 2 .0 , x ) * (x - 1 .0 );
w = 1 .0 /x;
s = (x * polevlf( w, P, 8 )) / (b * p1evlf( w, Q, 8 ));
return ( s );
}
if ( x <= 50 .0 )
{
b = powf( 2 .0 , -x );
w = polevlf( x, A, 10 ) / p1evlf( x, B, 10 );
w = expf(w) + b;
return (w);
}
/* Basic sum of inverse powers */
s = 0 .0 ;
a = 1 .0 ;
do
{
a += 2 .0 ;
b = powf( a, -x );
s += b;
}
while ( b/s > MACHEPF );
b = powf( 2 .0 , -x );
s = (s + b)/(1 .0 -b);
return (s);
}
Messung V0.5 in Prozent C=95 H=91 G=92
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-14)
¤
*© Formatika GbR, Deutschland