normal distribution

Percentage Accurate: 99.4% → 99.6%
Time: 7.9s
Alternatives: 7
Speedup: 1.4×

Specification

?
\[\left(0 \leq u1 \land u1 \leq 1\right) \land \left(0 \leq u2 \land u2 \leq 1\right)\]
\[\begin{array}{l} \\ \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (+
  (* (* (/ 1.0 6.0) (pow (* -2.0 (log u1)) 0.5)) (cos (* (* 2.0 (PI)) u2)))
  0.5))
\begin{array}{l}

\\
\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (+
  (* (* (/ 1.0 6.0) (pow (* -2.0 (log u1)) 0.5)) (cos (* (* 2.0 (PI)) u2)))
  0.5))
\begin{array}{l}

\\
\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5
\end{array}

Alternative 1: 99.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\left(\sqrt{2} \cdot 0.16666666666666666\right) \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot -2\right), \sqrt{-\log u1}, 0.5\right) \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (fma
  (* (* (sqrt 2.0) 0.16666666666666666) (cos (* (* (PI) u2) -2.0)))
  (sqrt (- (log u1)))
  0.5))
\begin{array}{l}

\\
\mathsf{fma}\left(\left(\sqrt{2} \cdot 0.16666666666666666\right) \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot -2\right), \sqrt{-\log u1}, 0.5\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. pow-to-expN/A

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{e^{\log \left(-2 \cdot \log u1\right) \cdot \frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} \cdot e^{\color{blue}{\frac{1}{2} \cdot \log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. exp-prodN/A

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{\frac{1}{2}}\right)}^{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. lower-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{\frac{1}{2}}\right)}^{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. lower-exp.f64N/A

      \[\leadsto \left(\frac{1}{6} \cdot {\color{blue}{\left(e^{\frac{1}{2}}\right)}}^{\log \left(-2 \cdot \log u1\right)}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    7. lower-log.f6498.9

      \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{0.5}\right)}^{\color{blue}{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
    8. lift-*.f64N/A

      \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{\frac{1}{2}}\right)}^{\log \color{blue}{\left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    9. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{\frac{1}{2}}\right)}^{\log \color{blue}{\left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    10. lower-*.f6498.9

      \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{0.5}\right)}^{\log \color{blue}{\left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
  4. Applied rewrites98.9%

    \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{0.5}\right)}^{\log \left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
  5. Taylor expanded in u1 around inf

    \[\leadsto \color{blue}{\frac{1}{2} + \frac{1}{6} \cdot \left(\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}\right)} \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{1}{6} \cdot \left(\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}\right) + \frac{1}{2}} \]
    2. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}} + \frac{1}{2} \]
    3. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right), \sqrt{\log \left(\frac{1}{u1}\right)}, \frac{1}{2}\right)} \]
  7. Applied rewrites99.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot 0.16666666666666666\right) \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot -2\right), \sqrt{-\log u1}, 0.5\right)} \]
  8. Add Preprocessing

Alternative 2: 99.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\sqrt{2}, 0.16666666666666666 \cdot \left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot u2\right) \cdot \sqrt{-\log u1}\right), 0.5\right) \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (fma
  (sqrt 2.0)
  (* 0.16666666666666666 (* (cos (* (* (PI) 2.0) u2)) (sqrt (- (log u1)))))
  0.5))
\begin{array}{l}

