/* fresnl.c
*
* Fresnel integral
*
*
*
* SYNOPSIS :
*
* double x , S , C ;
* void fresnl ( ) ;
*
* fresnl ( x , _ & S , _ & C ) ;
*
*
* DESCRIPTION :
*
* Evaluates the Fresnel integrals
*
* x
* -
* | |
* C ( x ) = | cos ( pi / 2 t * * 2 ) dt ,
* | |
* -
* 0
*
* x
* -
* | |
* S ( x ) = | sin ( pi / 2 t * * 2 ) dt .
* | |
* -
* 0
*
*
* The integrals are evaluated by a power series for x < 1 .
* For x > = 1 auxiliary functions f ( x ) and g ( x ) are employed
* such that
*
* C ( x ) = 0 . 5 + f ( x ) sin ( pi / 2 x * * 2 ) - g ( x ) cos ( pi / 2 x * * 2 )
* S ( x ) = 0 . 5 - f ( x ) cos ( pi / 2 x * * 2 ) - g ( x ) sin ( pi / 2 x * * 2 )
*
*
*
* ACCURACY :
*
* Relative error .
*
* Arithmetic function domain # trials peak rms
* IEEE S ( x ) 0 , 10 10000 2 . 0 e - 15 3 . 2 e - 16
* IEEE C ( x ) 0 , 10 10000 1 . 8 e - 15 3 . 3 e - 16
* DEC S ( x ) 0 , 10 6000 2 . 2 e - 16 3 . 9 e - 17
* DEC C ( x ) 0 , 10 5000 2 . 3 e - 16 3 . 9 e - 17
*/
/*
Cephes Math Library Release 2 . 8 : June , 2000
Copyright 1984 , 1987 , 1989 , 2000 by Stephen L . Moshier
*/
#include "mconf.h"
/* S(x) for small x */
#ifdef UNK
static double sn[6 ] = {
-2 .99181919401019853726 E3,
7 .08840045257738576863 E5,
-6 .29741486205862506537 E7,
2 .54890880573376359104 E9,
-4 .42979518059697779103 E10,
3 .18016297876567817986 E11,
};
static double sd[6 ] = {
/* 1.00000000000000000000E0,*/
2 .81376268889994315696 E2,
4 .55847810806532581675 E4,
5 .17343888770096400730 E6,
4 .19320245898111231129 E8,
2 .24411795645340920940 E10,
6 .07366389490084639049 E11,
};
#endif
#ifdef DEC
static unsigned short sn[24 ] = {
0143072 ,0176433 ,0065455 ,0127034 ,
0045055 ,0007200 ,0134540 ,0026661 ,
0146560 ,0035061 ,0023667 ,0127545 ,
0050027 ,0166503 ,0002673 ,0153756 ,
0151045 ,0002721 ,0121737 ,0102066 ,
0051624 ,0013177 ,0033451 ,0021271 ,
};
static unsigned short sd[24 ] = {
/*0040200,0000000,0000000,0000000,*/
0042214 ,0130051 ,0112070 ,0101617 ,
0044062 ,0010307 ,0172346 ,0152510 ,
0045635 ,0160575 ,0143200 ,0136642 ,
0047307 ,0171215 ,0127457 ,0052361 ,
0050647 ,0031447 ,0032621 ,0013510 ,
0052015 ,0064733 ,0117362 ,0012653 ,
};
#endif
#ifdef IBMPC
static unsigned short sn[24 ] = {
0 xb5c3,0 x6d65,0 x5fa3,0 xc0a7,
0 x05b6,0 x172c,0 xa1d0,0 x4125,
0 xf5ed,0 x24f6,0 x0746,0 xc18e,
0 x7afe,0 x60b7,0 xfda8,0 x41e2,
0 xf087,0 x347b,0 xa0ba,0 xc224,
0 x2457,0 xe6e5,0 x82cf,0 x4252,
};
static unsigned short sd[24 ] = {
/*0x0000,0x0000,0x0000,0x3ff0,*/
0 x1072,0 x3287,0 x9605,0 x4071,
0 xdaa9,0 xfe9c,0 x4218,0 x40e6,
0 x17b4,0 xb8d0,0 xbc2f,0 x4153,
0 xea9e,0 xb5e5,0 xfe51,0 x41b8,
0 x22e9,0 xe6b2,0 xe664,0 x4214,
0 x42b5,0 x73de,0 xad3b,0 x4261,
};
#endif
#ifdef MIEEE
static unsigned short sn[24 ] = {
0 xc0a7,0 x5fa3,0 x6d65,0 xb5c3,
0 x4125,0 xa1d0,0 x172c,0 x05b6,
0 xc18e,0 x0746,0 x24f6,0 xf5ed,
0 x41e2,0 xfda8,0 x60b7,0 x7afe,
0 xc224,0 xa0ba,0 x347b,0 xf087,
0 x4252,0 x82cf,0 xe6e5,0 x2457,
};
static unsigned short sd[24 ] = {
/*0x3ff0,0x0000,0x0000,0x0000,*/
0 x4071,0 x9605,0 x3287,0 x1072,
0 x40e6,0 x4218,0 xfe9c,0 xdaa9,
0 x4153,0 xbc2f,0 xb8d0,0 x17b4,
0 x41b8,0 xfe51,0 xb5e5,0 xea9e,
0 x4214,0 xe664,0 xe6b2,0 x22e9,
0 x4261,0 xad3b,0 x73de,0 x42b5,
};
#endif
/* C(x) for small x */
#ifdef UNK
static double cn[6 ] = {
-4 .98843114573573548651 E-8 ,
9 .50428062829859605134 E-6 ,
-6 .45191435683965050962 E-4 ,
1 .88843319396703850064 E-2 ,
-2 .05525900955013891793 E-1 ,
9 .99999999999999998822 E-1 ,
};
static double cd[7 ] = {
3 .99982968972495980367 E-12 ,
9 .15439215774657478799 E-10 ,
1 .25001862479598821474 E-7 ,
1 .22262789024179030997 E-5 ,
8 .68029542941784300606 E-4 ,
4 .12142090722199792936 E-2 ,
1 .00000000000000000118 E0,
};
#endif
#ifdef DEC
static unsigned short cn[24 ] = {
0132126 ,0040141 ,0063733 ,0013231 ,
0034037 ,0072223 ,0010200 ,0075637 ,
0135451 ,0021020 ,0073264 ,0036057 ,
0036632 ,0131520 ,0101316 ,0060233 ,
0137522 ,0072541 ,0136124 ,0132202 ,
0040200 ,0000000 ,0000000 ,0000000 ,
};
static unsigned short cd[28 ] = {
0026614 ,0135503 ,0051776 ,0032631 ,
0030573 ,0121116 ,0154033 ,0126712 ,
0032406 ,0034100 ,0012442 ,0106212 ,
0034115 ,0017567 ,0150520 ,0164623 ,
0035543 ,0106171 ,0177336 ,0146351 ,
0037050 ,0150073 ,0000607 ,0171635 ,
0040200 ,0000000 ,0000000 ,0000000 ,
};
#endif
#ifdef IBMPC
static unsigned short cn[24 ] = {
0 x62d3,0 x2cfb,0 xc80c,0 xbe6a,
0 x0f74,0 x6210,0 xee92,0 x3ee3,
0 x8786,0 x0ed6,0 x2442,0 xbf45,
0 xcc13,0 x1059,0 x566a,0 x3f93,
0 x9690,0 x378a,0 x4eac,0 xbfca,
0 x0000,0 x0000,0 x0000,0 x3ff0,
};
static unsigned short cd[28 ] = {
0 xc6b3,0 x6a7f,0 x9768,0 x3d91,
0 x75b9,0 xdb03,0 x7449,0 x3e0f,
0 x5191,0 x02a4,0 xc708,0 x3e80,
0 x1d32,0 xfa2a,0 xa3ee,0 x3ee9,
0 xd99d,0 x3fdb,0 x718f,0 x3f4c,
0 xfe74,0 x6030,0 x1a07,0 x3fa5,
0 x0000,0 x0000,0 x0000,0 x3ff0,
};
#endif
#ifdef MIEEE
static unsigned short cn[24 ] = {
0 xbe6a,0 xc80c,0 x2cfb,0 x62d3,
0 x3ee3,0 xee92,0 x6210,0 x0f74,
0 xbf45,0 x2442,0 x0ed6,0 x8786,
0 x3f93,0 x566a,0 x1059,0 xcc13,
0 xbfca,0 x4eac,0 x378a,0 x9690,
0 x3ff0,0 x0000,0 x0000,0 x0000,
};
static unsigned short cd[28 ] = {
0 x3d91,0 x9768,0 x6a7f,0 xc6b3,
0 x3e0f,0 x7449,0 xdb03,0 x75b9,
0 x3e80,0 xc708,0 x02a4,0 x5191,
0 x3ee9,0 xa3ee,0 xfa2a,0 x1d32,
0 x3f4c,0 x718f,0 x3fdb,0 xd99d,
0 x3fa5,0 x1a07,0 x6030,0 xfe74,
0 x3ff0,0 x0000,0 x0000,0 x0000,
};
#endif
/* Auxiliary function f(x) */
#ifdef UNK
static double fn[10 ] = {
4 .21543555043677546506 E-1 ,
1 .43407919780758885261 E-1 ,
1 .15220955073585758835 E-2 ,
3 .45017939782574027900 E-4 ,
4 .63613749287867322088 E-6 ,
3 .05568983790257605827 E-8 ,
1 .02304514164907233465 E-10 ,
1 .72010743268161828879 E-13 ,
1 .34283276233062758925 E-16 ,
3 .76329711269987889006 E-20 ,
};
static double fd[10 ] = {
/* 1.00000000000000000000E0,*/
7 .51586398353378947175 E-1 ,
1 .16888925859191382142 E-1 ,
6 .44051526508858611005 E-3 ,
1 .55934409164153020873 E-4 ,
1 .84627567348930545870 E-6 ,
1 .12699224763999035261 E-8 ,
3 .60140029589371370404 E-11 ,
5 .88754533621578410010 E-14 ,
4 .52001434074129701496 E-17 ,
1 .25443237090011264384 E-20 ,
};
#endif
#ifdef DEC
static unsigned short fn[40 ] = {
0037727 ,0152216 ,0106601 ,0016214 ,
0037422 ,0154606 ,0112710 ,0071355 ,
0036474 ,0143453 ,0154253 ,0166545 ,
0035264 ,0161606 ,0022250 ,0073743 ,
0033633 ,0110036 ,0024653 ,0136246 ,
0032003 ,0036652 ,0041164 ,0036413 ,
0027740 ,0174122 ,0046305 ,0036726 ,
0025501 ,0125270 ,0121317 ,0167667 ,
0023032 ,0150555 ,0076175 ,0047443 ,
0020061 ,0133570 ,0070130 ,0027657 ,
};
static unsigned short fd[40 ] = {
/*0040200,0000000,0000000,0000000,*/
0040100 ,0063767 ,0054413 ,0151452 ,
0037357 ,0061566 ,0007243 ,0065754 ,
0036323 ,0005365 ,0033552 ,0133625 ,
0035043 ,0101123 ,0000275 ,0165402 ,
0033367 ,0146614 ,0110623 ,0023647 ,
0031501 ,0116644 ,0125222 ,0144263 ,
0027436 ,0062051 ,0117235 ,0001411 ,
0025204 ,0111543 ,0056370 ,0036201 ,
0022520 ,0071351 ,0015227 ,0122144 ,
0017554 ,0172240 ,0112713 ,0005006 ,
};
#endif
#ifdef IBMPC
static unsigned short fn[40 ] = {
0 x2391,0 xd1b0,0 xfa91,0 x3fda,
0 x0e5e,0 xd2b9,0 x5b30,0 x3fc2,
0 x7dad,0 x7b15,0 x98e5,0 x3f87,
0 x0efc,0 xc495,0 x9c70,0 x3f36,
0 x7795,0 xc535,0 x7203,0 x3ed3,
0 x87a1,0 x484e,0 x67b5,0 x3e60,
0 xa7bb,0 x4998,0 x1f0a,0 x3ddc,
0 xfdf7,0 x1459,0 x3557,0 x3d48,
0 xa9e4,0 xaf8f,0 x5a2d,0 x3ca3,
0 x05f6,0 x0e0b,0 x36ef,0 x3be6,
};
static unsigned short fd[40 ] = {
/*0x0000,0x0000,0x0000,0x3ff0,*/
0 x7a65,0 xeb21,0 x0cfe,0 x3fe8,
0 x6d7d,0 xc1d4,0 xec6e,0 x3fbd,
0 x56f3,0 xa6ed,0 x615e,0 x3f7a,
0 xbd60,0 x6017,0 x704a,0 x3f24,
0 x64f5,0 x9232,0 xf9b1,0 x3ebe,
0 x5916,0 x9552,0 x33b4,0 x3e48,
0 xa061,0 x33d3,0 xcc85,0 x3dc3,
0 x0790,0 x6b9f,0 x926c,0 x3d30,
0 xf48d,0 x2352,0 x0e5d,0 x3c8a,
0 x6141,0 x12b9,0 x9e94,0 x3bcd,
};
#endif
#ifdef MIEEE
static unsigned short fn[40 ] = {
0 x3fda,0 xfa91,0 xd1b0,0 x2391,
0 x3fc2,0 x5b30,0 xd2b9,0 x0e5e,
0 x3f87,0 x98e5,0 x7b15,0 x7dad,
0 x3f36,0 x9c70,0 xc495,0 x0efc,
0 x3ed3,0 x7203,0 xc535,0 x7795,
0 x3e60,0 x67b5,0 x484e,0 x87a1,
0 x3ddc,0 x1f0a,0 x4998,0 xa7bb,
0 x3d48,0 x3557,0 x1459,0 xfdf7,
0 x3ca3,0 x5a2d,0 xaf8f,0 xa9e4,
0 x3be6,0 x36ef,0 x0e0b,0 x05f6,
};
static unsigned short fd[40 ] = {
/*0x3ff0,0x0000,0x0000,0x0000,*/
0 x3fe8,0 x0cfe,0 xeb21,0 x7a65,
0 x3fbd,0 xec6e,0 xc1d4,0 x6d7d,
0 x3f7a,0 x615e,0 xa6ed,0 x56f3,
0 x3f24,0 x704a,0 x6017,0 xbd60,
0 x3ebe,0 xf9b1,0 x9232,0 x64f5,
0 x3e48,0 x33b4,0 x9552,0 x5916,
0 x3dc3,0 xcc85,0 x33d3,0 xa061,
0 x3d30,0 x926c,0 x6b9f,0 x0790,
0 x3c8a,0 x0e5d,0 x2352,0 xf48d,
0 x3bcd,0 x9e94,0 x12b9,0 x6141,
};
#endif
/* Auxiliary function g(x) */
#ifdef UNK
static double gn[11 ] = {
5 .04442073643383265887 E-1 ,
1 .97102833525523411709 E-1 ,
1 .87648584092575249293 E-2 ,
6 .84079380915393090172 E-4 ,
1 .15138826111884280931 E-5 ,
9 .82852443688422223854 E-8 ,
4 .45344415861750144738 E-10 ,
1 .08268041139020870318 E-12 ,
1 .37555460633261799868 E-15 ,
8 .36354435630677421531 E-19 ,
1 .86958710162783235106 E-22 ,
};
static double gd[11 ] = {
/* 1.00000000000000000000E0,*/
1 .47495759925128324529 E0,
3 .37748989120019970451 E-1 ,
2 .53603741420338795122 E-2 ,
8 .14679107184306179049 E-4 ,
1 .27545075667729118702 E-5 ,
1 .04314589657571990585 E-7 ,
4 .60680728146520428211 E-10 ,
1 .10273215066240270757 E-12 ,
1 .38796531259578871258 E-15 ,
8 .39158816283118707363 E-19 ,
1 .86958710162783236342 E-22 ,
};
#endif
#ifdef DEC
static unsigned short gn[44 ] = {
0040001 ,0021435 ,0120406 ,0053123 ,
0037511 ,0152523 ,0037703 ,0122011 ,
0036631 ,0134302 ,0122721 ,0110235 ,
0035463 ,0051712 ,0043215 ,0114732 ,
0034101 ,0025677 ,0147725 ,0057630 ,
0032323 ,0010342 ,0067523 ,0002206 ,
0030364 ,0152247 ,0110007 ,0054107 ,
0026230 ,0057654 ,0035464 ,0047124 ,
0023706 ,0036401 ,0167705 ,0045440 ,
0021166 ,0154447 ,0105632 ,0142461 ,
0016142 ,0002353 ,0011175 ,0170530 ,
};
static unsigned short gd[44 ] = {
/*0040200,0000000,0000000,0000000,*/
0040274 ,0145551 ,0016742 ,0127005 ,
0037654 ,0166557 ,0076416 ,0015165 ,
0036717 ,0140217 ,0030675 ,0050111 ,
0035525 ,0110060 ,0076405 ,0070502 ,
0034125 ,0176061 ,0060120 ,0031730 ,
0032340 ,0001615 ,0054343 ,0120501 ,
0030375 ,0041414 ,0070747 ,0107060 ,
0026233 ,0031034 ,0160757 ,0074526 ,
0023710 ,0003341 ,0137100 ,0144664 ,
0021167 ,0126414 ,0023774 ,0015435 ,
0016142 ,0002353 ,0011175 ,0170530 ,
};
#endif
#ifdef IBMPC
static unsigned short gn[44 ] = {
0 xcaca,0 xb420,0 x2463,0 x3fe0,
0 x7481,0 x67f8,0 x3aaa,0 x3fc9,
0 x3214,0 x54ba,0 x3718,0 x3f93,
0 xb33b,0 x48d1,0 x6a79,0 x3f46,
0 xabf3,0 xf9fa,0 x2577,0 x3ee8,
0 x6091,0 x4dea,0 x621c,0 x3e7a,
0 xeb09,0 xf200,0 x9a94,0 x3dfe,
0 x89cb,0 x8766,0 x0bf5,0 x3d73,
0 xa964,0 x3df8,0 xc7a0,0 x3cd8,
0 x58a6,0 xf173,0 xdb24,0 x3c2e,
0 xbe2b,0 x624f,0 x409d,0 x3b6c,
};
static unsigned short gd[44 ] = {
/*0x0000,0x0000,0x0000,0x3ff0,*/
0 x55c1,0 x23bc,0 x996d,0 x3ff7,
0 xc34f,0 xefa1,0 x9dad,0 x3fd5,
0 xaa09,0 xe637,0 xf811,0 x3f99,
0 xae28,0 x0fa0,0 xb206,0 x3f4a,
0 x067b,0 x2c0a,0 xbf86,0 x3eea,
0 x7428,0 xab1c,0 x0071,0 x3e7c,
0 xf1c6,0 x8e3c,0 xa861,0 x3dff,
0 xef2b,0 x9c3d,0 x6643,0 x3d73,
0 x1936,0 x37c8,0 x00dc,0 x3cd9,
0 x8364,0 x84ff,0 xf5a1,0 x3c2e,
0 xbe2b,0 x624f,0 x409d,0 x3b6c,
};
#endif
#ifdef MIEEE
static unsigned short gn[44 ] = {
0 x3fe0,0 x2463,0 xb420,0 xcaca,
0 x3fc9,0 x3aaa,0 x67f8,0 x7481,
0 x3f93,0 x3718,0 x54ba,0 x3214,
0 x3f46,0 x6a79,0 x48d1,0 xb33b,
0 x3ee8,0 x2577,0 xf9fa,0 xabf3,
0 x3e7a,0 x621c,0 x4dea,0 x6091,
0 x3dfe,0 x9a94,0 xf200,0 xeb09,
0 x3d73,0 x0bf5,0 x8766,0 x89cb,
0 x3cd8,0 xc7a0,0 x3df8,0 xa964,
0 x3c2e,0 xdb24,0 xf173,0 x58a6,
0 x3b6c,0 x409d,0 x624f,0 xbe2b,
};
static unsigned short gd[44 ] = {
/*0x3ff0,0x0000,0x0000,0x0000,*/
0 x3ff7,0 x996d,0 x23bc,0 x55c1,
0 x3fd5,0 x9dad,0 xefa1,0 xc34f,
0 x3f99,0 xf811,0 xe637,0 xaa09,
0 x3f4a,0 xb206,0 x0fa0,0 xae28,
0 x3eea,0 xbf86,0 x2c0a,0 x067b,
0 x3e7c,0 x0071,0 xab1c,0 x7428,
0 x3dff,0 xa861,0 x8e3c,0 xf1c6,
0 x3d73,0 x6643,0 x9c3d,0 xef2b,
0 x3cd9,0 x00dc,0 x37c8,0 x1936,
0 x3c2e,0 xf5a1,0 x84ff,0 x8364,
0 x3b6c,0 x409d,0 x624f,0 xbe2b,
};
#endif
#ifdef ANSIPROT
extern double fabs ( double );
extern double cos ( double );
extern double sin ( double );
extern double polevl ( double , void *, int );
extern double p1evl ( double , void *, int );
#else
double fabs(), cos(), sin(), polevl(), p1evl();
#endif
extern double PI, PIO2, MACHEP;
int fresnl( xxa, ssa, cca )
double xxa, *ssa, *cca;
{
double f, g, cc, ss, c, s, t, u;
double x, x2;
x = fabs(xxa);
x2 = x * x;
if ( x2 < 2 .5625 )
{
t = x2 * x2;
ss = x * x2 * polevl( t, sn, 5 )/p1evl( t, sd, 6 );
cc = x * polevl( t, cn, 5 )/polevl(t, cd, 6 );
goto done;
}
if ( x > 36974 .0 )
{
cc = 0 .5 ;
ss = 0 .5 ;
goto done;
}
/* Asymptotic power series auxiliary functions
* for large argument
*/
x2 = x * x;
t = PI * x2;
u = 1 .0 /(t * t);
t = 1 .0 /t;
f = 1 .0 - u * polevl( u, fn, 9 )/p1evl(u, fd, 10 );
g = t * polevl( u, gn, 10 )/p1evl(u, gd, 11 );
t = PIO2 * x2;
c = cos(t);
s = sin(t);
t = PI * x;
cc = 0 .5 + (f * s - g * c)/t;
ss = 0 .5 - (f * c + g * s)/t;
done:
if ( xxa < 0 .0 )
{
cc = -cc;
ss = -ss;
}
*cca = cc;
*ssa = ss;
return (0 );
}
Messung V0.5 in Prozent C=97 H=97 G=96