\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.5
\mathsf{fma}\left(\left(0.16666666666666666 \cdot \sqrt{-\log u1}\right) \cdot \sqrt{2}, \cos \log \left(e^{\left(2 \cdot \pi\right) \cdot u2}\right), 0.5\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 (fma (* (* 0.16666666666666666 (sqrt (- (log u1)))) (sqrt 2.0)) (cos (log (exp (* (* 2.0 PI) u2)))) 0.5))
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 fma(((0.16666666666666666 * sqrt(-log(u1))) * sqrt(2.0)), cos(log(exp((2.0 * ((double) M_PI)) * u2))), 0.5);
}



Bits error versus u1



Bits error versus u2
Initial program 0.4
Simplified0.4
Taylor expanded in u1 around inf 0.3
Simplified0.3
Applied associate-*r*_binary640.3
Applied add-log-exp_binary640.3
Final simplification0.3
herbie shell --seed 2022067
(FPCore (u1 u2)
:name "normal distribution"
:precision binary64
:pre (and (and (<= 0.0 u1) (<= u1 1.0)) (and (<= 0.0 u2) (<= u2 1.0)))
(+ (* (* (/ 1.0 6.0) (pow (* -2.0 (log u1)) 0.5)) (cos (* (* 2.0 PI) u2))) 0.5))