UniformSampleCone, x

Percentage Accurate: 57.4% → 98.7%
Time: 11.7s
Alternatives: 13
Speedup: 5.8×

Specification

?
\[\left(\left(2.328306437 \cdot 10^{-10} \leq ux \land ux \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq uy \land uy \leq 1\right)\right) \land \left(0 \leq maxCos \land maxCos \leq 1\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
   (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\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 13 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: 57.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
   (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Alternative 1: 98.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \sqrt{\left(ux \cdot ux\right) \cdot \frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2} \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sqrt
   (-
    (* (* ux ux) (/ (+ (* -2.0 maxCos) 2.0) ux))
    (* (pow (- maxCos 1.0) 2.0) (* ux ux))))
  (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}

\\
\sqrt{\left(ux \cdot ux\right) \cdot \frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2} \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Derivation
  1. Initial program 56.3%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around inf

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}}} \]
    2. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}}} \]
    3. associate--r+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 \cdot \frac{1}{ux} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right)} \cdot {ux}^{2}} \]
    4. associate-*r/N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\color{blue}{\frac{2 \cdot 1}{ux}} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    5. metadata-evalN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{\color{blue}{2}}{ux} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    6. associate-*r/N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{2}{ux} - \color{blue}{\frac{2 \cdot maxCos}{ux}}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    7. div-subN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\frac{2 - 2 \cdot maxCos}{ux}} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    8. cancel-sign-sub-invN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    9. metadata-evalN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{2 + \color{blue}{-2} \cdot maxCos}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    10. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\frac{2 + -2 \cdot maxCos}{ux} - {\left(maxCos - 1\right)}^{2}\right)} \cdot {ux}^{2}} \]
    11. lower-/.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\frac{2 + -2 \cdot maxCos}{ux}} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    12. +-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{-2 \cdot maxCos + 2}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    13. lower-fma.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
    14. lower-pow.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - \color{blue}{{\left(maxCos - 1\right)}^{2}}\right) \cdot {ux}^{2}} \]
    15. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\color{blue}{\left(maxCos - 1\right)}}^{2}\right) \cdot {ux}^{2}} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]
    17. lower-*.f3270.0

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]
  5. Applied rewrites70.1%

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)}} \]
  6. Step-by-step derivation
    1. Applied rewrites70.2%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} \cdot \left(ux \cdot ux\right) + \color{blue}{\left(-{\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)}} \]
    2. Step-by-step derivation
      1. Applied rewrites98.8%

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{maxCos \cdot -2 + 2}{ux} \cdot \left(ux \cdot ux\right) + \left(-{\color{blue}{\left(maxCos - 1\right)}}^{2}\right) \cdot \left(ux \cdot ux\right)} \]
      2. Final simplification98.8%

        \[\leadsto \sqrt{\left(ux \cdot ux\right) \cdot \frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2} \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \]
      3. Add Preprocessing

      Alternative 2: 83.0% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := maxCos \cdot ux + \left(1 - ux\right)\\ t_1 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \cdot t\_1 \leq 0.03200000151991844:\\ \;\;\;\;\sqrt{0.5 \cdot \left(4 \cdot ux\right)} \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot t\_0} \cdot 1\\ \end{array} \end{array} \]
      (FPCore (ux uy maxCos)
       :precision binary32
       (let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))) (t_1 (cos (* (PI) (* 2.0 uy)))))
         (if (<= (* (sqrt (- 1.0 (* t_0 t_0))) t_1) 0.03200000151991844)
           (* (sqrt (* 0.5 (* 4.0 ux))) t_1)
           (* (sqrt (- 1.0 (* (* (- (+ (/ 1.0 ux) maxCos) 1.0) ux) t_0))) 1.0))))
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
      t_1 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
      \mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \cdot t\_1 \leq 0.03200000151991844:\\
      \;\;\;\;\sqrt{0.5 \cdot \left(4 \cdot ux\right)} \cdot t\_1\\
      
      \mathbf{else}:\\
      \;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot t\_0} \cdot 1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f32 (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))))) < 0.0320000015

        1. Initial program 39.3%

          \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift--.f32N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
          2. flip--N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\frac{1 \cdot 1 - \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}{1 + \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}} \]
          3. lower-/.f32N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\frac{1 \cdot 1 - \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}{1 + \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}} \]
        4. Applied rewrites25.4%

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\frac{1 - {\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)}^{4}}{{\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)}^{2} + 1}}} \]
        5. Taylor expanded in ux around 0

          \[\leadsto \color{blue}{\sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \cdot \left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right)} \]
        6. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
          2. lower-*.f32N/A

            \[\leadsto \color{blue}{\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
          3. *-commutativeN/A

            \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{2}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          4. lower-*.f32N/A

            \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{2}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          5. lower-sqrt.f32N/A

            \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{2}}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          6. lower-cos.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          7. *-commutativeN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \color{blue}{\left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          8. lower-*.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \color{blue}{\left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          9. *-commutativeN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          10. lower-*.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          11. lower-PI.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          12. lower-sqrt.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \color{blue}{\sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
          13. *-commutativeN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 - 4 \cdot maxCos\right) \cdot ux}} \]
          14. lower-*.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 - 4 \cdot maxCos\right) \cdot ux}} \]
          15. cancel-sign-sub-invN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 + \left(\mathsf{neg}\left(4\right)\right) \cdot maxCos\right)} \cdot ux} \]
          16. metadata-evalN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\left(4 + \color{blue}{-4} \cdot maxCos\right) \cdot ux} \]
          17. +-commutativeN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(-4 \cdot maxCos + 4\right)} \cdot ux} \]
          18. lower-fma.f3262.3

            \[\leadsto \left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-4, maxCos, 4\right)} \cdot ux} \]
        7. Applied rewrites62.8%

          \[\leadsto \color{blue}{\left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\mathsf{fma}\left(-4, maxCos, 4\right) \cdot ux}} \]
        8. Taylor expanded in maxCos around 0

          \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{4 \cdot ux} \]
        9. Step-by-step derivation
          1. Applied rewrites85.7%

            \[\leadsto \left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{4 \cdot ux} \]
          2. Step-by-step derivation
            1. Applied rewrites85.9%

              \[\leadsto \color{blue}{\sqrt{\left(4 \cdot ux\right) \cdot 0.5} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(uy \cdot 2\right)\right)} \]

            if 0.0320000015 < (*.f32 (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))))

            1. Initial program 92.2%

              \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in uy around 0

              \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
            4. Step-by-step derivation
              1. Applied rewrites82.5%

                \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
              2. Taylor expanded in ux around inf

                \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(ux \cdot \left(\left(maxCos + \frac{1}{ux}\right) - 1\right)\right)}} \]
              3. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(maxCos + \frac{1}{ux}\right) - 1\right) \cdot ux\right)}} \]
                2. lower-*.f32N/A

                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(maxCos + \frac{1}{ux}\right) - 1\right) \cdot ux\right)}} \]
                3. lower--.f32N/A

                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\color{blue}{\left(\left(maxCos + \frac{1}{ux}\right) - 1\right)} \cdot ux\right)} \]
                4. +-commutativeN/A

                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\color{blue}{\left(\frac{1}{ux} + maxCos\right)} - 1\right) \cdot ux\right)} \]
                5. lower-+.f32N/A

                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\color{blue}{\left(\frac{1}{ux} + maxCos\right)} - 1\right) \cdot ux\right)} \]
                6. lower-/.f3282.9

                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\left(\color{blue}{\frac{1}{ux}} + maxCos\right) - 1\right) \cdot ux\right)} \]
              4. Applied rewrites82.9%

                \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right)}} \]
            5. Recombined 2 regimes into one program.
            6. Final simplification85.0%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt{1 - \left(maxCos \cdot ux + \left(1 - ux\right)\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \leq 0.03200000151991844:\\ \;\;\;\;\sqrt{0.5 \cdot \left(4 \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\ \end{array} \]
            7. Add Preprocessing

            Alternative 3: 98.8% accurate, 0.6× speedup?

            \[\begin{array}{l} \\ \sqrt{\left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \end{array} \]
            (FPCore (ux uy maxCos)
             :precision binary32
             (*
              (sqrt
               (* (- (/ (+ (* -2.0 maxCos) 2.0) ux) (pow (- maxCos 1.0) 2.0)) (* ux ux)))
              (cos (* (PI) (* 2.0 uy)))))
            \begin{array}{l}
            
            \\
            \sqrt{\left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
            \end{array}
            
            Derivation
            1. Initial program 56.3%

              \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in ux around inf

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}}} \]
              2. lower-*.f32N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}}} \]
              3. associate--r+N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 \cdot \frac{1}{ux} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right)} \cdot {ux}^{2}} \]
              4. associate-*r/N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\color{blue}{\frac{2 \cdot 1}{ux}} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              5. metadata-evalN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{\color{blue}{2}}{ux} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              6. associate-*r/N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{2}{ux} - \color{blue}{\frac{2 \cdot maxCos}{ux}}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              7. div-subN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\frac{2 - 2 \cdot maxCos}{ux}} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              8. cancel-sign-sub-invN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              9. metadata-evalN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{2 + \color{blue}{-2} \cdot maxCos}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              10. lower--.f32N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\frac{2 + -2 \cdot maxCos}{ux} - {\left(maxCos - 1\right)}^{2}\right)} \cdot {ux}^{2}} \]
              11. lower-/.f32N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\frac{2 + -2 \cdot maxCos}{ux}} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              12. +-commutativeN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{-2 \cdot maxCos + 2}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              13. lower-fma.f32N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
              14. lower-pow.f32N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - \color{blue}{{\left(maxCos - 1\right)}^{2}}\right) \cdot {ux}^{2}} \]
              15. lower--.f32N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\color{blue}{\left(maxCos - 1\right)}}^{2}\right) \cdot {ux}^{2}} \]
              16. unpow2N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]
              17. lower-*.f3270.1

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]
            5. Applied rewrites70.1%

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)}} \]
            6. Step-by-step derivation
              1. Applied rewrites98.8%

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \]
              2. Final simplification98.8%

                \[\leadsto \sqrt{\left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \]
              3. Add Preprocessing

              Alternative 4: 85.4% accurate, 0.6× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{if}\;t\_0 \leq 0.9999849796295166:\\ \;\;\;\;\sqrt{0.5 \cdot \left(4 \cdot ux\right)} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux} \cdot 1\\ \end{array} \end{array} \]
              (FPCore (ux uy maxCos)
               :precision binary32
               (let* ((t_0 (cos (* (PI) (* 2.0 uy)))))
                 (if (<= t_0 0.9999849796295166)
                   (* (sqrt (* 0.5 (* 4.0 ux))) t_0)
                   (*
                    (sqrt (* (- (fma -2.0 maxCos 2.0) (* (pow (- maxCos 1.0) 2.0) ux)) ux))
                    1.0))))
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
              \mathbf{if}\;t\_0 \leq 0.9999849796295166:\\
              \;\;\;\;\sqrt{0.5 \cdot \left(4 \cdot ux\right)} \cdot t\_0\\
              
              \mathbf{else}:\\
              \;\;\;\;\sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux} \cdot 1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) < 0.99998498

                1. Initial program 54.1%

                  \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. lift--.f32N/A

                    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                  2. flip--N/A

                    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\frac{1 \cdot 1 - \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}{1 + \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}} \]
                  3. lower-/.f32N/A

                    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\frac{1 \cdot 1 - \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}{1 + \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}} \]
                4. Applied rewrites9.2%

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\frac{1 - {\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)}^{4}}{{\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)}^{2} + 1}}} \]
                5. Taylor expanded in ux around 0

                  \[\leadsto \color{blue}{\sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \cdot \left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right)} \]
                6. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \color{blue}{\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
                  2. lower-*.f32N/A

                    \[\leadsto \color{blue}{\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
                  3. *-commutativeN/A

                    \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{2}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  4. lower-*.f32N/A

                    \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{2}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  5. lower-sqrt.f32N/A

                    \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{2}}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  6. lower-cos.f32N/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  7. *-commutativeN/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \color{blue}{\left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  8. lower-*.f32N/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \color{blue}{\left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  9. *-commutativeN/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  10. lower-*.f32N/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  11. lower-PI.f32N/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
                  12. lower-sqrt.f32N/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \color{blue}{\sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
                  13. *-commutativeN/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 - 4 \cdot maxCos\right) \cdot ux}} \]
                  14. lower-*.f32N/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 - 4 \cdot maxCos\right) \cdot ux}} \]
                  15. cancel-sign-sub-invN/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 + \left(\mathsf{neg}\left(4\right)\right) \cdot maxCos\right)} \cdot ux} \]
                  16. metadata-evalN/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\left(4 + \color{blue}{-4} \cdot maxCos\right) \cdot ux} \]
                  17. +-commutativeN/A

                    \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(-4 \cdot maxCos + 4\right)} \cdot ux} \]
                  18. lower-fma.f3220.0

                    \[\leadsto \left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-4, maxCos, 4\right)} \cdot ux} \]
                7. Applied rewrites20.0%

                  \[\leadsto \color{blue}{\left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\mathsf{fma}\left(-4, maxCos, 4\right) \cdot ux}} \]
                8. Taylor expanded in maxCos around 0

                  \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{4 \cdot ux} \]
                9. Step-by-step derivation
                  1. Applied rewrites74.4%

                    \[\leadsto \left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{4 \cdot ux} \]
                  2. Step-by-step derivation
                    1. Applied rewrites74.6%

                      \[\leadsto \color{blue}{\sqrt{\left(4 \cdot ux\right) \cdot 0.5} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(uy \cdot 2\right)\right)} \]

                    if 0.99998498 < (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32)))

                    1. Initial program 57.3%

                      \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in uy around 0

                      \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    4. Step-by-step derivation
                      1. Applied rewrites56.9%

                        \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                      2. Taylor expanded in ux around 0

                        \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                      3. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right) \cdot ux}} \]
                        2. associate--l+N/A

                          \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + \left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) - 2 \cdot maxCos\right)\right)} \cdot ux} \]
                        3. cancel-sign-sub-invN/A

                          \[\leadsto 1 \cdot \sqrt{\left(2 + \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}\right) \cdot ux} \]
                        4. metadata-evalN/A

                          \[\leadsto 1 \cdot \sqrt{\left(2 + \left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + \color{blue}{-2} \cdot maxCos\right)\right) \cdot ux} \]
                        5. +-commutativeN/A

                          \[\leadsto 1 \cdot \sqrt{\left(2 + \color{blue}{\left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}\right) \cdot ux} \]
                        6. lower-*.f32N/A

                          \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + \left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot ux}} \]
                        7. associate-+r+N/A

                          \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \cdot ux} \]
                        8. mul-1-negN/A

                          \[\leadsto 1 \cdot \sqrt{\left(\left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}\right) \cdot ux} \]
                        9. unsub-negN/A

                          \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) - ux \cdot {\left(maxCos - 1\right)}^{2}\right)} \cdot ux} \]
                        10. lower--.f32N/A

                          \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) - ux \cdot {\left(maxCos - 1\right)}^{2}\right)} \cdot ux} \]
                        11. +-commutativeN/A

                          \[\leadsto 1 \cdot \sqrt{\left(\color{blue}{\left(-2 \cdot maxCos + 2\right)} - ux \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
                        12. lower-fma.f32N/A

                          \[\leadsto 1 \cdot \sqrt{\left(\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} - ux \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
                        13. *-commutativeN/A

                          \[\leadsto 1 \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right) \cdot ux} \]
                        14. lower-*.f32N/A

                          \[\leadsto 1 \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right) \cdot ux} \]
                        15. lower-pow.f32N/A

                          \[\leadsto 1 \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2}} \cdot ux\right) \cdot ux} \]
                        16. lower--.f3294.0

                          \[\leadsto 1 \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\color{blue}{\left(maxCos - 1\right)}}^{2} \cdot ux\right) \cdot ux} \]
                      4. Applied rewrites94.0%

                        \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux}} \]
                    5. Recombined 2 regimes into one program.
                    6. Final simplification87.7%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \leq 0.9999849796295166:\\ \;\;\;\;\sqrt{0.5 \cdot \left(4 \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux} \cdot 1\\ \end{array} \]
                    7. Add Preprocessing

                    Alternative 5: 92.8% accurate, 1.1× speedup?

                    \[\begin{array}{l} \\ \sqrt{ux \cdot 2 - ux \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \end{array} \]
                    (FPCore (ux uy maxCos)
                     :precision binary32
                     (* (sqrt (- (* ux 2.0) (* ux ux))) (cos (* (PI) (* 2.0 uy)))))
                    \begin{array}{l}
                    
                    \\
                    \sqrt{ux \cdot 2 - ux \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
                    \end{array}
                    
                    Derivation
                    1. Initial program 56.3%

                      \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in ux around inf

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}}} \]
                      2. lower-*.f32N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}}} \]
                      3. associate--r+N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 \cdot \frac{1}{ux} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right)} \cdot {ux}^{2}} \]
                      4. associate-*r/N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\color{blue}{\frac{2 \cdot 1}{ux}} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      5. metadata-evalN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{\color{blue}{2}}{ux} - 2 \cdot \frac{maxCos}{ux}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      6. associate-*r/N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{2}{ux} - \color{blue}{\frac{2 \cdot maxCos}{ux}}\right) - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      7. div-subN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\frac{2 - 2 \cdot maxCos}{ux}} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      8. cancel-sign-sub-invN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      9. metadata-evalN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{2 + \color{blue}{-2} \cdot maxCos}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      10. lower--.f32N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\frac{2 + -2 \cdot maxCos}{ux} - {\left(maxCos - 1\right)}^{2}\right)} \cdot {ux}^{2}} \]
                      11. lower-/.f32N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\frac{2 + -2 \cdot maxCos}{ux}} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      12. +-commutativeN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{-2 \cdot maxCos + 2}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      13. lower-fma.f32N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                      14. lower-pow.f32N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - \color{blue}{{\left(maxCos - 1\right)}^{2}}\right) \cdot {ux}^{2}} \]
                      15. lower--.f32N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\color{blue}{\left(maxCos - 1\right)}}^{2}\right) \cdot {ux}^{2}} \]
                      16. unpow2N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]
                      17. lower-*.f3270.1

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]
                    5. Applied rewrites70.1%

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)}} \]
                    6. Step-by-step derivation
                      1. Applied rewrites70.2%

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} \cdot \left(ux \cdot ux\right) + \color{blue}{\left(-{\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)}} \]
                      2. Taylor expanded in maxCos around 0

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{-1 \cdot {ux}^{2} + \color{blue}{2 \cdot ux}} \]
                      3. Step-by-step derivation
                        1. Applied rewrites95.1%

                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}} \]
                        2. Final simplification95.1%

                          \[\leadsto \sqrt{ux \cdot 2 - ux \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \]
                        3. Add Preprocessing

                        Alternative 6: 72.3% accurate, 2.5× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\ \end{array} \end{array} \]
                        (FPCore (ux uy maxCos)
                         :precision binary32
                         (if (<= ux 0.0001500000071246177)
                           (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
                           (*
                            (sqrt
                             (-
                              1.0
                              (* (* (- (+ (/ 1.0 ux) maxCos) 1.0) ux) (+ (* maxCos ux) (- 1.0 ux)))))
                            1.0)))
                        float code(float ux, float uy, float maxCos) {
                        	float tmp;
                        	if (ux <= 0.0001500000071246177f) {
                        		tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
                        	} else {
                        		tmp = sqrtf((1.0f - (((((1.0f / ux) + maxCos) - 1.0f) * ux) * ((maxCos * ux) + (1.0f - ux))))) * 1.0f;
                        	}
                        	return tmp;
                        }
                        
                        function code(ux, uy, maxCos)
                        	tmp = Float32(0.0)
                        	if (ux <= Float32(0.0001500000071246177))
                        		tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0));
                        	else
                        		tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(Float32(Float32(Float32(1.0) / ux) + maxCos) - Float32(1.0)) * ux) * Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux))))) * Float32(1.0));
                        	end
                        	return tmp
                        end
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;ux \leq 0.0001500000071246177:\\
                        \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if ux < 1.50000007e-4

                          1. Initial program 34.3%

                            \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                          2. Add Preprocessing
                          3. Taylor expanded in uy around 0

                            \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                          4. Step-by-step derivation
                            1. Applied rewrites31.9%

                              \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            2. Taylor expanded in ux around 0

                              \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
                            3. Step-by-step derivation
                              1. cancel-sign-sub-invN/A

                                \[\leadsto 1 \cdot \sqrt{ux \cdot \color{blue}{\left(2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}} \]
                              2. metadata-evalN/A

                                \[\leadsto 1 \cdot \sqrt{ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)} \]
                              3. *-commutativeN/A

                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                              4. lower-*.f32N/A

                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                              5. +-commutativeN/A

                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(-2 \cdot maxCos + 2\right)} \cdot ux} \]
                              6. lower-fma.f3273.6

                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} \cdot ux} \]
                            4. Applied rewrites73.2%

                              \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}} \]

                            if 1.50000007e-4 < ux

                            1. Initial program 89.9%

                              \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            2. Add Preprocessing
                            3. Taylor expanded in uy around 0

                              \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            4. Step-by-step derivation
                              1. Applied rewrites75.6%

                                \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                              2. Taylor expanded in ux around inf

                                \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(ux \cdot \left(\left(maxCos + \frac{1}{ux}\right) - 1\right)\right)}} \]
                              3. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(maxCos + \frac{1}{ux}\right) - 1\right) \cdot ux\right)}} \]
                                2. lower-*.f32N/A

                                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(maxCos + \frac{1}{ux}\right) - 1\right) \cdot ux\right)}} \]
                                3. lower--.f32N/A

                                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\color{blue}{\left(\left(maxCos + \frac{1}{ux}\right) - 1\right)} \cdot ux\right)} \]
                                4. +-commutativeN/A

                                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\color{blue}{\left(\frac{1}{ux} + maxCos\right)} - 1\right) \cdot ux\right)} \]
                                5. lower-+.f32N/A

                                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\color{blue}{\left(\frac{1}{ux} + maxCos\right)} - 1\right) \cdot ux\right)} \]
                                6. lower-/.f3276.1

                                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\left(\color{blue}{\frac{1}{ux}} + maxCos\right) - 1\right) \cdot ux\right)} \]
                              4. Applied rewrites76.1%

                                \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right)}} \]
                            5. Recombined 2 regimes into one program.
                            6. Final simplification74.6%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\ \end{array} \]
                            7. Add Preprocessing

                            Alternative 7: 72.4% accurate, 3.0× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\ \end{array} \end{array} \]
                            (FPCore (ux uy maxCos)
                             :precision binary32
                             (if (<= ux 0.0001500000071246177)
                               (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
                               (*
                                (sqrt
                                 (- 1.0 (* (- 1.0 (- ux (* maxCos ux))) (+ (* maxCos ux) (- 1.0 ux)))))
                                1.0)))
                            float code(float ux, float uy, float maxCos) {
                            	float tmp;
                            	if (ux <= 0.0001500000071246177f) {
                            		tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
                            	} else {
                            		tmp = sqrtf((1.0f - ((1.0f - (ux - (maxCos * ux))) * ((maxCos * ux) + (1.0f - ux))))) * 1.0f;
                            	}
                            	return tmp;
                            }
                            
                            function code(ux, uy, maxCos)
                            	tmp = Float32(0.0)
                            	if (ux <= Float32(0.0001500000071246177))
                            		tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0));
                            	else
                            		tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) - Float32(ux - Float32(maxCos * ux))) * Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux))))) * Float32(1.0));
                            	end
                            	return tmp
                            end
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;ux \leq 0.0001500000071246177:\\
                            \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if ux < 1.50000007e-4

                              1. Initial program 34.3%

                                \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                              2. Add Preprocessing
                              3. Taylor expanded in uy around 0

                                \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                              4. Step-by-step derivation
                                1. Applied rewrites31.9%

                                  \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                2. Taylor expanded in ux around 0

                                  \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
                                3. Step-by-step derivation
                                  1. cancel-sign-sub-invN/A

                                    \[\leadsto 1 \cdot \sqrt{ux \cdot \color{blue}{\left(2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}} \]
                                  2. metadata-evalN/A

                                    \[\leadsto 1 \cdot \sqrt{ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)} \]
                                  3. *-commutativeN/A

                                    \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                  4. lower-*.f32N/A

                                    \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                  5. +-commutativeN/A

                                    \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(-2 \cdot maxCos + 2\right)} \cdot ux} \]
                                  6. lower-fma.f3273.6

                                    \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} \cdot ux} \]
                                4. Applied rewrites73.2%

                                  \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}} \]

                                if 1.50000007e-4 < ux

                                1. Initial program 89.9%

                                  \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                2. Add Preprocessing
                                3. Taylor expanded in uy around 0

                                  \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites75.6%

                                    \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                  2. Step-by-step derivation
                                    1. lift-+.f32N/A

                                      \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    2. lift--.f32N/A

                                      \[\leadsto 1 \cdot \sqrt{1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    3. associate-+l-N/A

                                      \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    4. lower--.f32N/A

                                      \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    5. lower--.f3275.8

                                      \[\leadsto 1 \cdot \sqrt{1 - \left(1 - \color{blue}{\left(ux - ux \cdot maxCos\right)}\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    6. lift-*.f32N/A

                                      \[\leadsto 1 \cdot \sqrt{1 - \left(1 - \left(ux - \color{blue}{ux \cdot maxCos}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    7. *-commutativeN/A

                                      \[\leadsto 1 \cdot \sqrt{1 - \left(1 - \left(ux - \color{blue}{maxCos \cdot ux}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    8. lower-*.f3275.8

                                      \[\leadsto 1 \cdot \sqrt{1 - \left(1 - \left(ux - \color{blue}{maxCos \cdot ux}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                  3. Applied rewrites75.8%

                                    \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                5. Recombined 2 regimes into one program.
                                6. Final simplification74.5%

                                  \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\ \end{array} \]
                                7. Add Preprocessing

                                Alternative 8: 72.3% accurate, 3.0× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := maxCos \cdot ux + \left(1 - ux\right)\\ \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - t\_0 \cdot t\_0} \cdot 1\\ \end{array} \end{array} \]
                                (FPCore (ux uy maxCos)
                                 :precision binary32
                                 (let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
                                   (if (<= ux 0.0001500000071246177)
                                     (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
                                     (* (sqrt (- 1.0 (* t_0 t_0))) 1.0))))
                                float code(float ux, float uy, float maxCos) {
                                	float t_0 = (maxCos * ux) + (1.0f - ux);
                                	float tmp;
                                	if (ux <= 0.0001500000071246177f) {
                                		tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
                                	} else {
                                		tmp = sqrtf((1.0f - (t_0 * t_0))) * 1.0f;
                                	}
                                	return tmp;
                                }
                                
                                function code(ux, uy, maxCos)
                                	t_0 = Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux))
                                	tmp = Float32(0.0)
                                	if (ux <= Float32(0.0001500000071246177))
                                		tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0));
                                	else
                                		tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))) * Float32(1.0));
                                	end
                                	return tmp
                                end
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
                                \mathbf{if}\;ux \leq 0.0001500000071246177:\\
                                \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\sqrt{1 - t\_0 \cdot t\_0} \cdot 1\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if ux < 1.50000007e-4

                                  1. Initial program 34.3%

                                    \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in uy around 0

                                    \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites31.9%

                                      \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    2. Taylor expanded in ux around 0

                                      \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
                                    3. Step-by-step derivation
                                      1. cancel-sign-sub-invN/A

                                        \[\leadsto 1 \cdot \sqrt{ux \cdot \color{blue}{\left(2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}} \]
                                      2. metadata-evalN/A

                                        \[\leadsto 1 \cdot \sqrt{ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)} \]
                                      3. *-commutativeN/A

                                        \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                      4. lower-*.f32N/A

                                        \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                      5. +-commutativeN/A

                                        \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(-2 \cdot maxCos + 2\right)} \cdot ux} \]
                                      6. lower-fma.f3268.1

                                        \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} \cdot ux} \]
                                    4. Applied rewrites73.2%

                                      \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}} \]

                                    if 1.50000007e-4 < ux

                                    1. Initial program 89.9%

                                      \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in uy around 0

                                      \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites75.6%

                                        \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    5. Recombined 2 regimes into one program.
                                    6. Final simplification73.6%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(maxCos \cdot ux + \left(1 - ux\right)\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\ \end{array} \]
                                    7. Add Preprocessing

                                    Alternative 9: 71.2% accurate, 3.1× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\left(maxCos - 1\right) \cdot ux + 1\right)} \cdot 1\\ \end{array} \end{array} \]
                                    (FPCore (ux uy maxCos)
                                     :precision binary32
                                     (if (<= ux 0.0001500000071246177)
                                       (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
                                       (*
                                        (sqrt (- 1.0 (* (- (fma ux maxCos 1.0) ux) (+ (* (- maxCos 1.0) ux) 1.0))))
                                        1.0)))
                                    float code(float ux, float uy, float maxCos) {
                                    	float tmp;
                                    	if (ux <= 0.0001500000071246177f) {
                                    		tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
                                    	} else {
                                    		tmp = sqrtf((1.0f - ((fmaf(ux, maxCos, 1.0f) - ux) * (((maxCos - 1.0f) * ux) + 1.0f)))) * 1.0f;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    function code(ux, uy, maxCos)
                                    	tmp = Float32(0.0)
                                    	if (ux <= Float32(0.0001500000071246177))
                                    		tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0));
                                    	else
                                    		tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(fma(ux, maxCos, Float32(1.0)) - ux) * Float32(Float32(Float32(maxCos - Float32(1.0)) * ux) + Float32(1.0))))) * Float32(1.0));
                                    	end
                                    	return tmp
                                    end
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;ux \leq 0.0001500000071246177:\\
                                    \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\left(maxCos - 1\right) \cdot ux + 1\right)} \cdot 1\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if ux < 1.50000007e-4

                                      1. Initial program 34.3%

                                        \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in uy around 0

                                        \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites31.9%

                                          \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                        2. Taylor expanded in ux around 0

                                          \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
                                        3. Step-by-step derivation
                                          1. cancel-sign-sub-invN/A

                                            \[\leadsto 1 \cdot \sqrt{ux \cdot \color{blue}{\left(2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}} \]
                                          2. metadata-evalN/A

                                            \[\leadsto 1 \cdot \sqrt{ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)} \]
                                          3. *-commutativeN/A

                                            \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                          4. lower-*.f32N/A

                                            \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                          5. +-commutativeN/A

                                            \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(-2 \cdot maxCos + 2\right)} \cdot ux} \]
                                          6. lower-fma.f3273.6

                                            \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} \cdot ux} \]
                                        4. Applied rewrites73.2%

                                          \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}} \]

                                        if 1.50000007e-4 < ux

                                        1. Initial program 89.9%

                                          \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in uy around 0

                                          \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                        4. Step-by-step derivation
                                          1. Applied rewrites75.6%

                                            \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                          2. Taylor expanded in ux around inf

                                            \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(ux \cdot \left(\left(maxCos + \frac{1}{ux}\right) - 1\right)\right)}} \]
                                          3. Step-by-step derivation
                                            1. *-commutativeN/A

                                              \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(maxCos + \frac{1}{ux}\right) - 1\right) \cdot ux\right)}} \]
                                            2. lower-*.f32N/A

                                              \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(maxCos + \frac{1}{ux}\right) - 1\right) \cdot ux\right)}} \]
                                            3. lower--.f32N/A

                                              \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\color{blue}{\left(\left(maxCos + \frac{1}{ux}\right) - 1\right)} \cdot ux\right)} \]
                                            4. +-commutativeN/A

                                              \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\color{blue}{\left(\frac{1}{ux} + maxCos\right)} - 1\right) \cdot ux\right)} \]
                                            5. lower-+.f32N/A

                                              \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\color{blue}{\left(\frac{1}{ux} + maxCos\right)} - 1\right) \cdot ux\right)} \]
                                            6. lower-/.f3276.1

                                              \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\left(\color{blue}{\frac{1}{ux}} + maxCos\right) - 1\right) \cdot ux\right)} \]
                                          4. Applied rewrites76.1%

                                            \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right)}} \]
                                          5. Step-by-step derivation
                                            1. lift-*.f32N/A

                                              \[\leadsto \color{blue}{1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right)}} \]
                                            2. *-commutativeN/A

                                              \[\leadsto \color{blue}{\sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right)} \cdot 1} \]
                                            3. lower-*.f3276.1

                                              \[\leadsto \color{blue}{\sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right)} \cdot 1} \]
                                          6. Applied rewrites73.5%

                                            \[\leadsto \color{blue}{\sqrt{1 - \left(1 + \left(maxCos - 1\right) \cdot ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)} \cdot 1} \]
                                        5. Recombined 2 regimes into one program.
                                        6. Final simplification73.9%

                                          \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\left(maxCos - 1\right) \cdot ux + 1\right)} \cdot 1\\ \end{array} \]
                                        7. Add Preprocessing

                                        Alternative 10: 71.1% accurate, 3.5× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\ \end{array} \end{array} \]
                                        (FPCore (ux uy maxCos)
                                         :precision binary32
                                         (if (<= ux 0.0001500000071246177)
                                           (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
                                           (* (sqrt (- 1.0 (* (- 1.0 ux) (+ (* maxCos ux) (- 1.0 ux))))) 1.0)))
                                        float code(float ux, float uy, float maxCos) {
                                        	float tmp;
                                        	if (ux <= 0.0001500000071246177f) {
                                        		tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
                                        	} else {
                                        		tmp = sqrtf((1.0f - ((1.0f - ux) * ((maxCos * ux) + (1.0f - ux))))) * 1.0f;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        function code(ux, uy, maxCos)
                                        	tmp = Float32(0.0)
                                        	if (ux <= Float32(0.0001500000071246177))
                                        		tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0));
                                        	else
                                        		tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) - ux) * Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux))))) * Float32(1.0));
                                        	end
                                        	return tmp
                                        end
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \begin{array}{l}
                                        \mathbf{if}\;ux \leq 0.0001500000071246177:\\
                                        \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
                                        
                                        \mathbf{else}:\\
                                        \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\
                                        
                                        
                                        \end{array}
                                        \end{array}
                                        
                                        Derivation
                                        1. Split input into 2 regimes
                                        2. if ux < 1.50000007e-4

                                          1. Initial program 34.3%

                                            \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in uy around 0

                                            \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                          4. Step-by-step derivation
                                            1. Applied rewrites31.9%

                                              \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                            2. Taylor expanded in ux around 0

                                              \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
                                            3. Step-by-step derivation
                                              1. cancel-sign-sub-invN/A

                                                \[\leadsto 1 \cdot \sqrt{ux \cdot \color{blue}{\left(2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}} \]
                                              2. metadata-evalN/A

                                                \[\leadsto 1 \cdot \sqrt{ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)} \]
                                              3. *-commutativeN/A

                                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                              4. lower-*.f32N/A

                                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                              5. +-commutativeN/A

                                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(-2 \cdot maxCos + 2\right)} \cdot ux} \]
                                              6. lower-fma.f3273.6

                                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} \cdot ux} \]
                                            4. Applied rewrites73.2%

                                              \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}} \]

                                            if 1.50000007e-4 < ux

                                            1. Initial program 89.9%

                                              \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in uy around 0

                                              \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                            4. Step-by-step derivation
                                              1. Applied rewrites75.6%

                                                \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                              2. Taylor expanded in maxCos around 0

                                                \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
                                              3. Step-by-step derivation
                                                1. lower--.f3274.2

                                                  \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
                                              4. Applied rewrites74.2%

                                                \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
                                            5. Recombined 2 regimes into one program.
                                            6. Final simplification73.8%

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\ \end{array} \]
                                            7. Add Preprocessing

                                            Alternative 11: 61.8% accurate, 5.8× speedup?

                                            \[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1 \end{array} \]
                                            (FPCore (ux uy maxCos)
                                             :precision binary32
                                             (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0))
                                            float code(float ux, float uy, float maxCos) {
                                            	return sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
                                            }
                                            
                                            function code(ux, uy, maxCos)
                                            	return Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0))
                                            end
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1
                                            \end{array}
                                            
                                            Derivation
                                            1. Initial program 56.3%

                                              \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in uy around 0

                                              \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                            4. Step-by-step derivation
                                              1. Applied rewrites49.2%

                                                \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                              2. Taylor expanded in ux around 0

                                                \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
                                              3. Step-by-step derivation
                                                1. cancel-sign-sub-invN/A

                                                  \[\leadsto 1 \cdot \sqrt{ux \cdot \color{blue}{\left(2 + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}} \]
                                                2. metadata-evalN/A

                                                  \[\leadsto 1 \cdot \sqrt{ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)} \]
                                                3. *-commutativeN/A

                                                  \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                                4. lower-*.f32N/A

                                                  \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
                                                5. +-commutativeN/A

                                                  \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(-2 \cdot maxCos + 2\right)} \cdot ux} \]
                                                6. lower-fma.f3261.1

                                                  \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} \cdot ux} \]
                                              4. Applied rewrites62.6%

                                                \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}} \]
                                              5. Final simplification59.4%

                                                \[\leadsto \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1 \]
                                              6. Add Preprocessing

                                              Alternative 12: 19.7% accurate, 7.1× speedup?

                                              \[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot 1 \end{array} \]
                                              (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (fma -1.0 1.0 1.0)) 1.0))
                                              float code(float ux, float uy, float maxCos) {
                                              	return sqrtf(fmaf(-1.0f, 1.0f, 1.0f)) * 1.0f;
                                              }
                                              
                                              function code(ux, uy, maxCos)
                                              	return Float32(sqrt(fma(Float32(-1.0), Float32(1.0), Float32(1.0))) * Float32(1.0))
                                              end
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot 1
                                              \end{array}
                                              
                                              Derivation
                                              1. Initial program 56.3%

                                                \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in uy around 0

                                                \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                              4. Step-by-step derivation
                                                1. Applied rewrites49.2%

                                                  \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                2. Taylor expanded in ux around 0

                                                  \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{1}} \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites6.6%

                                                    \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{1}} \]
                                                  2. Step-by-step derivation
                                                    1. lift--.f32N/A

                                                      \[\leadsto 1 \cdot \sqrt{\color{blue}{1 - 1}} \]
                                                    2. sub-negN/A

                                                      \[\leadsto 1 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left(1\right)\right)}} \]
                                                    3. +-commutativeN/A

                                                      \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(1\right)\right) + 1}} \]
                                                    4. neg-mul-1N/A

                                                      \[\leadsto 1 \cdot \sqrt{\color{blue}{-1 \cdot 1} + 1} \]
                                                    5. lower-fma.f3219.4

                                                      \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-1, 1, 1\right)}} \]
                                                  3. Applied rewrites20.0%

                                                    \[\leadsto 1 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-1, 1, 1\right)}} \]
                                                  4. Final simplification19.9%

                                                    \[\leadsto \sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot 1 \]
                                                  5. Add Preprocessing

                                                  Alternative 13: 6.6% accurate, 8.2× speedup?

                                                  \[\begin{array}{l} \\ \sqrt{1 - 1} \cdot 1 \end{array} \]
                                                  (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 1.0)) 1.0))
                                                  float code(float ux, float uy, float maxCos) {
                                                  	return sqrtf((1.0f - 1.0f)) * 1.0f;
                                                  }
                                                  
                                                  real(4) function code(ux, uy, maxcos)
                                                      real(4), intent (in) :: ux
                                                      real(4), intent (in) :: uy
                                                      real(4), intent (in) :: maxcos
                                                      code = sqrt((1.0e0 - 1.0e0)) * 1.0e0
                                                  end function
                                                  
                                                  function code(ux, uy, maxCos)
                                                  	return Float32(sqrt(Float32(Float32(1.0) - Float32(1.0))) * Float32(1.0))
                                                  end
                                                  
                                                  function tmp = code(ux, uy, maxCos)
                                                  	tmp = sqrt((single(1.0) - single(1.0))) * single(1.0);
                                                  end
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  \sqrt{1 - 1} \cdot 1
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Initial program 56.3%

                                                    \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in uy around 0

                                                    \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                  4. Step-by-step derivation
                                                    1. Applied rewrites49.2%

                                                      \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                    2. Taylor expanded in ux around 0

                                                      \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{1}} \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites6.6%

                                                        \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{1}} \]
                                                      2. Final simplification6.6%

                                                        \[\leadsto \sqrt{1 - 1} \cdot 1 \]
                                                      3. Add Preprocessing

                                                      Reproduce

                                                      ?
                                                      herbie shell --seed 2024276 
                                                      (FPCore (ux uy maxCos)
                                                        :name "UniformSampleCone, x"
                                                        :precision binary32
                                                        :pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
                                                        (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))