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

Error

Bits error versus u1

Bits error versus u2

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. Initial simplification0.4

    \[\leadsto 0.5 + \left({\left(-2 \cdot \log u1\right)}^{0.5} \cdot \frac{1}{6}\right) \cdot \cos \left(\left(\pi \cdot u2\right) \cdot 2\right)\]
  3. Using strategy rm
  4. Applied add-exp-log0.5

    \[\leadsto 0.5 + \color{blue}{e^{\log \left({\left(-2 \cdot \log u1\right)}^{0.5} \cdot \frac{1}{6}\right)}} \cdot \cos \left(\left(\pi \cdot u2\right) \cdot 2\right)\]
  5. Using strategy rm
  6. Applied rem-exp-log0.4

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

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

Runtime

Time bar (total: 30.0s)Debug logProfile

herbie shell --seed 2018346 
(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))