/* ndtrll.c
*
* Normal distribution function
* 128 - bit long double version
*
*
*
* SYNOPSIS :
*
* long double x , y , ndtrl ( ) ;
*
* y = ndtrl ( x ) ;
*
*
*
* DESCRIPTION :
*
* Returns the area under the Gaussian probability density
* function , integrated from minus infinity to x :
*
* x
* -
* 1 | | 2
* ndtr ( x ) = - - - - - - - - - | exp ( - t / 2 ) dt
* sqrt ( 2 pi ) | |
* -
* - inf .
*
* = ( 1 + erf ( z ) ) / 2
* = erfc ( z ) / 2
*
* where z = x / sqrt ( 2 ) . Computation is via the functions
* erf and erfc with care to avoid error amplification in computing exp ( - x ^ 2 ) .
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* IEEE - 13 , 0 50000 7 . 7 e - 34 1 . 7 e - 34
* IEEE - 106 . 5 , - 2 50000 6 . 1 e - 34 1 . 9 e - 34
* IEEE 0 , 3 50000 1 . 5 e - 34 3 . 9 e - 35
*
*
* ERROR MESSAGES :
*
* message condition value returned
* erfcl underflow x ^ 2 / 2 > MAXLOGL 0 . 0
*
*/
/* ndtrll.c
*
* Error function
*
*
*
* SYNOPSIS :
*
* long double x , y , erfl ( ) ;
*
* y = erfl ( x ) ;
*
*
*
* DESCRIPTION :
*
* The integral is
*
* x
* -
* 2 | | 2
* erf ( x ) = - - - - - - - - | exp ( - t ) dt .
* sqrt ( pi ) | |
* -
* 0
*
* The magnitude of x is limited to about 106 . 56 for IEEE
* arithmetic ; 1 or - 1 is returned outside this range .
*
* For 0 < = | x | < 1 , erf ( x ) is computed by rational approximations ; otherwise
* erf ( x ) = 1 - erfc ( x ) .
*
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* IEEE 0 , 1 50000 1 . 5 e - 34 4 . 4 e - 35
*
*/
/* ndtrll.c
*
* Complementary error function
*
*
*
* SYNOPSIS :
*
* long double x , y , erfcl ( ) ;
*
* y = erfcl ( x ) ;
*
*
*
* DESCRIPTION :
*
*
* 1 - erf ( x ) =
*
* inf .
* -
* 2 | | 2
* erfc ( x ) = - - - - - - - - | exp ( - t ) dt
* sqrt ( pi ) | |
* -
* x
*
*
* For small x , erfc ( x ) = 1 - erf ( x ) ; otherwise rational
* approximations are computed .
*
* A special function expx2l . c is used to suppress error amplification
* in computing exp ( - x ^ 2 ) .
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* IEEE 0 , 13 100000 5 . 8 e - 34 1 . 5 e - 34
* IEEE 6 , 106 . 56 100000 5 . 9 e - 34 1 . 5 e - 34
*
*
* ERROR MESSAGES :
*
* message condition value returned
* erfcl underflow x ^ 2 > MAXLOGL 0 . 0
*
*
*/
/*
Cephes Math Library Release 2 . 9 : September , 2001
Copyright 1984 , 1995 , 2001 by Stephen L . Moshier
*/
#include "mconf.h"
extern long double MAXLOGL;
static long double SQRTHL = 7 .0710678118654752440084436210484903928484 E-1 L;
/* erfc(x + 0.25) = erfc(0.25) + x R(x)
0 < = x < 0 . 125
Peak relative error 1.4e-35 */
#define NRNr13 8
static long double RNr13[NRNr13 + 1 ] =
{
-2 .353707097641280550282633036456457014829 E3L,
3 .871159656228743599994116143079870279866 E2L,
-3 .888105134258266192210485617504098426679 E2L,
-2 .129998539120061668038806696199343094971 E1L,
-8 .125462263594034672468446317145384108734 E1L,
8 .151549093983505810118308635926270319660 E0L,
-5 .033362032729207310462422357772568553670 E0L,
-4 .253956621135136090295893547735851168471 E-2 L,
-8 .098602878463854789780108161581050357814 E-2 L
};
#define NRDr13 7
static long double RDr13[NRDr13 + 1 ] =
{
2 .220448796306693503549505450626652881752 E3L,
1 .899133258779578688791041599040951431383 E2L,
1 .061906712284961110196427571557149268454 E3L,
7 .497086072306967965180978101974566760042 E1L,
2 .146796115662672795876463568170441327274 E2L,
1 .120156008362573736664338015952284925592 E1L,
2 .211014952075052616409845051695042741074 E1L,
6 .469655675326150785692908453094054988938 E-1 L
/* 1.0E0 */
};
/* erfc(0.25) = C13a + C13b to extra precision. */
static long double C13a = 0 .723663330078125 L;
static long double C13b = 1 .0279753638067014931732235184287934646022 E-5 L;
/* erfc(x + 0.375) = erfc(0.375) + x R(x)
0 < = x < 0 . 125
Peak relative error 1.2e-35 */
#define NRNr14 8
static long double RNr14[NRNr14 + 1 ] =
{
-2 .446164016404426277577283038988918202456 E3L,
6 .718753324496563913392217011618096698140 E2L,
-4 .581631138049836157425391886957389240794 E2L,
-2 .382844088987092233033215402335026078208 E1L,
-7 .119237852400600507927038680970936336458 E1L,
1 .313609646108420136332418282286454287146 E1L,
-6 .188608702082264389155862490056401365834 E0L,
-2 .787116601106678287277373011101132659279 E-2 L,
-2 .230395570574153963203348263549700967918 E-2 L
};
#define NRDr14 7
static long double RDr14[NRDr14 + 1 ] =
{
2 .495187439241869732696223349840963702875 E3L,
2 .503549449872925580011284635695738412162 E2L,
1 .159033560988895481698051531263861842461 E3L,
9 .493751466542304491261487998684383688622 E1L,
2 .276214929562354328261422263078480321204 E2L,
1 .367697521219069280358984081407807931847 E1L,
2 .276988395995528495055594829206582732682 E1L,
7 .647745753648996559837591812375456641163 E-1 L
/* 1.0E0 */
};
/* erfc(0.375) = C14a + C14b to extra precision. */
static long double C14a = 0 .5958709716796875 L;
static long double C14b = 1 .2118885490201676174914080878232469565953 E-5 L;
/* erfc(x + 0.5) = erfc(0.5) + x R(x)
0 < = x < 0 . 125
Peak relative error 4.7e-36 */
#define NRNr15 8
static long double RNr15[NRNr15 + 1 ] =
{
-2 .624212418011181487924855581955853461925 E3L,
8 .473828904647825181073831556439301342756 E2L,
-5 .286207458628380765099405359607331669027 E2L,
-3 .895781234155315729088407259045269652318 E1L,
-6 .200857908065163618041240848728398496256 E1L,
1 .469324610346924001393137895116129204737 E1L,
-6 .961356525370658572800674953305625578903 E0L,
5 .145724386641163809595512876629030548495 E-3 L,
1 .990253655948179713415957791776180406812 E-2 L
};
#define NRDr15 7
static long double RDr15[NRDr15 + 1 ] =
{
2 .986190760847974943034021764693341524962 E3L,
5 .288262758961073066335410218650047725985 E2L,
1 .363649178071006978355113026427856008978 E3L,
1 .921707975649915894241864988942255320833 E2L,
2 .588651100651029023069013885900085533226 E2L,
2 .628752920321455606558942309396855629459 E1L,
2 .455649035885114308978333741080991380610 E1L,
1 .378826653595128464383127836412100939126 E0L
/* 1.0E0 */
};
/* erfc(0.5) = C15a + C15b to extra precision. */
static long double C15a = 0 .4794921875 L;
static long double C15b = 7 .9346869534623172533461080354712635484242 E-6 L;
/* erfc(x + 0.625) = erfc(0.625) + x R(x)
0 < = x < 0 . 125
Peak relative error 5.1e-36 */
#define NRNr16 8
static long double RNr16[NRNr16 + 1 ] =
{
-2 .347887943200680563784690094002722906820 E3L,
8 .008590660692105004780722726421020136482 E2L,
-5 .257363310384119728760181252132311447963 E2L,
-4 .471737717857801230450290232600243795637 E1L,
-4 .849540386452573306708795324759300320304 E1L,
1 .140885264677134679275986782978655952843 E1L,
-6 .731591085460269447926746876983786152300 E0L,
1 .370831653033047440345050025876085121231 E-1 L,
2 .022958279982138755020825717073966576670 E-2 L,
};
#define NRDr16 7
static long double RDr16[NRDr16 + 1 ] =
{
3 .075166170024837215399323264868308087281 E3L,
8 .730468942160798031608053127270430036627 E2L,
1 .458472799166340479742581949088453244767 E3L,
3 .230423687568019709453130785873540386217 E2L,
2 .804009872719893612081109617983169474655 E2L,
4 .465334221323222943418085830026979293091 E1L,
2 .612723259683205928103787842214809134746 E1L,
2 .341526751185244109722204018543276124997 E0L,
/* 1.0E0 */
};
/* erfc(0.625) = C16a + C16b to extra precision. */
static long double C16a = 0 .3767547607421875 L;
static long double C16b = 4 .3570693945275513594941232097252997287766 E-6 L;
/* erfc(x + 0.75) = erfc(0.75) + x R(x)
0 < = x < 0 . 125
Peak relative error 1.7e-35 */
#define NRNr17 8
static long double RNr17[NRNr17 + 1 ] =
{
-1 .767068734220277728233364375724380366826 E3L,
6 .693746645665242832426891888805363898707 E2L,
-4 .746224241837275958126060307406616817753 E2L,
-2 .274160637728782675145666064841883803196 E1L,
-3 .541232266140939050094370552538987982637 E1L,
6 .988950514747052676394491563585179503865 E0L,
-5 .807687216836540830881352383529281215100 E0L,
3 .631915988567346438830283503729569443642 E-1 L,
-1 .488945487149634820537348176770282391202 E-2 L
};
#define NRDr17 7
static long double RDr17[NRDr17 + 1 ] =
{
2 .748457523498150741964464942246913394647 E3L,
1 .020213390713477686776037331757871252652 E3L,
1 .388857635935432621972601695296561952738 E3L,
3 .903363681143817750895999579637315491087 E2L,
2 .784568344378139499217928969529219886578 E2L,
5 .555800830216764702779238020065345401144 E1L,
2 .646215470959050279430447295801291168941 E1L,
2 .984905282103517497081766758550112011265 E0L,
/* 1.0E0 */
};
/* erfc(0.75) = C17a + C17b to extra precision. */
static long double C17a = 0 .2888336181640625 L;
static long double C17b = 1 .0748182422368401062165408589222625794046 E-5 L;
/* erfc(x + 0.875) = erfc(0.875) + x R(x)
0 < = x < 0 . 125
Peak relative error 2.2e-35 */
#define NRNr18 8
static long double RNr18[NRNr18 + 1 ] =
{
-1 .342044899087593397419622771847219619588 E3L,
6 .127221294229172997509252330961641850598 E2L,
-4 .519821356522291185621206350470820610727 E2L,
1 .223275177825128732497510264197915160235 E1L,
-2 .730789571382971355625020710543532867692 E1L,
4 .045181204921538886880171727755445395862 E0L,
-4 .925146477876592723401384464691452700539 E0L,
5 .933878036611279244654299924101068088582 E-1 L,
-5 .557645435858916025452563379795159124753 E-2 L
};
#define NRDr18 7
static long double RDr18[NRDr18 + 1 ] =
{
2 .557518000661700588758505116291983092951 E3L,
1 .070171433382888994954602511991940418588 E3L,
1 .344842834423493081054489613250688918709 E3L,
4 .161144478449381901208660598266288188426 E2L,
2 .763670252219855198052378138756906980422 E2L,
5 .998153487868943708236273854747564557632 E1L,
2 .657695108438628847733050476209037025318 E1L,
3 .252140524394421868923289114410336976512 E0L,
/* 1.0E0 */
};
/* erfc(0.875) = C18a + C18b to extra precision. */
static long double C18a = 0 .215911865234375 L;
static long double C18b = 1 .3073705765341685464282101150637224028267 E-5 L;
/* erfc(x + 1.0) = erfc(1.0) + x R(x)
0 < = x < 0 . 125
Peak relative error 1.6e-35 */
#define NRNr19 8
static long double RNr19[NRNr19 + 1 ] =
{
-1 .139180936454157193495882956565663294826 E3L,
6 .134903129086899737514712477207945973616 E2L,
-4 .628909024715329562325555164720732868263 E2L,
4 .165702387210732352564932347500364010833 E1L,
-2 .286979913515229747204101330405771801610 E1L,
1 .870695256449872743066783202326943667722 E0L,
-4 .177486601273105752879868187237000032364 E0L,
7 .533980372789646140112424811291782526263 E-1 L,
-8 .629945436917752003058064731308767664446 E-2 L
};
#define NRDr19 7
static long double RDr19[NRDr19 + 1 ] =
{
2 .744303447981132701432716278363418643778 E3L,
1 .266396359526187065222528050591302171471 E3L,
1 .466739461422073351497972255511919814273 E3L,
4 .868710570759693955597496520298058147162 E2L,
2 .993694301559756046478189634131722579643 E2L,
6 .868976819510254139741559102693828237440 E1L,
2 .801505816247677193480190483913753613630 E1L,
3 .604439909194350263552750347742663954481 E0L,
/* 1.0E0 */
};
/* erfc(1.0) = C19a + C19b to extra precision. */
static long double C19a = 0 .15728759765625 L;
static long double C19b = 1 .1609394035130658779364917390740703933002 E-5 L;
/* erfc(x + 1.125) = erfc(1.125) + x R(x)
0 < = x < 0 . 125
Peak relative error 3.6e-36 */
#define NRNr20 8
static long double RNr20[NRNr20 + 1 ] =
{
-9 .652706916457973956366721379612508047640 E2L,
5 .577066396050932776683469951773643880634 E2L,
-4 .406335508848496713572223098693575485978 E2L,
5 .202893466490242733570232680736966655434 E1L,
-1 .931311847665757913322495948705563937159 E1L,
-9 .364318268748287664267341457164918090611 E-2 L,
-3 .306390351286352764891355375882586201069 E0L,
7 .573806045289044647727613003096916516475 E-1 L,
-9 .611744011489092894027478899545635991213 E-2 L
};
#define NRDr20 7
static long double RDr20[NRDr20 + 1 ] =
{
3 .032829629520142564106649167182428189014 E3L,
1 .659648470721967719961167083684972196891 E3L,
1 .703545128657284619402511356932569292535 E3L,
6 .393465677731598872500200253155257708763 E2L,
3 .489131397281030947405287112726059221934 E2L,
8 .848641738570783406484348434387611713070 E1L,
3 .132269062552392974833215844236160958502 E1L,
4 .430131663290563523933419966185230513168 E0L
/* 1.0E0 */
};
/* erfc(1.125) = C20a + C20b to extra precision. */
static long double C20a = 0 .111602783203125 L;
static long double C20b = 8 .9850951672359304215530728365232161564636 E-6 L;
/* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2)
7 / 8 < = 1 / x < 1
Peak relative error 1.4e-35 */
#define NRNr8 9
static long double RNr8[NRNr8 + 1 ] =
{
3 .587451489255356250759834295199296936784 E1L,
5 .406249749087340431871378009874875889602 E2L,
2 .931301290625250886238822286506381194157 E3L,
7 .359254185241795584113047248898753470923 E3L,
9 .201031849810636104112101947312492532314 E3L,
5 .749697096193191467751650366613289284777 E3L,
1 .710415234419860825710780802678697889231 E3L,
2 .150753982543378580859546706243022719599 E2L,
8 .740953582272147335100537849981160931197 E0L,
4 .876422978828717219629814794707963640913 E-2 L
};
#define NRDr8 8
static long double RDr8[NRDr8 + 1 ] =
{
6 .358593134096908350929496535931630140282 E1L,
9 .900253816552450073757174323424051765523 E2L,
5 .642928777856801020545245437089490805186 E3L,
1 .524195375199570868195152698617273739609 E4L,
2 .113829644500006749947332935305800887345 E4L,
1 .526438562626465706267943737310282977138 E4L,
5 .561370922149241457131421914140039411782 E3L,
9 .394035530179705051609070428036834496942 E2L,
6 .147019596150394577984175188032707343615 E1L
/* 1.0E0 */
};
/* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2)
3 / 4 < = 1 / x < 7 / 8
Peak relative error 1.7e-36 */
#define NRNr7 9
static long double RNr7[NRNr7 + 1 ] =
{
1 .293515364043117601705535485785956592493 E2L,
2 .474534371269189867053251150063459055230 E3L,
1 .756537563959875738809491329250457486510 E4L,
5 .977479535376639763773153344676726091607 E4L,
1 .054313816139671870123172936972055385049 E5L,
9 .754699773487726957401038094714603033904 E4L,
4 .579131242577671038339922925213209214880 E4L,
1 .000710322164510887997115157797717324370 E4L,
8 .496863250712471449526805271633794700452 E2L,
1 .797349831386892396933210199236530557333 E1L
};
#define NRDr7 9
static long double RDr7[NRDr7 + 1 ] =
{
2 .292696320307033494820399866075534515002 E2L,
4 .500632608295626968062258401895610053116 E3L,
3 .321218723485498111535866988511716659339 E4L,
1 .196084512221845156596781258490840961462 E5L,
2 .287033883912529843927983406878910939930 E5L,
2 .370223495794642027268482075021298394425 E5L,
1 .305173734022437154610938308944995159199 E5L,
3 .589386258485887630236490009835928559621 E4L,
4 .339996864041074149726360516336773136101 E3L,
1 .753135522665469574605384979152863899099 E2L
/* 1.0E0 */
};
/* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2)
5 / 8 < = 1 / x < 3 / 4
Peak relative error 1.6e-35 */
#define NRNr6 9
static long double RNr6[NRNr6 + 1 ] =
{
1 .423313561367394923305025174137639124533 E1L,
3 .244462503273003837514629113846075327206 E2L,
2 .784937282403293364911673341412846781934 E3L,
1 .163060685810874867196849890286455473382 E4L,
2 .554141394931962276102205517358731053756 E4L,
2 .982733782500729530503336931258698708782 E4L,
1 .789683564523810605328169719436374742840 E4L,
5 .056032142227470121262177112822018882754 E3L,
5 .605349942234782054561269306895707034586 E2L,
1 .561652599080729507274832243665726064881 E1L
};
#define NRDr6 9
static long double RDr6[NRDr6 + 1 ] =
{
2 .522757606611479946069351519410222913326 E1L,
5 .876797910931896554014229647006604017806 E2L,
5 .211092128250480712011248211246144751074 E3L,
2 .282679910855404599271496827409168580797 E4L,
5 .371245819205596609986320599133109262447 E4L,
6 .926186102106400355114925675028888924445 E4L,
4 .794366033363621432575096487724913414473 E4L,
1 .673190682734065914573814938835674963896 E4L,
2 .589544846151313120096957014256536236242 E3L,
1 .349438432583208276883323156200117027433 E2L
/* 1.000000000000000000000000000000000000000E0 */
};
/* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2)
1 / 2 < = 1 / x < 5 / 8
Peak relative error 4.3e-36 */
#define NRNr5 10
static long double RNr5[NRNr5 + 1 ] =
{
6 .743447478279267339131211137241149796763 E-2 L,
2 .031339015932962998168472743355874796350 E0L,
2 .369234815713196480221800940201367484379 E1L,
1 .387819614016107433603101545594790875922 E2L,
4 .435600256936515839937720907171966121786 E2L,
7 .881577949936817507981170892417739733047 E2L,
7 .615749099291545976179905281851765734680 E2L,
3 .752484528663442467089606663006771157777 E2L,
8 .279644286027145214308303292537009564726 E1L,
6 .201462983413738162709722770960040042647 E0L,
6 .649631608720062333043506249503378282697 E-2 L
};
#define NRDr5 9
static long double RDr5[NRDr5 + 1 ] =
{
1 .195244945161889822018178270706903972343 E-1 L,
3 .660216908153253021384862427197665991311 E0L,
4 .373405883243078019655721779021995159854 E1L,
2 .653305963056235008916733402786877121865 E2L,
8 .921329790491152046318422124415895506335 E2L,
1 .705552231555600759729260640562363304312 E3L,
1 .832711109606893446763174603477244625325 E3L,
1 .056823953275835649973998168744261083316 E3L,
2 .975561981792909722126456997074344895584 E2L,
3 .393149095158232521894537008472203487436 E1L
/* 1.0E0 */
};
/* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2)
3 / 8 < = 1 / x < 1 / 2
Peak relative error 1.8e-36 */
#define NRNr4 10
static long double RNr4[NRNr4 + 1 ] =
{
3 .558685919236420073872459554885612994007 E-2 L,
1 .460223642496950651561817195253277924528 E0L,
2 .379856746555189546876720308841066577268 E1L,
2 .005205521246554860334064698817220160117 E2L,
9 .533374928664989955629120027419490517596 E2L,
2 .623024576994438336130421711314560425373 E3L,
4 .126446434603735586340585027628851620886 E3L,
3 .540675861596687801829655387867654030013 E3L,
1 .506037084891064572653273761987617394259 E3L,
2 .630715699182706745867272452228891752353 E2L,
1 .202476629652900619635409242749750364878 E1L
};
#define NRDr4 10
static long double RDr4[NRDr4 + 1 ] =
{
6 .307606561714590590399683184410336583739 E-2 L,
2 .619717051134271249293056836082721776665 E0L,
4 .344441402681725017630451522968410844608 E1L,
3 .752891116408399440953195184301023399176 E2L,
1 .849305988804654653921972804388006355502 E3L,
5 .358505261991675891835885654499883449403 E3L,
9 .091890995405251314631428721090705475825 E3L,
8 .731418313949291797856351745278287516416 E3L,
4 .420211285043270337492325400764271868740 E3L,
1 .031487363021856106882306509107923200832 E3L,
8 .387036084846046121805145056040429461783 E1L
/* 1.0E0 */
};
/* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2)
1 / 4 < = 1 / x < 3 / 8
Peak relative error 8.1e-37 */
#define NRNr3 11
static long double RNr3[NRNr3 + 1 ] =
{
4 .584481542956275354582319313040418316755 E-5 L,
2 .674923158288848442110883948437930349128 E-3 L,
6 .344232532055212248017211243740466847311 E-2 L,
7 .985145965992002744933550450451513513963 E-1 L,
5 .845078061888281665064746347663123946270 E0L,
2 .566625318816866587482759497608029522596 E1L,
6 .736225182343446605268837827950856640948 E1L,
1 .021796460139598089409347761712730512053 E2L,
8 .344336615515430530929955615400706619764 E1L,
3 .207749011528249356283897356277376306967 E1L,
4 .386185123863412086856423971695142026036 E0L,
8 .971576448581208351826868348023528863856 E-2 L
};
#define NRDr3 10
static long double RDr3[NRDr3 + 1 ] =
{
8 .125781965218112303281657065320409661370 E-5 L,
4 .781806762611504685247817818428945295520 E-3 L,
1 .147785538413798317790357996845767614561 E-1 L,
1 .469285552007088106614218996464752307606 E0L,
1 .101712261349880339221039938999124077650 E1L,
5 .008507527095093413713171655268276861071 E1L,
1 .383058691613468970486425146336829447433 E2L,
2 .264114250278912520501010108736339599752 E2L,
2 .081377197698598680576330179979996940039 E2L,
9 .724438129690013609440151781601781137944 E1L,
1 .907905050771832372089975877589291760121 E1L
/* 1.0E0 */
};
/* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2)
1 / 8 < = 1 / x < 1 / 4
Peak relative error 1.5e-36 */
#define NRNr2 11
static long double RNr2[NRNr2 + 1 ] =
{
6 .928615158005256885698045840589513728399 E-7 L,
5 .616245938942075826026382337922413007879 E-5 L,
1 .871624980715261794832358438894219696113 E-3 L,
3 .349922063795792371642023765253747563009 E-2 L,
3 .531865233974349943956345502463135695834 E-1 L,
2 .264714157625072773976468825160906342360 E0L,
8 .810720294489253776747319730638214883026 E0L,
2 .014056685571655833019183248931442888437 E1L,
2 .524586947657190747039554310814128743320 E1L,
1 .520656940937208886246188940244581671609 E1L,
3 .334145500790963675035841482334493680498 E0L,
1 .122108380007109245896534245151140632457 E-1 L
};
#define NRDr2 10
static long double RDr2[NRDr2 + 1 ] =
{
1 .228065061824874795984937092427781089256 E-6 L,
1 .001593999520159167559129042893802235969 E-4 L,
3 .366527555699367241421450749821030974446 E-3 L,
6 .098626947195865254152265585991861150369 E-2 L,
6 .541547922508613985813189387198804660235 E-1 L,
4 .301130233305371976727117480925676583204 E0L,
1 .737155892350891711527711121692994762909 E1L,
4 .206892112110558214680649401236873828801 E1L,
5 .787487996025016843403524261574779631219 E1L,
4 .094047148590822715163181507813774861621 E1L,
1 .230603930056944875836549716515643997094 E1L
/* 1.0E0 */
};
/* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2)
1 / 128 < = 1 / x < 1 / 8
Peak relative error 2.2e-36 */
#define NRNr1 9
static long double RNr1[NRNr1 + 1 ] =
{
1 .293111801138199795250035229383033322539 E-6 L,
9 .785224720880980456171438759161161816706 E-5 L,
2 .932474396233212166056331430621176065943 E-3 L,
4 .496429595719847083917435337780697436921 E-2 L,
3 .805989855927720844877478869846718877846 E-1 L,
1 .789745532222426292126781724570152590071 E0L,
4 .465737379634389318903237306594171764628 E0L,
5 .268535822258082278401240171488850433767 E0L,
2 .258357766807433839494276681092713991651 E0L,
1 .504459334078750002966538036652860809497 E-1 L
};
#define NRDr1 8
static long double RDr1[NRDr1 + 1 ] =
{
2 .291980991578770070179177302906728371406 E-6 L,
1 .745845828808028552029674694534934620384 E-4 L,
5 .283248841982102317072923869576785278019 E-3 L,
8 .221212297078141470944454807434634848018 E-2 L,
7 .120500674861902950423510939060230945621 E-1 L,
3 .475435367560809622183983439133664598155 E0L,
9 .243253391989233533874386043611304387113 E0L,
1 .227894792475280941511758877318903197188 E1L,
6 .789361410398841316638617624392719077724 E0L
/* 1.0E0 */
};
/* erf(z+1) = erf_const + P(z)/Q(z)
- . 125 < = z < = 0
Peak relative error 7.3e-36 */
static long double erf_const = 0 .845062911510467529296875 L;
#define NTN2 8
static long double TN2[NTN2 + 1 ] =
{
-4 .088889697077485301010486931817357000235 E1L,
7 .157046430681808553842307502826960051036 E3L,
-2 .191561912574409865550015485451373731780 E3L,
2 .180174916555316874988981177654057337219 E3L,
2 .848578658049670668231333682379720943455 E2L,
1 .630362490952512836762810462174798925274 E2L,
6 .317712353961866974143739396865293596895 E0L,
2 .450441034183492434655586496522857578066 E1L,
5 .127662277706787664956025545897050896203 E-1 L
};
#define NTD2 8
static long double TD2[NTD2 + 1 ] =
{
1 .731026445926834008273768924015161048885 E4L,
1 .209682239007990370796112604286048173750 E4L,
1 .160950290217993641320602282462976163857 E4L,
5 .394294645127126577825507169061355698157 E3L,
2 .791239340533632669442158497532521776093 E3L,
8 .989365571337319032943005387378993827684 E2L,
2 .974016493766349409725385710897298069677 E2L,
6 .148192754590376378740261072533527271947 E1L,
1 .178502892490738445655468927408440847480 E1L
/* 1.0E0 */
};
/* erf(x) = x + x P(x^2)/Q(x^2)
0 < = x < = 7 / 8
Peak relative error 1.8e-35 */
#define NTN1 8
static long double TN1[NTN1 + 1 ] =
{
-3 .858252324254637124543172907442106422373 E10L,
9 .580319248590464682316366876952214879858 E10L,
1 .302170519734879977595901236693040544854 E10L,
2 .922956950426397417800321486727032845006 E9L,
1 .764317520783319397868923218385468729799 E8L,
1 .573436014601118630105796794840834145120 E7L,
4 .028077380105721388745632295157816229289 E5L,
1 .644056806467289066852135096352853491530 E4L,
3 .390868480059991640235675479463287886081 E1L
};
#define NTD1 8
static long double TD1[NTD1 + 1 ] =
{
-3 .005357030696532927149885530689529032152 E11L,
-1 .342602283126282827411658673839982164042 E11L,
-2 .777153893355340961288511024443668743399 E10L,
-3 .483826391033531996955620074072768276974 E9L,
-2 .906321047071299585682722511260895227921 E8L,
-1 .653347985722154162439387878512427542691 E7L,
-6 .245520581562848778466500301865173123136 E5L,
-1 .402124304177498828590239373389110545142 E4L,
-1 .209368072473510674493129989468348633579 E2L
/* 1.000000000000000000000000000000000000000E0 */
};
#ifdef ANSIPROT
extern long double polevll ( long double , void *, int );
extern long double p1evll ( long double , void *, int );
extern long double expl ( long double );
extern long double logl ( long double );
extern long double erfl ( long double );
extern long double erfcl ( long double );
extern long double fabsl ( long double );
extern long double expx2l ( long double , int );
extern long double sqrtl (long double );
static long double erfcel (long double );
#else
long double polevll(), p1evll(), expl(), logl(), erfl(), erfcl(), fabsl();
long double expx2l(), sqrtl();
static long double erfcel();
#endif
#ifdef INFINITIES
extern long double INFINITYL;
#endif
/* Evaluate P[n] x^n + P[n-1] x^(n-1) + ... + P[0] */
static long double
neval (long double x, long double *p, int n)
{
long double y;
p += n;
y = *p--;
do
{
y = y * x + *p--;
}
while (--n > 0 );
return y;
}
/* Evaluate x^n+1 + P[n] x^(n) + P[n-1] x^(n-1) + ... + P[0] */
static long double
deval (long double x, long double *p, int n)
{
long double y;
p += n;
y = x + *p--;
do
{
y = y * x + *p--;
}
while (--n > 0 );
return y;
}
/* Gaussian distribution function. */
long double ndtrl(a)
long double a;
{
long double x, y, z;
x = a * SQRTHL;
z = fabsl(x);
if ( z < 0 .25 )
y = 0 .5 L + 0 .5 L * erfl(x);
else if (z < 1 .25 )
{
y = 0 .5 L * erfcl(z);
if (x > 0 )
y = 1 .0 L - y;
}
else
{
/* See below for erfcel. */
y = 0 .5 L * erfcel(z);
/* Multiply by exp(-x^2 / 2) */
z = expx2l(a, -1 );
y = y * sqrtl(z);
if ( x > 0 .0 L )
y = 1 .0 L - y;
}
return (y);
}
long double erfcl(a)
long double a;
{
long double x, y, z;
int i;
#ifdef INFINITIES
if ( a == INFINITYL )
return (0 .0 L);
if ( a == -INFINITYL )
return (2 .0 L);
#endif
if ( a < 0 .0 L )
x = -a;
else
x = a;
if ( x < 0 .25 L )
return ( 1 .0 L - erfl(a) );
if (x < 1 .25 L)
{
i = 8 .0 * x;
switch (i)
{
case 2 :
z = x - 0 .25 L;
y = C13b + z * neval (z, RNr13, NRNr13) / deval (z, RDr13, NRDr13);
y += C13a;
break ;
case 3 :
z = x - 0 .375 L;
y = C14b + z * neval (z, RNr14, NRNr14) / deval (z, RDr14, NRDr14);
y += C14a;
break ;
case 4 :
z = x - 0 .5 L;
y = C15b + z * neval (z, RNr15, NRNr15) / deval (z, RDr15, NRDr15);
y += C15a;
break ;
case 5 :
z = x - 0 .625 L;
y = C16b + z * neval (z, RNr16, NRNr16) / deval (z, RDr16, NRDr16);
y += C16a;
break ;
case 6 :
z = x - 0 .75 L;
y = C17b + z * neval (z, RNr17, NRNr17) / deval (z, RDr17, NRDr17);
y += C17a;
break ;
case 7 :
z = x - 0 .875 L;
y = C18b + z * neval (z, RNr18, NRNr18) / deval (z, RDr18, NRDr18);
y += C18a;
break ;
case 8 :
z = x - 1 .0 L;
y = C19b + z * neval (z, RNr19, NRNr19) / deval (z, RDr19, NRDr19);
y += C19a;
break ;
case 9 :
z = x - 1 .125 L;
y = C20b + z * neval (z, RNr20, NRNr20) / deval (z, RDr20, NRDr20);
y += C20a;
break ;
}
if ( a < 0 .0 L )
y = 2 .0 L - y;
return y;
}
z = -a * a;
if ( z < -MAXLOGL )
{
under:
mtherr( "erfcl" , UNDERFLOW );
if ( a < 0 )
return ( 2 .0 L );
else
return ( 0 .0 L );
}
y = expx2l(a, -1 ) * erfcel (x);
if ( a < 0 .0 L )
y = 2 .0 L - y;
if ( y == 0 .0 L )
goto under;
return y;
}
/* Exponentially scaled erfc valid for x >= 0 */
long double erfcel(x)
long double x;
{
long double p,y,z;
int i;
/* Compute z = expl(z). */
z = 1 .0 L/(x*x);
i = 8 .0 / x;
switch (i)
{
default :
case 0 :
p = neval (z, RNr1, NRNr1) / deval (z, RDr1, NRDr1);
break ;
case 1 :
p = neval (z, RNr2, NRNr2) / deval (z, RDr2, NRDr2);
break ;
case 2 :
p = neval (z, RNr3, NRNr3) / deval (z, RDr3, NRDr3);
break ;
case 3 :
p = neval (z, RNr4, NRNr4) / deval (z, RDr4, NRDr4);
break ;
case 4 :
p = neval (z, RNr5, NRNr5) / deval (z, RDr5, NRDr5);
break ;
case 5 :
p = neval (z, RNr6, NRNr6) / deval (z, RDr6, NRDr6);
break ;
case 6 :
p = neval (z, RNr7, NRNr7) / deval (z, RDr7, NRDr7);
break ;
case 7 :
p = neval (z, RNr8, NRNr8) / deval (z, RDr8, NRDr8);
break ;
}
y = p / x;
return (y);
}
long double erfl(x)
long double x;
{
long double a, y, z;
#if MINUSZERO
if ( x == 0 .0 L )
return (x);
#endif
#ifdef INFINITIES
if ( x == -INFINITYL )
return (-1 .0 L);
if ( x == INFINITYL )
return (1 .0 L);
#endif
a = fabsl(x);
if ( a > 1 .0 L )
return ( 1 .0 L - erfcl(x) );
z = x * x;
if (a < 0 .875 )
{
y = a + a * neval (z, TN1, NTN1) / deval (z, TD1, NTD1);
}
else
{
a = a - 1 .0 L;
y = erf_const + neval (a, TN2, NTN2) / deval (a, TD2, NTD2);
}
if (x < 0 )
y = -y;
return ( y );
}
Messung V0.5 in Prozent C=95 H=98 G=96
¤ Dauer der Verarbeitung: 0.20 Sekunden
(vorverarbeitet am 2026-06-23)
¤
*© Formatika GbR, Deutschland