Average Error: 0.4 → 0.3
Time: 1.7m
Precision: 64
\[\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\]
\[\frac{{\left(\log u1 \cdot -2\right)}^{0.5} \cdot \cos \left(u2 \cdot \left(2 \cdot \pi\right)\right)}{6} + 0.5\]

Error

Bits error versus u1

Bits error versus u2

Derivation

  1. Initial program 0.4

    \[\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\]
  2. Simplified0.4

    \[\leadsto \color{blue}{0.5 + \frac{\cos \left(u2 \cdot \left(2 \cdot \pi\right)\right)}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}}\]
  3. Using strategy rm
  4. Applied associate-*l/0.3

    \[\leadsto 0.5 + \color{blue}{\frac{\cos \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot {\left(-2 \cdot \log u1\right)}^{0.5}}{6}}\]
  5. Final simplification0.3

    \[\leadsto \frac{{\left(\log u1 \cdot -2\right)}^{0.5} \cdot \cos \left(u2 \cdot \left(2 \cdot \pi\right)\right)}{6} + 0.5\]

Reproduce

herbie shell --seed 2019100 
(FPCore (u1 u2)
  :name "normal distribution"
  :pre (and (<= 0 u1 1) (<= 0 u2 1))
  (+ (* (* (/ 1 6) (pow (* -2 (log u1)) 0.5)) (cos (* (* 2 PI) u2))) 0.5))