\\
\mathsf{fma}\left(\sqrt{2}, 0.16666666666666666 \cdot \left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot u2\right) \cdot \sqrt{-\log u1}\right), 0.5\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. pow-to-expN/A

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{e^{\log \left(-2 \cdot \log u1\right) \cdot \frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} \cdot e^{\color{blue}{\frac{1}{2} \cdot \log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. exp-prodN/A

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{\frac{1}{2}}\right)}^{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. lower-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{\frac{1}{2}}\right)}^{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. lower-exp.f64N/A

      \[\leadsto \left(\frac{1}{6} \cdot {\color{blue}{\left(e^{\frac{1}{2}}\right)}}^{\log \left(-2 \cdot \log u1\right)}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    7. lower-log.f6498.9

      \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{0.5}\right)}^{\color{blue}{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
    8. lift-*.f64N/A

      \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{\frac{1}{2}}\right)}^{\log \color{blue}{\left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    9. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{\frac{1}{2}}\right)}^{\log \color{blue}{\left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    10. lower-*.f6498.9

      \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{0.5}\right)}^{\log \color{blue}{\left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
  4. Applied rewrites98.9%

    \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{0.5}\right)}^{\log \left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
  5. Taylor expanded in u1 around inf

    \[\leadsto \color{blue}{\frac{1}{2} + \frac{1}{6} \cdot \left(\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}\right)} \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{1}{6} \cdot \left(\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}\right) + \frac{1}{2}} \]
    2. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}} + \frac{1}{2} \]
    3. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right), \sqrt{\log \left(\frac{1}{u1}\right)}, \frac{1}{2}\right)} \]
  7. Applied rewrites99.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot 0.16666666666666666\right) \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot -2\right), \sqrt{-\log u1}, 0.5\right)} \]
  8. Step-by-step derivation
    1. Applied rewrites99.4%

      \[\leadsto \mathsf{fma}\left(\sqrt{2}, \color{blue}{0.16666666666666666 \cdot \left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot u2\right) \cdot \sqrt{-\log u1}\right)}, 0.5\right) \]
    2. Add Preprocessing

    Alternative 3: 99.4% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (* (cos (* u2 (* (PI) 2.0))) 0.16666666666666666)
      (sqrt (* (log u1) -2.0))
      0.5))
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      2. unpow1/2N/A

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      3. lower-sqrt.f6499.4

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      4. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      5. *-commutativeN/A

        \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      6. lower-*.f6499.4

        \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
    4. Applied rewrites99.4%

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2}} \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right)} + \frac{1}{2} \]
      4. lift-*.f64N/A

        \[\leadsto \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right)} + \frac{1}{2} \]
      5. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}\right) \cdot \sqrt{\log u1 \cdot -2}} + \frac{1}{2} \]
      6. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right)} \]
      7. lower-*.f6499.4

        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      8. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
      10. lower-*.f6499.4

        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      11. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
      13. lower-*.f6499.4

        \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      14. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot \color{blue}{\frac{1}{6}}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
      15. metadata-eval99.4

        \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot \color{blue}{0.16666666666666666}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
    6. Applied rewrites99.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right)} \]
    7. Add Preprocessing

    Alternative 4: 99.0% accurate, 2.2× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\sqrt{2} \cdot \mathsf{fma}\left(u2 \cdot u2, \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -0.3333333333333333, 0.16666666666666666\right), \sqrt{-\log u1}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (*
       (sqrt 2.0)
       (fma (* u2 u2) (* (* (PI) (PI)) -0.3333333333333333) 0.16666666666666666))
      (sqrt (- (log u1)))
      0.5))
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\sqrt{2} \cdot \mathsf{fma}\left(u2 \cdot u2, \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -0.3333333333333333, 0.16666666666666666\right), \sqrt{-\log u1}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      2. pow-to-expN/A

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{e^{\log \left(-2 \cdot \log u1\right) \cdot \frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \left(\frac{1}{6} \cdot e^{\color{blue}{\frac{1}{2} \cdot \log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      4. exp-prodN/A

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{\frac{1}{2}}\right)}^{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      5. lower-pow.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{\frac{1}{2}}\right)}^{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      6. lower-exp.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot {\color{blue}{\left(e^{\frac{1}{2}}\right)}}^{\log \left(-2 \cdot \log u1\right)}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      7. lower-log.f6498.9

        \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{0.5}\right)}^{\color{blue}{\log \left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      8. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{\frac{1}{2}}\right)}^{\log \color{blue}{\left(-2 \cdot \log u1\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      9. *-commutativeN/A

        \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{\frac{1}{2}}\right)}^{\log \color{blue}{\left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
      10. lower-*.f6498.9

        \[\leadsto \left(\frac{1}{6} \cdot {\left(e^{0.5}\right)}^{\log \color{blue}{\left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
    4. Applied rewrites98.9%

      \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(e^{0.5}\right)}^{\log \left(\log u1 \cdot -2\right)}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
    5. Taylor expanded in u1 around inf

      \[\leadsto \color{blue}{\frac{1}{2} + \frac{1}{6} \cdot \left(\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{1}{6} \cdot \left(\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}\right) + \frac{1}{2}} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)\right) \cdot \sqrt{\log \left(\frac{1}{u1}\right)}} + \frac{1}{2} \]
      3. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right), \sqrt{\log \left(\frac{1}{u1}\right)}, \frac{1}{2}\right)} \]
    7. Applied rewrites99.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot 0.16666666666666666\right) \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot -2\right), \sqrt{-\log u1}, 0.5\right)} \]
    8. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{fma}\left(\frac{-1}{3} \cdot \left({u2}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{2}\right)\right) + \frac{1}{6} \cdot \sqrt{2}, \sqrt{\color{blue}{-\log u1}}, \frac{1}{2}\right) \]
    9. Step-by-step derivation
      1. Applied rewrites98.3%

        \[\leadsto \mathsf{fma}\left(\sqrt{2} \cdot \mathsf{fma}\left(u2 \cdot u2, \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -0.3333333333333333, 0.16666666666666666\right), \sqrt{\color{blue}{-\log u1}}, 0.5\right) \]
      2. Add Preprocessing

      Alternative 5: 98.8% accurate, 2.3× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\left(-2 \cdot u2\right) \cdot u2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right) \end{array} \]
      (FPCore (u1 u2)
       :precision binary64
       (fma
        (* (fma (* (* -2.0 u2) u2) (* (PI) (PI)) 1.0) 0.16666666666666666)
        (sqrt (* (log u1) -2.0))
        0.5))
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(\mathsf{fma}\left(\left(-2 \cdot u2\right) \cdot u2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right)
      \end{array}
      
      Derivation
      1. Initial program 99.4%

        \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-pow.f64N/A

          \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
        2. unpow1/2N/A

          \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
        3. lower-sqrt.f6499.4

          \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
        4. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
        5. *-commutativeN/A

          \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
        6. lower-*.f6499.4

          \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      4. Applied rewrites99.4%

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      5. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2}} \]
        2. lift-*.f64N/A

          \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
        3. *-commutativeN/A

          \[\leadsto \color{blue}{\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right)} + \frac{1}{2} \]
        4. lift-*.f64N/A

          \[\leadsto \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right)} + \frac{1}{2} \]
        5. associate-*r*N/A

          \[\leadsto \color{blue}{\left(\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}\right) \cdot \sqrt{\log u1 \cdot -2}} + \frac{1}{2} \]
        6. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right)} \]
        7. lower-*.f6499.4

          \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
        8. lift-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        9. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        10. lower-*.f6499.4

          \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
        11. lift-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        12. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        13. lower-*.f6499.4

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
        14. lift-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot \color{blue}{\frac{1}{6}}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        15. metadata-eval99.4

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot \color{blue}{0.16666666666666666}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      6. Applied rewrites99.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right)} \]
      7. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(1 + -2 \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
      8. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(-2 \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + 1\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        2. associate-*r*N/A

          \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(-2 \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}} + 1\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        3. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(-2 \cdot {u2}^{2}, {\mathsf{PI}\left(\right)}^{2}, 1\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        4. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-2 \cdot \color{blue}{\left(u2 \cdot u2\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        5. associate-*r*N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\left(-2 \cdot u2\right) \cdot u2}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        6. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\left(-2 \cdot u2\right) \cdot u2}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        7. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\left(-2 \cdot u2\right)} \cdot u2, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        8. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(-2 \cdot u2\right) \cdot u2, \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        9. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(-2 \cdot u2\right) \cdot u2, \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        10. lower-PI.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(-2 \cdot u2\right) \cdot u2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        11. lower-PI.f6498.1

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(-2 \cdot u2\right) \cdot u2, \mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}, 1\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      9. Applied rewrites98.1%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\left(-2 \cdot u2\right) \cdot u2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)} \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      10. Add Preprocessing

      Alternative 6: 98.8% accurate, 2.4× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -0.3333333333333333, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 0.16666666666666666\right), \sqrt{\log u1 \cdot -2}, 0.5\right) \end{array} \]
      (FPCore (u1 u2)
       :precision binary64
       (fma
        (fma (* (* u2 u2) -0.3333333333333333) (* (PI) (PI)) 0.16666666666666666)
        (sqrt (* (log u1) -2.0))
        0.5))
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -0.3333333333333333, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 0.16666666666666666\right), \sqrt{\log u1 \cdot -2}, 0.5\right)
      \end{array}
      
      Derivation
      1. Initial program 99.4%

        \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-pow.f64N/A

          \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
        2. unpow1/2N/A

          \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
        3. lower-sqrt.f6499.4

          \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
        4. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{-2 \cdot \log u1}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
        5. *-commutativeN/A

          \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
        6. lower-*.f6499.4

          \[\leadsto \left(\frac{1}{6} \cdot \sqrt{\color{blue}{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      4. Applied rewrites99.4%

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{\sqrt{\log u1 \cdot -2}}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      5. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2}} \]
        2. lift-*.f64N/A

          \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
        3. *-commutativeN/A

          \[\leadsto \color{blue}{\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right)} + \frac{1}{2} \]
        4. lift-*.f64N/A

          \[\leadsto \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \color{blue}{\left(\frac{1}{6} \cdot \sqrt{\log u1 \cdot -2}\right)} + \frac{1}{2} \]
        5. associate-*r*N/A

          \[\leadsto \color{blue}{\left(\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}\right) \cdot \sqrt{\log u1 \cdot -2}} + \frac{1}{2} \]
        6. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right)} \]
        7. lower-*.f6499.4

          \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
        8. lift-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        9. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        10. lower-*.f6499.4

          \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
        11. lift-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        12. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        13. lower-*.f6499.4

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)}\right) \cdot \frac{1}{6}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
        14. lift-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot \color{blue}{\frac{1}{6}}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        15. metadata-eval99.4

          \[\leadsto \mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot \color{blue}{0.16666666666666666}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      6. Applied rewrites99.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right)} \]
      7. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{6} + \frac{-1}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
      8. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{1}{6}}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        2. associate-*r*N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{-1}{3} \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}} + \frac{1}{6}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        3. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{-1}{3} \cdot {u2}^{2}, {\mathsf{PI}\left(\right)}^{2}, \frac{1}{6}\right)}, \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        4. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{{u2}^{2} \cdot \frac{-1}{3}}, {\mathsf{PI}\left(\right)}^{2}, \frac{1}{6}\right), \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        5. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{{u2}^{2} \cdot \frac{-1}{3}}, {\mathsf{PI}\left(\right)}^{2}, \frac{1}{6}\right), \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        6. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\left(u2 \cdot u2\right)} \cdot \frac{-1}{3}, {\mathsf{PI}\left(\right)}^{2}, \frac{1}{6}\right), \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        7. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\left(u2 \cdot u2\right)} \cdot \frac{-1}{3}, {\mathsf{PI}\left(\right)}^{2}, \frac{1}{6}\right), \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        8. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot \frac{-1}{3}, \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, \frac{1}{6}\right), \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        9. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot \frac{-1}{3}, \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, \frac{1}{6}\right), \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        10. lower-PI.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot \frac{-1}{3}, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), \frac{1}{6}\right), \sqrt{\log u1 \cdot -2}, \frac{1}{2}\right) \]
        11. lower-PI.f6498.1

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -0.3333333333333333, \mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}, 0.16666666666666666\right), \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      9. Applied rewrites98.1%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -0.3333333333333333, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 0.16666666666666666\right)}, \sqrt{\log u1 \cdot -2}, 0.5\right) \]
      10. Add Preprocessing

      Alternative 7: 98.4% accurate, 2.9× speedup?

      \[\begin{array}{l} \\ \sqrt{\log u1 \cdot -0.05555555555555555} + 0.5 \end{array} \]
      (FPCore (u1 u2)
       :precision binary64
       (+ (sqrt (* (log u1) -0.05555555555555555)) 0.5))
      double code(double u1, double u2) {
      	return sqrt((log(u1) * -0.05555555555555555)) + 0.5;
      }
      
      real(8) function code(u1, u2)
          real(8), intent (in) :: u1
          real(8), intent (in) :: u2
          code = sqrt((log(u1) * (-0.05555555555555555d0))) + 0.5d0
      end function
      
      public static double code(double u1, double u2) {
      	return Math.sqrt((Math.log(u1) * -0.05555555555555555)) + 0.5;
      }
      
      def code(u1, u2):
      	return math.sqrt((math.log(u1) * -0.05555555555555555)) + 0.5
      
      function code(u1, u2)
      	return Float64(sqrt(Float64(log(u1) * -0.05555555555555555)) + 0.5)
      end
      
      function tmp = code(u1, u2)
      	tmp = sqrt((log(u1) * -0.05555555555555555)) + 0.5;
      end
      
      code[u1_, u2_] := N[(N[Sqrt[N[(N[Log[u1], $MachinePrecision] * -0.05555555555555555), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \sqrt{\log u1 \cdot -0.05555555555555555} + 0.5
      \end{array}
      
      Derivation
      1. Initial program 99.4%

        \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) + 0.5 \]
      2. Add Preprocessing
      3. Applied rewrites98.1%

        \[\leadsto \color{blue}{\sqrt{{\left(\log u1 \cdot -2\right)}^{1} \cdot 0.027777777777777776}} + 0.5 \]
      4. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \sqrt{\color{blue}{{\left(\log u1 \cdot -2\right)}^{1} \cdot \frac{1}{36}}} + \frac{1}{2} \]
        2. lift-pow.f64N/A

          \[\leadsto \sqrt{\color{blue}{{\left(\log u1 \cdot -2\right)}^{1}} \cdot \frac{1}{36}} + \frac{1}{2} \]
        3. unpow1N/A

          \[\leadsto \sqrt{\color{blue}{\left(\log u1 \cdot -2\right)} \cdot \frac{1}{36}} + \frac{1}{2} \]
        4. lift-*.f64N/A

          \[\leadsto \sqrt{\color{blue}{\left(\log u1 \cdot -2\right)} \cdot \frac{1}{36}} + \frac{1}{2} \]
        5. associate-*l*N/A

          \[\leadsto \sqrt{\color{blue}{\log u1 \cdot \left(-2 \cdot \frac{1}{36}\right)}} + \frac{1}{2} \]
        6. metadata-evalN/A

          \[\leadsto \sqrt{\log u1 \cdot \color{blue}{\frac{-1}{18}}} + \frac{1}{2} \]
        7. metadata-evalN/A

          \[\leadsto \sqrt{\log u1 \cdot \color{blue}{\left(\frac{1}{36} \cdot -2\right)}} + \frac{1}{2} \]
        8. lower-*.f64N/A

          \[\leadsto \sqrt{\color{blue}{\log u1 \cdot \left(\frac{1}{36} \cdot -2\right)}} + \frac{1}{2} \]
        9. metadata-eval98.1

          \[\leadsto \sqrt{\log u1 \cdot \color{blue}{-0.05555555555555555}} + 0.5 \]
      5. Applied rewrites98.1%

        \[\leadsto \sqrt{\color{blue}{\log u1 \cdot -0.05555555555555555}} + 0.5 \]
      6. Add Preprocessing

      Reproduce

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