\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.50.5 + \cos \left(\sqrt{\left(2 \cdot \pi\right) \cdot u2} \cdot \sqrt{\left(2 \cdot \pi\right) \cdot u2}\right) \cdot \left(\sqrt{-\log u1} \cdot \left(0.16666666666666666 \cdot \sqrt{2}\right)\right)(FPCore (u1 u2) :precision binary64 (+ (* (* (/ 1.0 6.0) (pow (* -2.0 (log u1)) 0.5)) (cos (* (* 2.0 PI) u2))) 0.5))
(FPCore (u1 u2) :precision binary64 (+ 0.5 (* (cos (* (sqrt (* (* 2.0 PI) u2)) (sqrt (* (* 2.0 PI) u2)))) (* (sqrt (- (log u1))) (* 0.16666666666666666 (sqrt 2.0))))))
double code(double u1, double u2) {
return (((1.0 / 6.0) * pow((-2.0 * log(u1)), 0.5)) * cos((2.0 * ((double) M_PI)) * u2)) + 0.5;
}
double code(double u1, double u2) {
return 0.5 + (cos(sqrt((2.0 * ((double) M_PI)) * u2) * sqrt((2.0 * ((double) M_PI)) * u2)) * (sqrt(-log(u1)) * (0.16666666666666666 * sqrt(2.0))));
}







Bits error versus u1







Bits error versus u2
Results
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 20032 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 20032 |
| Alternative 3 | |
|---|---|
| Error | 1.0 |
| Cost | 13248 |
| Alternative 4 | |
|---|---|
| Error | 53.0 |
| Cost | 64 |


Initial program 0.4
rmApplied add-sqr-sqrt_binary640.4
rmApplied *-un-lft-identity_binary640.4
Taylor expanded around inf 0.3
Simplified0.3
rmApplied associate-*r*_binary640.3
Simplified0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2021045
(FPCore (u1 u2)
:name "normal distribution"
:precision binary64
:pre (and (<= 0.0 u1 1.0) (<= 0.0 u2 1.0))
(+ (* (* (/ 1.0 6.0) (pow (* -2.0 (log u1)) 0.5)) (cos (* (* 2.0 PI) u2))) 0.5))