Beckmann Sample, near normal, slope_y

Percentage Accurate: 58.2% → 91.1%
Time: 8.8s
Alternatives: 8
Speedup: 8.9×

Specification

?
\[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\begin{array}{l} \\ \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (- (log (- 1.0 u1)))) (sin (* (* 2.0 (PI)) u2))))
\begin{array}{l}

\\
\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)
\end{array}

Sampling outcomes in binary32 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 8 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: 58.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (- (log (- 1.0 u1)))) (sin (* (* 2.0 (PI)) u2))))
\begin{array}{l}

\\
\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)
\end{array}

Alternative 1: 91.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -\log \left(1 - u1\right)\\ t_1 := {\mathsf{PI}\left(\right)}^{0.16666666666666666}\\ \mathbf{if}\;t\_0 \leq 0.00010599999950500205:\\ \;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(\left(\left(t\_1 \cdot u2\right) \cdot t\_1\right) \cdot 2\right) \cdot {\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2}\right) \cdot \sqrt{t\_0}\\ \end{array} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (let* ((t_0 (- (log (- 1.0 u1)))) (t_1 (pow (PI) 0.16666666666666666)))
   (if (<= t_0 0.00010599999950500205)
     (* (pow (* u1 u1) 0.25) (sin (* (+ u2 u2) (PI))))
     (*
      (sin (* (* (* (* t_1 u2) t_1) 2.0) (pow (cbrt (PI)) 2.0)))
      (sqrt t_0)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -\log \left(1 - u1\right)\\
t_1 := {\mathsf{PI}\left(\right)}^{0.16666666666666666}\\
\mathbf{if}\;t\_0 \leq 0.00010599999950500205:\\
\;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\sin \left(\left(\left(\left(t\_1 \cdot u2\right) \cdot t\_1\right) \cdot 2\right) \cdot {\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2}\right) \cdot \sqrt{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1))) < 1.06e-4

    1. Initial program 34.4%

      \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    2. Add Preprocessing
    3. Applied rewrites45.3%

      \[\leadsto \color{blue}{\frac{\sqrt{-\left(-{\left(\mathsf{log1p}\left(u1\right)\right)}^{2}\right)}}{\sqrt{\mathsf{log1p}\left(u1\right)}}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    4. Taylor expanded in u1 around 0

      \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
      2. lower-*.f32N/A

        \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
      3. lower-sin.f32N/A

        \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{u1} \]
      4. *-commutativeN/A

        \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
      5. lower-*.f32N/A

        \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
      6. *-commutativeN/A

        \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
      7. lower-*.f32N/A

        \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
      8. lower-PI.f32N/A

        \[\leadsto \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
      9. lower-sqrt.f3293.5

        \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \color{blue}{\sqrt{u1}} \]
    6. Applied rewrites93.5%

      \[\leadsto \color{blue}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}} \]
    7. Step-by-step derivation
      1. Applied rewrites93.6%

        \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot {\left(u1 \cdot u1\right)}^{\color{blue}{0.25}} \]
      2. Step-by-step derivation
        1. Applied rewrites93.6%

          \[\leadsto \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \cdot {\left(\color{blue}{u1} \cdot u1\right)}^{0.25} \]

        if 1.06e-4 < (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))

        1. Initial program 89.3%

          \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)} \]
          2. lift-*.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right) \]
          3. associate-*l*N/A

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

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \color{blue}{\left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right)} \]
          5. lift-PI.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \]
          6. add-cube-cbrtN/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(\color{blue}{\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right)} \cdot u2\right) \cdot 2\right) \]
          7. associate-*l*N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\color{blue}{\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right)\right)} \cdot 2\right) \]
          8. associate-*l*N/A

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

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \color{blue}{\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right)\right)} \]
          10. pow2N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\color{blue}{{\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2}} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right)\right) \]
          11. lower-pow.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\color{blue}{{\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2}} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right)\right) \]
          12. lift-PI.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\color{blue}{\mathsf{PI}\left(\right)}}\right)}^{2} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right)\right) \]
          13. lower-cbrt.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\color{blue}{\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}}^{2} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right)\right) \]
          14. lower-*.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \color{blue}{\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right)}\right) \]
          15. lower-*.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\color{blue}{\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right)} \cdot 2\right)\right) \]
          16. lift-PI.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\left(\sqrt[3]{\color{blue}{\mathsf{PI}\left(\right)}} \cdot u2\right) \cdot 2\right)\right) \]
          17. lower-cbrt.f3289.2

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\left(\color{blue}{\sqrt[3]{\mathsf{PI}\left(\right)}} \cdot u2\right) \cdot 2\right)\right) \]
        4. Applied rewrites89.2%

          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \color{blue}{\left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right)\right)} \]
        5. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\color{blue}{\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot u2\right)} \cdot 2\right)\right) \]
          2. lift-cbrt.f32N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\left(\color{blue}{\sqrt[3]{\mathsf{PI}\left(\right)}} \cdot u2\right) \cdot 2\right)\right) \]
          3. pow1/3N/A

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\left(\color{blue}{{\mathsf{PI}\left(\right)}^{\frac{1}{3}}} \cdot u2\right) \cdot 2\right)\right) \]
          4. sqr-powN/A

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

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

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\color{blue}{\left({\mathsf{PI}\left(\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \cdot \left({\mathsf{PI}\left(\right)}^{\left(\frac{\frac{1}{3}}{2}\right)} \cdot u2\right)\right)} \cdot 2\right)\right) \]
          7. lower-pow.f32N/A

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

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

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

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\left({\mathsf{PI}\left(\right)}^{\frac{1}{6}} \cdot \left(\color{blue}{{\mathsf{PI}\left(\right)}^{\left(\frac{\frac{1}{3}}{2}\right)}} \cdot u2\right)\right) \cdot 2\right)\right) \]
          11. metadata-eval89.4

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\left({\mathsf{PI}\left(\right)}^{0.16666666666666666} \cdot \left({\mathsf{PI}\left(\right)}^{\color{blue}{0.16666666666666666}} \cdot u2\right)\right) \cdot 2\right)\right) \]
        6. Applied rewrites89.4%

          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2} \cdot \left(\color{blue}{\left({\mathsf{PI}\left(\right)}^{0.16666666666666666} \cdot \left({\mathsf{PI}\left(\right)}^{0.16666666666666666} \cdot u2\right)\right)} \cdot 2\right)\right) \]
      3. Recombined 2 regimes into one program.
      4. Final simplification92.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;-\log \left(1 - u1\right) \leq 0.00010599999950500205:\\ \;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(\left(\left({\mathsf{PI}\left(\right)}^{0.16666666666666666} \cdot u2\right) \cdot {\mathsf{PI}\left(\right)}^{0.16666666666666666}\right) \cdot 2\right) \cdot {\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2}\right) \cdot \sqrt{-\log \left(1 - u1\right)}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 2: 91.1% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := -\log \left(1 - u1\right)\\ \mathbf{if}\;t\_0 \leq 0.00010599999950500205:\\ \;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot u2\right) \cdot \sqrt{t\_0}\\ \end{array} \end{array} \]
      (FPCore (cosTheta_i u1 u2)
       :precision binary32
       (let* ((t_0 (- (log (- 1.0 u1)))))
         (if (<= t_0 0.00010599999950500205)
           (* (pow (* u1 u1) 0.25) (sin (* (+ u2 u2) (PI))))
           (* (sin (* (* (PI) 2.0) u2)) (sqrt t_0)))))
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := -\log \left(1 - u1\right)\\
      \mathbf{if}\;t\_0 \leq 0.00010599999950500205:\\
      \;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot u2\right) \cdot \sqrt{t\_0}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1))) < 1.06e-4

        1. Initial program 34.4%

          \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
        2. Add Preprocessing
        3. Applied rewrites45.2%

          \[\leadsto \color{blue}{\frac{\sqrt{-\left(-{\left(\mathsf{log1p}\left(u1\right)\right)}^{2}\right)}}{\sqrt{\mathsf{log1p}\left(u1\right)}}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
        4. Taylor expanded in u1 around 0

          \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
        5. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
          2. lower-*.f32N/A

            \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
          3. lower-sin.f32N/A

            \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{u1} \]
          4. *-commutativeN/A

            \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
          5. lower-*.f32N/A

            \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
          6. *-commutativeN/A

            \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
          7. lower-*.f32N/A

            \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
          8. lower-PI.f32N/A

            \[\leadsto \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
          9. lower-sqrt.f3293.5

            \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \color{blue}{\sqrt{u1}} \]
        6. Applied rewrites93.5%

          \[\leadsto \color{blue}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}} \]
        7. Step-by-step derivation
          1. Applied rewrites93.6%

            \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot {\left(u1 \cdot u1\right)}^{\color{blue}{0.25}} \]
          2. Step-by-step derivation
            1. Applied rewrites93.6%

              \[\leadsto \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \cdot {\left(\color{blue}{u1} \cdot u1\right)}^{0.25} \]

            if 1.06e-4 < (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))

            1. Initial program 89.3%

              \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
            2. Add Preprocessing
          3. Recombined 2 regimes into one program.
          4. Final simplification91.9%

            \[\leadsto \begin{array}{l} \mathbf{if}\;-\log \left(1 - u1\right) \leq 0.00010599999950500205:\\ \;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot u2\right) \cdot \sqrt{-\log \left(1 - u1\right)}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 3: 85.0% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-\log \left(1 - u1\right) \leq 0.0009399999980814755:\\ \;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)} \cdot \left(\left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot 2\right)\\ \end{array} \end{array} \]
          (FPCore (cosTheta_i u1 u2)
           :precision binary32
           (if (<= (- (log (- 1.0 u1))) 0.0009399999980814755)
             (* (pow (* u1 u1) 0.25) (sin (* (+ u2 u2) (PI))))
             (*
              (sqrt (log (sqrt (/ 1.0 (- 1.0 u1)))))
              (* (* (* (sqrt 2.0) (PI)) u2) 2.0))))
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;-\log \left(1 - u1\right) \leq 0.0009399999980814755:\\
          \;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)} \cdot \left(\left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot 2\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1))) < 9.39999998e-4

            1. Initial program 39.9%

              \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
            2. Add Preprocessing
            3. Applied rewrites44.9%

              \[\leadsto \color{blue}{\frac{\sqrt{-\left(-{\left(\mathsf{log1p}\left(u1\right)\right)}^{2}\right)}}{\sqrt{\mathsf{log1p}\left(u1\right)}}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
            4. Taylor expanded in u1 around 0

              \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
            5. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
              2. lower-*.f32N/A

                \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
              3. lower-sin.f32N/A

                \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{u1} \]
              4. *-commutativeN/A

                \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
              5. lower-*.f32N/A

                \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
              6. *-commutativeN/A

                \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
              7. lower-*.f32N/A

                \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
              8. lower-PI.f32N/A

                \[\leadsto \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
              9. lower-sqrt.f3290.3

                \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \color{blue}{\sqrt{u1}} \]
            6. Applied rewrites90.3%

              \[\leadsto \color{blue}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}} \]
            7. Step-by-step derivation
              1. Applied rewrites90.4%

                \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot {\left(u1 \cdot u1\right)}^{\color{blue}{0.25}} \]
              2. Step-by-step derivation
                1. Applied rewrites90.4%

                  \[\leadsto \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \cdot {\left(\color{blue}{u1} \cdot u1\right)}^{0.25} \]

                if 9.39999998e-4 < (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))

                1. Initial program 92.8%

                  \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. lift-neg.f32N/A

                    \[\leadsto \sqrt{\color{blue}{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  2. lift-log.f32N/A

                    \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\log \left(1 - u1\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  3. neg-logN/A

                    \[\leadsto \sqrt{\color{blue}{\log \left(\frac{1}{1 - u1}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  4. inv-powN/A

                    \[\leadsto \sqrt{\log \color{blue}{\left({\left(1 - u1\right)}^{-1}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  5. sqr-powN/A

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

                    \[\leadsto \sqrt{\color{blue}{\log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right) + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  7. lower-+.f32N/A

                    \[\leadsto \sqrt{\color{blue}{\log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right) + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  8. lower-log.f32N/A

                    \[\leadsto \sqrt{\color{blue}{\log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  9. lower-pow.f32N/A

                    \[\leadsto \sqrt{\log \color{blue}{\left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  10. metadata-evalN/A

                    \[\leadsto \sqrt{\log \left({\left(1 - u1\right)}^{\color{blue}{\frac{-1}{2}}}\right) + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  11. lower-log.f32N/A

                    \[\leadsto \sqrt{\log \left({\left(1 - u1\right)}^{\frac{-1}{2}}\right) + \color{blue}{\log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  12. lower-pow.f32N/A

                    \[\leadsto \sqrt{\log \left({\left(1 - u1\right)}^{\frac{-1}{2}}\right) + \log \color{blue}{\left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  13. metadata-eval88.1

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

                  \[\leadsto \sqrt{\color{blue}{\log \left({\left(1 - u1\right)}^{-0.5}\right) + \log \left({\left(1 - u1\right)}^{-0.5}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                5. Taylor expanded in u2 around 0

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

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

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

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

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

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

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

                    \[\leadsto \left(2 \cdot \left(\color{blue}{\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)} \]
                  8. lower-sqrt.f32N/A

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

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

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \color{blue}{\sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)}} \]
                  11. lower-log.f32N/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\color{blue}{\log \left(\sqrt{\frac{1}{1 - u1}}\right)}} \]
                  12. lower-sqrt.f32N/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \color{blue}{\left(\sqrt{\frac{1}{1 - u1}}\right)}} \]
                  13. sub-negN/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{\color{blue}{1 + \left(\mathsf{neg}\left(u1\right)\right)}}}\right)} \]
                  14. mul-1-negN/A

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

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\color{blue}{\frac{1}{1 + -1 \cdot u1}}}\right)} \]
                  16. mul-1-negN/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{1 + \color{blue}{\left(\mathsf{neg}\left(u1\right)\right)}}}\right)} \]
                  17. sub-negN/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{\color{blue}{1 - u1}}}\right)} \]
                  18. lower--.f3278.3

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{\color{blue}{1 - u1}}}\right)} \]
                7. Applied rewrites78.3%

                  \[\leadsto \color{blue}{\left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)}} \]
              3. Recombined 2 regimes into one program.
              4. Final simplification86.8%

                \[\leadsto \begin{array}{l} \mathbf{if}\;-\log \left(1 - u1\right) \leq 0.0009399999980814755:\\ \;\;\;\;{\left(u1 \cdot u1\right)}^{0.25} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)} \cdot \left(\left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot 2\right)\\ \end{array} \]
              5. Add Preprocessing

              Alternative 4: 85.0% accurate, 1.3× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - u1 \leq 0.9990599751472473:\\ \;\;\;\;\sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)} \cdot \left(\left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\ \end{array} \end{array} \]
              (FPCore (cosTheta_i u1 u2)
               :precision binary32
               (if (<= (- 1.0 u1) 0.9990599751472473)
                 (*
                  (sqrt (log (sqrt (/ 1.0 (- 1.0 u1)))))
                  (* (* (* (sqrt 2.0) (PI)) u2) 2.0))
                 (* (sqrt u1) (sin (* (+ u2 u2) (PI))))))
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;1 - u1 \leq 0.9990599751472473:\\
              \;\;\;\;\sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)} \cdot \left(\left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot 2\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\sqrt{u1} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (-.f32 #s(literal 1 binary32) u1) < 0.999059975

                1. Initial program 92.8%

                  \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. lift-neg.f32N/A

                    \[\leadsto \sqrt{\color{blue}{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  2. lift-log.f32N/A

                    \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\log \left(1 - u1\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  3. neg-logN/A

                    \[\leadsto \sqrt{\color{blue}{\log \left(\frac{1}{1 - u1}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  4. inv-powN/A

                    \[\leadsto \sqrt{\log \color{blue}{\left({\left(1 - u1\right)}^{-1}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  5. sqr-powN/A

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

                    \[\leadsto \sqrt{\color{blue}{\log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right) + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  7. lower-+.f32N/A

                    \[\leadsto \sqrt{\color{blue}{\log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right) + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  8. lower-log.f32N/A

                    \[\leadsto \sqrt{\color{blue}{\log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  9. lower-pow.f32N/A

                    \[\leadsto \sqrt{\log \color{blue}{\left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  10. metadata-evalN/A

                    \[\leadsto \sqrt{\log \left({\left(1 - u1\right)}^{\color{blue}{\frac{-1}{2}}}\right) + \log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  11. lower-log.f32N/A

                    \[\leadsto \sqrt{\log \left({\left(1 - u1\right)}^{\frac{-1}{2}}\right) + \color{blue}{\log \left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  12. lower-pow.f32N/A

                    \[\leadsto \sqrt{\log \left({\left(1 - u1\right)}^{\frac{-1}{2}}\right) + \log \color{blue}{\left({\left(1 - u1\right)}^{\left(\frac{-1}{2}\right)}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  13. metadata-eval88.1

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

                  \[\leadsto \sqrt{\color{blue}{\log \left({\left(1 - u1\right)}^{-0.5}\right) + \log \left({\left(1 - u1\right)}^{-0.5}\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                5. Taylor expanded in u2 around 0

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

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

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

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

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

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

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

                    \[\leadsto \left(2 \cdot \left(\color{blue}{\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)} \]
                  8. lower-sqrt.f32N/A

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

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

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \color{blue}{\sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)}} \]
                  11. lower-log.f32N/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\color{blue}{\log \left(\sqrt{\frac{1}{1 - u1}}\right)}} \]
                  12. lower-sqrt.f32N/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \color{blue}{\left(\sqrt{\frac{1}{1 - u1}}\right)}} \]
                  13. sub-negN/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{\color{blue}{1 + \left(\mathsf{neg}\left(u1\right)\right)}}}\right)} \]
                  14. mul-1-negN/A

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

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\color{blue}{\frac{1}{1 + -1 \cdot u1}}}\right)} \]
                  16. mul-1-negN/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{1 + \color{blue}{\left(\mathsf{neg}\left(u1\right)\right)}}}\right)} \]
                  17. sub-negN/A

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{\color{blue}{1 - u1}}}\right)} \]
                  18. lower--.f3278.3

                    \[\leadsto \left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{\color{blue}{1 - u1}}}\right)} \]
                7. Applied rewrites78.3%

                  \[\leadsto \color{blue}{\left(2 \cdot \left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \cdot \sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)}} \]

                if 0.999059975 < (-.f32 #s(literal 1 binary32) u1)

                1. Initial program 39.9%

                  \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                2. Add Preprocessing
                3. Applied rewrites46.4%

                  \[\leadsto \color{blue}{\frac{\sqrt{-\left(-{\left(\mathsf{log1p}\left(u1\right)\right)}^{2}\right)}}{\sqrt{\mathsf{log1p}\left(u1\right)}}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                4. Taylor expanded in u1 around 0

                  \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                5. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                  2. lower-*.f32N/A

                    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                  3. lower-sin.f32N/A

                    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{u1} \]
                  4. *-commutativeN/A

                    \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                  5. lower-*.f32N/A

                    \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                  6. *-commutativeN/A

                    \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                  7. lower-*.f32N/A

                    \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                  8. lower-PI.f32N/A

                    \[\leadsto \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
                  9. lower-sqrt.f3290.3

                    \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \color{blue}{\sqrt{u1}} \]
                6. Applied rewrites90.3%

                  \[\leadsto \color{blue}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}} \]
                7. Step-by-step derivation
                  1. Applied rewrites90.3%

                    \[\leadsto \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \cdot \sqrt{u1} \]
                8. Recombined 2 regimes into one program.
                9. Final simplification86.8%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;1 - u1 \leq 0.9990599751472473:\\ \;\;\;\;\sqrt{\log \left(\sqrt{\frac{1}{1 - u1}}\right)} \cdot \left(\left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)\\ \end{array} \]
                10. Add Preprocessing

                Alternative 5: 76.2% accurate, 1.9× speedup?

                \[\begin{array}{l} \\ \sqrt{u1} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right) \end{array} \]
                (FPCore (cosTheta_i u1 u2)
                 :precision binary32
                 (* (sqrt u1) (sin (* (+ u2 u2) (PI)))))
                \begin{array}{l}
                
                \\
                \sqrt{u1} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right)
                \end{array}
                
                Derivation
                1. Initial program 55.4%

                  \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                2. Add Preprocessing
                3. Applied rewrites36.7%

                  \[\leadsto \color{blue}{\frac{\sqrt{-\left(-{\left(\mathsf{log1p}\left(u1\right)\right)}^{2}\right)}}{\sqrt{\mathsf{log1p}\left(u1\right)}}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                4. Taylor expanded in u1 around 0

                  \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                5. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                  2. lower-*.f32N/A

                    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                  3. lower-sin.f32N/A

                    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{u1} \]
                  4. *-commutativeN/A

                    \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                  5. lower-*.f32N/A

                    \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                  6. *-commutativeN/A

                    \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                  7. lower-*.f32N/A

                    \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                  8. lower-PI.f32N/A

                    \[\leadsto \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
                  9. lower-sqrt.f3278.2

                    \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \color{blue}{\sqrt{u1}} \]
                6. Applied rewrites78.2%

                  \[\leadsto \color{blue}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}} \]
                7. Step-by-step derivation
                  1. Applied rewrites78.2%

                    \[\leadsto \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \cdot \sqrt{u1} \]
                  2. Final simplification78.2%

                    \[\leadsto \sqrt{u1} \cdot \sin \left(\left(u2 + u2\right) \cdot \mathsf{PI}\left(\right)\right) \]
                  3. Add Preprocessing

                  Alternative 6: 66.3% accurate, 1.9× speedup?

                  \[\begin{array}{l} \\ \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot {\left(u1 \cdot u1\right)}^{0.25} \end{array} \]
                  (FPCore (cosTheta_i u1 u2)
                   :precision binary32
                   (* (* (* (PI) u2) 2.0) (pow (* u1 u1) 0.25)))
                  \begin{array}{l}
                  
                  \\
                  \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot {\left(u1 \cdot u1\right)}^{0.25}
                  \end{array}
                  
                  Derivation
                  1. Initial program 55.4%

                    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  2. Add Preprocessing
                  3. Applied rewrites36.7%

                    \[\leadsto \color{blue}{\frac{\sqrt{-\left(-{\left(\mathsf{log1p}\left(u1\right)\right)}^{2}\right)}}{\sqrt{\mathsf{log1p}\left(u1\right)}}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                  4. Taylor expanded in u1 around 0

                    \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                  5. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                    2. lower-*.f32N/A

                      \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                    3. lower-sin.f32N/A

                      \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{u1} \]
                    4. *-commutativeN/A

                      \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                    5. lower-*.f32N/A

                      \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                    6. *-commutativeN/A

                      \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                    7. lower-*.f32N/A

                      \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                    8. lower-PI.f32N/A

                      \[\leadsto \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
                    9. lower-sqrt.f3278.2

                      \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \color{blue}{\sqrt{u1}} \]
                  6. Applied rewrites78.2%

                    \[\leadsto \color{blue}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}} \]
                  7. Step-by-step derivation
                    1. Applied rewrites78.2%

                      \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot {\left(u1 \cdot u1\right)}^{\color{blue}{0.25}} \]
                    2. Taylor expanded in u2 around 0

                      \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot {\color{blue}{\left(u1 \cdot u1\right)}}^{\frac{1}{4}} \]
                    3. Step-by-step derivation
                      1. Applied rewrites68.6%

                        \[\leadsto \left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot {\color{blue}{\left(u1 \cdot u1\right)}}^{0.25} \]
                      2. Final simplification68.6%

                        \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot {\left(u1 \cdot u1\right)}^{0.25} \]
                      3. Add Preprocessing

                      Alternative 7: 66.3% accurate, 8.9× speedup?

                      \[\begin{array}{l} \\ \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \end{array} \]
                      (FPCore (cosTheta_i u1 u2)
                       :precision binary32
                       (* (* (* (PI) u2) 2.0) (sqrt u1)))
                      \begin{array}{l}
                      
                      \\
                      \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}
                      \end{array}
                      
                      Derivation
                      1. Initial program 55.4%

                        \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                      2. Add Preprocessing
                      3. Applied rewrites37.4%

                        \[\leadsto \color{blue}{\frac{\sqrt{-\left(-{\left(\mathsf{log1p}\left(u1\right)\right)}^{2}\right)}}{\sqrt{\mathsf{log1p}\left(u1\right)}}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                      4. Taylor expanded in u1 around 0

                        \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                      5. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                        2. lower-*.f32N/A

                          \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                        3. lower-sin.f32N/A

                          \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{u1} \]
                        4. *-commutativeN/A

                          \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                        5. lower-*.f32N/A

                          \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                        6. *-commutativeN/A

                          \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                        7. lower-*.f32N/A

                          \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                        8. lower-PI.f32N/A

                          \[\leadsto \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
                        9. lower-sqrt.f3278.2

                          \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \color{blue}{\sqrt{u1}} \]
                      6. Applied rewrites78.2%

                        \[\leadsto \color{blue}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}} \]
                      7. Taylor expanded in u2 around 0

                        \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\color{blue}{u1}} \]
                      8. Step-by-step derivation
                        1. Applied rewrites68.6%

                          \[\leadsto \left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot \sqrt{\color{blue}{u1}} \]
                        2. Final simplification68.6%

                          \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
                        3. Add Preprocessing

                        Alternative 8: 66.3% accurate, 8.9× speedup?

                        \[\begin{array}{l} \\ \left(\left(\sqrt{u1} \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot u2 \end{array} \]
                        (FPCore (cosTheta_i u1 u2)
                         :precision binary32
                         (* (* (* (sqrt u1) (PI)) 2.0) u2))
                        \begin{array}{l}
                        
                        \\
                        \left(\left(\sqrt{u1} \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot u2
                        \end{array}
                        
                        Derivation
                        1. Initial program 55.4%

                          \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                        2. Add Preprocessing
                        3. Applied rewrites35.9%

                          \[\leadsto \color{blue}{\frac{\sqrt{-\left(-{\left(\mathsf{log1p}\left(u1\right)\right)}^{2}\right)}}{\sqrt{\mathsf{log1p}\left(u1\right)}}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
                        4. Taylor expanded in u1 around 0

                          \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                        5. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                          2. lower-*.f32N/A

                            \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{u1}} \]
                          3. lower-sin.f32N/A

                            \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{u1} \]
                          4. *-commutativeN/A

                            \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                          5. lower-*.f32N/A

                            \[\leadsto \sin \color{blue}{\left(\left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)} \cdot \sqrt{u1} \]
                          6. *-commutativeN/A

                            \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                          7. lower-*.f32N/A

                            \[\leadsto \sin \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot 2\right) \cdot \sqrt{u1} \]
                          8. lower-PI.f32N/A

                            \[\leadsto \sin \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1} \]
                          9. lower-sqrt.f3278.2

                            \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \color{blue}{\sqrt{u1}} \]
                        6. Applied rewrites78.2%

                          \[\leadsto \color{blue}{\sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot \sqrt{u1}} \]
                        7. Step-by-step derivation
                          1. Applied rewrites78.2%

                            \[\leadsto \sin \left(\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot 2\right) \cdot {\left(u1 \cdot u1\right)}^{\color{blue}{0.25}} \]
                          2. Taylor expanded in u2 around 0

                            \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{u1} \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                          3. Step-by-step derivation
                            1. Applied rewrites68.5%

                              \[\leadsto \left(\left(\sqrt{u1} \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot \color{blue}{u2} \]
                            2. Add Preprocessing

                            Reproduce

                            ?
                            herbie shell --seed 2024332 
                            (FPCore (cosTheta_i u1 u2)
                              :name "Beckmann Sample, near normal, slope_y"
                              :precision binary32
                              :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 1.0))) (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                              (* (sqrt (- (log (- 1.0 u1)))) (sin (* (* 2.0 (PI)) u2))))