4 #define P10 242.66795523053175
5 #define P11 21.979261618294152
6 #define P12 6.9963834886191355
7 #define P13 -.035609843701815385
8 #define Q10 215.05887586986120
9 #define Q11 91.164905404514901
10 #define Q12 15.082797630407787
13 #define P20 300.4592610201616005
14 #define P21 451.9189537118729422
15 #define P22 339.3208167343436870
16 #define P23 152.9892850469404039
17 #define P24 43.16222722205673530
18 #define P25 7.211758250883093659
19 #define P26 .5641955174789739711
20 #define P27 -.0000001368648573827167067
21 #define Q20 300.4592609569832933
22 #define Q21 790.9509253278980272
23 #define Q22 931.3540948506096211
24 #define Q23 638.9802644656311665
25 #define Q24 277.5854447439876434
26 #define Q25 77.00015293522947295
27 #define Q26 12.78272731962942351
30 #define P30 -.00299610707703542174
31 #define P31 -.0494730910623250734
32 #define P32 -.226956593539686930
33 #define P33 -.278661308609647788
34 #define P34 -.0223192459734184686
35 #define Q30 .0106209230528467918
36 #define Q31 .191308926107829841
37 #define Q32 1.05167510706793207
38 #define Q33 1.98733201817135256
41 #define SQRT2 1.414213562373095049
42 #define SQRTPI 1.772453850905516027
45 normbase(double *x
, double *phi
)
48 double R1
, R2
, y
, y2
, y3
, y4
, y5
, y6
, y7
, erf
, erfc
, z
, z2
, z3
, z4
;
62 R1
= P10
+ P11
* y2
+ P12
* y4
+ P13
* y6
;
63 R2
= Q10
+ Q11
* y2
+ Q12
* y4
+ Q13
* y6
;
75 R1
= P20
+ P21
* y
+ P22
* y2
+ P23
* y3
+ P24
* y4
+ P25
* y5
+
77 R2
= Q20
+ Q21
* y
+ Q22
* y2
+ Q23
* y3
+ Q24
* y4
+ Q25
* y5
+
79 erfc
= exp(-y2
) * R1
/ R2
;
81 *phi
= 1.0 - (0.5 * erfc
);
90 R1
= P30
+ P31
* z
+ P32
* z2
+ P33
* z3
+ P34
* z4
;
91 R2
= Q30
+ Q31
* z
+ Q32
* z2
+ Q33
* z3
+ Q34
* z4
;
92 erfc
= (exp(-y2
)/y
) * (1.0 / SQRTPI
+ R1
/ (R2
* y2
));
94 *phi
= 1.0 - ( 0.5 * erfc
);