UniformSampleCone, x

Percentage Accurate: 57.3% → 98.8%
Time: 13.0s
Alternatives: 15
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 15 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.3% 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.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ t_1 := \left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux\\ \mathbf{if}\;maxCos \leq 4.5000000170603016 \cdot 10^{-8}:\\ \;\;\;\;\sqrt{t\_1} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{t\_1}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)} \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (cos (* (PI) (* 2.0 uy)))) (t_1 (* (* (- (/ 2.0 ux) 1.0) ux) ux)))
   (if (<= maxCos 4.5000000170603016e-8)
     (* (sqrt t_1) t_0)
     (*
      (sqrt
       (*
        (* maxCos maxCos)
        (- (/ (- (/ t_1 maxCos) (* (* (- 1.0 ux) ux) 2.0)) maxCos) (* ux ux))))
      t_0))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
t_1 := \left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux\\
\mathbf{if}\;maxCos \leq 4.5000000170603016 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{t\_1} \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{t\_1}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)} \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if maxCos < 4.50000002e-8

    1. Initial program 61.8%

      \[\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. *-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{maxCos \cdot -2} + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
      14. 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(maxCos, -2, 2\right)}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
      15. 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(maxCos, -2, 2\right)}{ux} - \color{blue}{{\left(maxCos - 1\right)}^{2}}\right) \cdot {ux}^{2}} \]
      16. lower--.f32N/A

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\left(2 \cdot \frac{1}{ux} - 1\right)}} \]
    7. 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(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot \color{blue}{ux}} \]

      if 4.50000002e-8 < maxCos

      1. Initial program 50.4%

        \[\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 maxCos around -inf

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{{maxCos}^{2} \cdot \left(-1 \cdot \frac{-1 \cdot \frac{1 - {\left(1 - ux\right)}^{2}}{maxCos} - -2 \cdot \left(ux \cdot \left(1 - ux\right)\right)}{maxCos} - {ux}^{2}\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(-1 \cdot \frac{-1 \cdot \frac{1 - {\left(1 - ux\right)}^{2}}{maxCos} - -2 \cdot \left(ux \cdot \left(1 - ux\right)\right)}{maxCos} - {ux}^{2}\right) \cdot {maxCos}^{2}}} \]
        2. lower-*.f32N/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\frac{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \]
      8. Recombined 2 regimes into one program.
      9. Final simplification98.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;maxCos \leq 4.5000000170603016 \cdot 10^{-8}:\\ \;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \end{array} \]
      10. Add Preprocessing

      Alternative 2: 98.8% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\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))))
        (cos (* (PI) (* 2.0 uy)))))
      \begin{array}{l}
      
      \\
      \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
      \end{array}
      
      Derivation
      1. Initial program 59.5%

        \[\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. *-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{maxCos \cdot -2} + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
        14. 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(maxCos, -2, 2\right)}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
        15. 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(maxCos, -2, 2\right)}{ux} - \color{blue}{{\left(maxCos - 1\right)}^{2}}\right) \cdot {ux}^{2}} \]
        16. lower--.f32N/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\frac{\mathsf{fma}\left(maxCos, -2, 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(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \]
        3. Add Preprocessing

        Alternative 3: 98.8% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{if}\;maxCos \leq 4.5000000170603016 \cdot 10^{-8}:\\ \;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\frac{\frac{\left(2 - ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_0\\ \end{array} \end{array} \]
        (FPCore (ux uy maxCos)
         :precision binary32
         (let* ((t_0 (cos (* (PI) (* 2.0 uy)))))
           (if (<= maxCos 4.5000000170603016e-8)
             (* (sqrt (* (* (- (/ 2.0 ux) 1.0) ux) ux)) t_0)
             (*
              (sqrt
               (*
                (-
                 (/ (- (/ (* (- 2.0 ux) ux) maxCos) (* (* (- 1.0 ux) ux) 2.0)) maxCos)
                 (* ux ux))
                (* maxCos maxCos)))
              t_0))))
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
        \mathbf{if}\;maxCos \leq 4.5000000170603016 \cdot 10^{-8}:\\
        \;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot t\_0\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{\left(\frac{\frac{\left(2 - ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if maxCos < 4.50000002e-8

          1. Initial program 61.8%

            \[\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. *-commutativeN/A

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{maxCos \cdot -2} + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
            14. 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(maxCos, -2, 2\right)}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
            15. 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(maxCos, -2, 2\right)}{ux} - \color{blue}{{\left(maxCos - 1\right)}^{2}}\right) \cdot {ux}^{2}} \]
            16. lower--.f32N/A

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

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

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

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

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\left(2 \cdot \frac{1}{ux} - 1\right)}} \]
          7. 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(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot \color{blue}{ux}} \]

            if 4.50000002e-8 < maxCos

            1. Initial program 50.4%

              \[\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 maxCos around -inf

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{{maxCos}^{2} \cdot \left(-1 \cdot \frac{-1 \cdot \frac{1 - {\left(1 - ux\right)}^{2}}{maxCos} - -2 \cdot \left(ux \cdot \left(1 - ux\right)\right)}{maxCos} - {ux}^{2}\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(-1 \cdot \frac{-1 \cdot \frac{1 - {\left(1 - ux\right)}^{2}}{maxCos} - -2 \cdot \left(ux \cdot \left(1 - ux\right)\right)}{maxCos} - {ux}^{2}\right) \cdot {maxCos}^{2}}} \]
              2. lower-*.f32N/A

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

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

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

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\frac{\left(2 - ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \]
            8. Recombined 2 regimes into one program.
            9. Final simplification98.8%

              \[\leadsto \begin{array}{l} \mathbf{if}\;maxCos \leq 4.5000000170603016 \cdot 10^{-8}:\\ \;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\frac{\frac{\left(2 - ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \end{array} \]
            10. Add Preprocessing

            Alternative 4: 86.7% accurate, 0.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ t_1 := \left(-1 + ux\right) - maxCos \cdot ux\\ \mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.0003600000054575503:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot t\_0\\ \end{array} \end{array} \]
            (FPCore (ux uy maxCos)
             :precision binary32
             (let* ((t_0 (cos (* (PI) (* 2.0 uy)))) (t_1 (- (+ -1.0 ux) (* maxCos ux))))
               (if (<= (- 1.0 (* t_1 t_1)) 0.0003600000054575503)
                 (* (sqrt (* (fma maxCos -2.0 2.0) ux)) t_0)
                 (* (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 (- ux (* maxCos ux)))))) t_0))))
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
            t_1 := \left(-1 + ux\right) - maxCos \cdot ux\\
            \mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.0003600000054575503:\\
            \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot t\_0\\
            
            \mathbf{else}:\\
            \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (-.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)))) < 3.60000005e-4

              1. Initial program 37.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 0

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

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

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

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

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

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

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{maxCos \cdot -2} + 2\right) \cdot ux} \]
                7. lower-fma.f3260.0

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

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

              if 3.60000005e-4 < (-.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 89.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{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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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--.f3289.5

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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-*.f3289.5

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

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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. Taylor expanded in maxCos around 0

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
              6. Step-by-step derivation
                1. lower--.f3285.0

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
              7. Applied rewrites85.0%

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
            3. Recombined 2 regimes into one program.
            4. Final simplification86.2%

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

            Alternative 5: 96.0% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux\\ \mathbf{if}\;maxCos \leq 1.9999999494757503 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{t\_0} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{t\_0}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)}\\ \end{array} \end{array} \]
            (FPCore (ux uy maxCos)
             :precision binary32
             (let* ((t_0 (* (* (- (/ 2.0 ux) 1.0) ux) ux)))
               (if (<= maxCos 1.9999999494757503e-5)
                 (* (sqrt t_0) (cos (* (PI) (* 2.0 uy))))
                 (*
                  1.0
                  (sqrt
                   (*
                    (* maxCos maxCos)
                    (-
                     (/ (- (/ t_0 maxCos) (* (* (- 1.0 ux) ux) 2.0)) maxCos)
                     (* ux ux))))))))
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux\\
            \mathbf{if}\;maxCos \leq 1.9999999494757503 \cdot 10^{-5}:\\
            \;\;\;\;\sqrt{t\_0} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;1 \cdot \sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{t\_0}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if maxCos < 1.99999995e-5

              1. Initial program 59.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 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. *-commutativeN/A

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{\color{blue}{maxCos \cdot -2} + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                14. 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(maxCos, -2, 2\right)}}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot {ux}^{2}} \]
                15. 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(maxCos, -2, 2\right)}{ux} - \color{blue}{{\left(maxCos - 1\right)}^{2}}\right) \cdot {ux}^{2}} \]
                16. lower--.f32N/A

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

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

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

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

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

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

                if 1.99999995e-5 < maxCos

                1. Initial program 56.7%

                  \[\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 maxCos around -inf

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{{maxCos}^{2} \cdot \left(-1 \cdot \frac{-1 \cdot \frac{1 - {\left(1 - ux\right)}^{2}}{maxCos} - -2 \cdot \left(ux \cdot \left(1 - ux\right)\right)}{maxCos} - {ux}^{2}\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(-1 \cdot \frac{-1 \cdot \frac{1 - {\left(1 - ux\right)}^{2}}{maxCos} - -2 \cdot \left(ux \cdot \left(1 - ux\right)\right)}{maxCos} - {ux}^{2}\right) \cdot {maxCos}^{2}}} \]
                  2. lower-*.f32N/A

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

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

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

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

                    \[\leadsto \color{blue}{1} \cdot \sqrt{\left(\frac{\frac{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \]
                  3. Step-by-step derivation
                    1. Applied rewrites85.5%

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;maxCos \leq 1.9999999494757503 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)}\\ \end{array} \]
                  6. Add Preprocessing

                  Alternative 6: 86.7% accurate, 1.0× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{if}\;ux \leq 0.00018000000272877514:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot ux - \left(-1 + ux\right)\right)} \cdot t\_0\\ \end{array} \end{array} \]
                  (FPCore (ux uy maxCos)
                   :precision binary32
                   (let* ((t_0 (cos (* (PI) (* 2.0 uy)))))
                     (if (<= ux 0.00018000000272877514)
                       (* (sqrt (* (fma maxCos -2.0 2.0) ux)) t_0)
                       (* (sqrt (- 1.0 (* (- 1.0 ux) (- (* maxCos ux) (+ -1.0 ux))))) t_0))))
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
                  \mathbf{if}\;ux \leq 0.00018000000272877514:\\
                  \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot t\_0\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot ux - \left(-1 + ux\right)\right)} \cdot t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if ux < 1.80000003e-4

                    1. Initial program 37.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 0

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

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

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

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

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

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{maxCos \cdot -2} + 2\right) \cdot ux} \]
                      7. lower-fma.f3260.0

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

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

                    if 1.80000003e-4 < ux

                    1. Initial program 89.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 maxCos around 0

                      \[\leadsto \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 \color{blue}{\left(1 - ux\right)}} \]
                    4. Step-by-step derivation
                      1. lower--.f3284.9

                        \[\leadsto \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 \color{blue}{\left(1 - ux\right)}} \]
                    5. Applied rewrites84.9%

                      \[\leadsto \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 \color{blue}{\left(1 - ux\right)}} \]
                  3. Recombined 2 regimes into one program.
                  4. Final simplification86.1%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.00018000000272877514:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(1 - ux\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)\\ \end{array} \]
                  5. Add Preprocessing

                  Alternative 7: 85.5% accurate, 1.1× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\ \;\;\;\;\sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \end{array} \end{array} \]
                  (FPCore (ux uy maxCos)
                   :precision binary32
                   (if (<= (* 2.0 uy) 0.00139999995008111)
                     (* (sqrt (* (- (/ 2.0 ux) 1.0) (* ux ux))) 1.0)
                     (* (sqrt (* (fma maxCos -2.0 2.0) ux)) (cos (* (PI) (* 2.0 uy))))))
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\
                  \;\;\;\;\sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot 1\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f32 uy #s(literal 2 binary32)) < 0.00139999995

                    1. Initial program 61.7%

                      \[\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 rewrites61.3%

                        \[\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(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                        3. +-commutativeN/A

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

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

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

                          \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}} \]
                        7. remove-double-divN/A

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

                          \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \frac{1}{\color{blue}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}}} \]
                        9. div-invN/A

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

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

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

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

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

                          \[\leadsto 1 \cdot \sqrt{1 - \frac{\color{blue}{maxCos \cdot ux} + \left(1 - ux\right)}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}} \]
                        15. lift-fma.f3258.2

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

                        \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\frac{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}}} \]
                      4. Taylor expanded in ux around inf

                        \[\leadsto 1 \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)}} \]
                      5. Applied rewrites90.0%

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

                        \[\leadsto 1 \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\left(2 \cdot \frac{1}{ux} - 1\right)}} \]
                      7. Step-by-step derivation
                        1. Applied rewrites90.1%

                          \[\leadsto 1 \cdot \sqrt{\left(\frac{2}{ux} - 1\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]

                        if 0.00139999995 < (*.f32 uy #s(literal 2 binary32))

                        1. Initial program 56.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 ux around 0

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

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

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

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

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

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{maxCos \cdot -2} + 2\right) \cdot ux} \]
                          7. lower-fma.f3222.5

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

                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux}} \]
                      8. Recombined 2 regimes into one program.
                      9. Final simplification83.8%

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

                      Alternative 8: 86.6% accurate, 1.1× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{if}\;ux \leq 0.00018000000272877514:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)} \cdot t\_0\\ \end{array} \end{array} \]
                      (FPCore (ux uy maxCos)
                       :precision binary32
                       (let* ((t_0 (cos (* (PI) (* 2.0 uy)))))
                         (if (<= ux 0.00018000000272877514)
                           (* (sqrt (* (fma maxCos -2.0 2.0) ux)) t_0)
                           (* (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux)))) t_0))))
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
                      \mathbf{if}\;ux \leq 0.00018000000272877514:\\
                      \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot t\_0\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)} \cdot t\_0\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if ux < 1.80000003e-4

                        1. Initial program 37.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 0

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

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

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

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

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

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{maxCos \cdot -2} + 2\right) \cdot ux} \]
                          7. lower-fma.f3260.0

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

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

                        if 1.80000003e-4 < ux

                        1. Initial program 89.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{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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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--.f3289.5

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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-*.f3289.5

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

                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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. Taylor expanded in maxCos around 0

                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
                        6. Step-by-step derivation
                          1. lower--.f3285.0

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
                        7. Applied rewrites85.0%

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

                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(1 - ux\right)} \cdot \left(1 - ux\right)} \]
                        9. Step-by-step derivation
                          1. lower--.f3284.4

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

                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(1 - ux\right)} \cdot \left(1 - ux\right)} \]
                      3. Recombined 2 regimes into one program.
                      4. Final simplification85.9%

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

                      Alternative 9: 79.9% accurate, 1.5× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{ux} - 1\\ \mathbf{if}\;maxCos \leq 1.999999943436137 \cdot 10^{-9}:\\ \;\;\;\;\sqrt{t\_0 \cdot \left(ux \cdot ux\right)} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{\left(t\_0 \cdot ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)}\\ \end{array} \end{array} \]
                      (FPCore (ux uy maxCos)
                       :precision binary32
                       (let* ((t_0 (- (/ 2.0 ux) 1.0)))
                         (if (<= maxCos 1.999999943436137e-9)
                           (* (sqrt (* t_0 (* ux ux))) 1.0)
                           (*
                            1.0
                            (sqrt
                             (*
                              (* maxCos maxCos)
                              (-
                               (/ (- (/ (* (* t_0 ux) ux) maxCos) (* (* (- 1.0 ux) ux) 2.0)) maxCos)
                               (* ux ux))))))))
                      float code(float ux, float uy, float maxCos) {
                      	float t_0 = (2.0f / ux) - 1.0f;
                      	float tmp;
                      	if (maxCos <= 1.999999943436137e-9f) {
                      		tmp = sqrtf((t_0 * (ux * ux))) * 1.0f;
                      	} else {
                      		tmp = 1.0f * sqrtf(((maxCos * maxCos) * ((((((t_0 * ux) * ux) / maxCos) - (((1.0f - ux) * ux) * 2.0f)) / maxCos) - (ux * ux))));
                      	}
                      	return tmp;
                      }
                      
                      real(4) function code(ux, uy, maxcos)
                          real(4), intent (in) :: ux
                          real(4), intent (in) :: uy
                          real(4), intent (in) :: maxcos
                          real(4) :: t_0
                          real(4) :: tmp
                          t_0 = (2.0e0 / ux) - 1.0e0
                          if (maxcos <= 1.999999943436137e-9) then
                              tmp = sqrt((t_0 * (ux * ux))) * 1.0e0
                          else
                              tmp = 1.0e0 * sqrt(((maxcos * maxcos) * ((((((t_0 * ux) * ux) / maxcos) - (((1.0e0 - ux) * ux) * 2.0e0)) / maxcos) - (ux * ux))))
                          end if
                          code = tmp
                      end function
                      
                      function code(ux, uy, maxCos)
                      	t_0 = Float32(Float32(Float32(2.0) / ux) - Float32(1.0))
                      	tmp = Float32(0.0)
                      	if (maxCos <= Float32(1.999999943436137e-9))
                      		tmp = Float32(sqrt(Float32(t_0 * Float32(ux * ux))) * Float32(1.0));
                      	else
                      		tmp = Float32(Float32(1.0) * sqrt(Float32(Float32(maxCos * maxCos) * Float32(Float32(Float32(Float32(Float32(Float32(t_0 * ux) * ux) / maxCos) - Float32(Float32(Float32(Float32(1.0) - ux) * ux) * Float32(2.0))) / maxCos) - Float32(ux * ux)))));
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(ux, uy, maxCos)
                      	t_0 = (single(2.0) / ux) - single(1.0);
                      	tmp = single(0.0);
                      	if (maxCos <= single(1.999999943436137e-9))
                      		tmp = sqrt((t_0 * (ux * ux))) * single(1.0);
                      	else
                      		tmp = single(1.0) * sqrt(((maxCos * maxCos) * ((((((t_0 * ux) * ux) / maxCos) - (((single(1.0) - ux) * ux) * single(2.0))) / maxCos) - (ux * ux))));
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := \frac{2}{ux} - 1\\
                      \mathbf{if}\;maxCos \leq 1.999999943436137 \cdot 10^{-9}:\\
                      \;\;\;\;\sqrt{t\_0 \cdot \left(ux \cdot ux\right)} \cdot 1\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;1 \cdot \sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{\left(t\_0 \cdot ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if maxCos < 1.99999994e-9

                        1. Initial program 61.4%

                          \[\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 rewrites51.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. 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(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                            3. +-commutativeN/A

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

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

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

                              \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}} \]
                            7. remove-double-divN/A

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

                              \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \frac{1}{\color{blue}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}}} \]
                            9. div-invN/A

                              \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\frac{\left(1 - ux\right) + ux \cdot maxCos}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}}} \]
                            10. lower-/.f3250.9

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

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

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

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

                              \[\leadsto 1 \cdot \sqrt{1 - \frac{\color{blue}{maxCos \cdot ux} + \left(1 - ux\right)}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}} \]
                            15. lift-fma.f3250.9

                              \[\leadsto 1 \cdot \sqrt{1 - \frac{\color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}} \]
                          3. Applied rewrites50.9%

                            \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\frac{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}}} \]
                          4. Taylor expanded in ux around inf

                            \[\leadsto 1 \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)}} \]
                          5. Applied rewrites75.9%

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

                            \[\leadsto 1 \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\left(2 \cdot \frac{1}{ux} - 1\right)}} \]
                          7. Step-by-step derivation
                            1. Applied rewrites76.2%

                              \[\leadsto 1 \cdot \sqrt{\left(\frac{2}{ux} - 1\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]

                            if 1.99999994e-9 < maxCos

                            1. Initial program 53.4%

                              \[\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 maxCos around -inf

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{{maxCos}^{2} \cdot \left(-1 \cdot \frac{-1 \cdot \frac{1 - {\left(1 - ux\right)}^{2}}{maxCos} - -2 \cdot \left(ux \cdot \left(1 - ux\right)\right)}{maxCos} - {ux}^{2}\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(-1 \cdot \frac{-1 \cdot \frac{1 - {\left(1 - ux\right)}^{2}}{maxCos} - -2 \cdot \left(ux \cdot \left(1 - ux\right)\right)}{maxCos} - {ux}^{2}\right) \cdot {maxCos}^{2}}} \]
                              2. lower-*.f32N/A

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

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

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

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

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

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

                                \[\leadsto \begin{array}{l} \mathbf{if}\;maxCos \leq 1.999999943436137 \cdot 10^{-9}:\\ \;\;\;\;\sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux}{maxCos} - \left(\left(1 - ux\right) \cdot ux\right) \cdot 2}{maxCos} - ux \cdot ux\right)}\\ \end{array} \]
                              6. Add Preprocessing

                              Alternative 10: 71.9% accurate, 2.8× speedup?

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

                                1. Initial program 88.7%

                                  \[\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{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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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--.f3288.9

                                    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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 \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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-*.f3288.9

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

                                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \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. Taylor expanded in maxCos around 0

                                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
                                6. Step-by-step derivation
                                  1. lower--.f3284.5

                                    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
                                7. Applied rewrites84.5%

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

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

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

                                  if 0.999899983 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))

                                  1. Initial program 36.4%

                                    \[\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 rewrites33.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.f3270.0

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

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

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

                                  Alternative 11: 71.9% accurate, 2.8× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := maxCos \cdot ux - \left(-1 + ux\right)\\ \mathbf{if}\;t\_0 \leq 0.9998999834060669:\\ \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_0} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\ \end{array} \end{array} \]
                                  (FPCore (ux uy maxCos)
                                   :precision binary32
                                   (let* ((t_0 (- (* maxCos ux) (+ -1.0 ux))))
                                     (if (<= t_0 0.9998999834060669)
                                       (* (sqrt (- 1.0 (* (- 1.0 ux) t_0))) 1.0)
                                       (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0))))
                                  float code(float ux, float uy, float maxCos) {
                                  	float t_0 = (maxCos * ux) - (-1.0f + ux);
                                  	float tmp;
                                  	if (t_0 <= 0.9998999834060669f) {
                                  		tmp = sqrtf((1.0f - ((1.0f - ux) * t_0))) * 1.0f;
                                  	} else {
                                  		tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 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 (t_0 <= Float32(0.9998999834060669))
                                  		tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) - ux) * t_0))) * Float32(1.0));
                                  	else
                                  		tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0));
                                  	end
                                  	return tmp
                                  end
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  t_0 := maxCos \cdot ux - \left(-1 + ux\right)\\
                                  \mathbf{if}\;t\_0 \leq 0.9998999834060669:\\
                                  \;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_0} \cdot 1\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999899983

                                    1. Initial program 88.7%

                                      \[\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 rewrites71.1%

                                        \[\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--.f3268.3

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

                                        \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(1 - ux\right)}} \]

                                      if 0.999899983 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))

                                      1. Initial program 36.4%

                                        \[\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 rewrites33.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.f3270.0

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

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

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

                                      Alternative 12: 75.7% accurate, 3.9× speedup?

                                      \[\begin{array}{l} \\ \sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot 1 \end{array} \]
                                      (FPCore (ux uy maxCos)
                                       :precision binary32
                                       (* (sqrt (* (- (/ 2.0 ux) 1.0) (* ux ux))) 1.0))
                                      float code(float ux, float uy, float maxCos) {
                                      	return sqrtf((((2.0f / ux) - 1.0f) * (ux * ux))) * 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((((2.0e0 / ux) - 1.0e0) * (ux * ux))) * 1.0e0
                                      end function
                                      
                                      function code(ux, uy, maxCos)
                                      	return Float32(sqrt(Float32(Float32(Float32(Float32(2.0) / ux) - Float32(1.0)) * Float32(ux * ux))) * Float32(1.0))
                                      end
                                      
                                      function tmp = code(ux, uy, maxCos)
                                      	tmp = sqrt((((single(2.0) / ux) - single(1.0)) * (ux * ux))) * single(1.0);
                                      end
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot 1
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 59.5%

                                        \[\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 rewrites50.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)} \]
                                        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(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                                          3. +-commutativeN/A

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

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

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

                                            \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}} \]
                                          7. remove-double-divN/A

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

                                            \[\leadsto 1 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \frac{1}{\color{blue}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}}} \]
                                          9. div-invN/A

                                            \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\frac{\left(1 - ux\right) + ux \cdot maxCos}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}}} \]
                                          10. lower-/.f3248.0

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

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

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

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

                                            \[\leadsto 1 \cdot \sqrt{1 - \frac{\color{blue}{maxCos \cdot ux} + \left(1 - ux\right)}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}} \]
                                          15. lift-fma.f3247.7

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

                                          \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{\frac{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}{\frac{1}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}}}} \]
                                        4. Taylor expanded in ux around inf

                                          \[\leadsto 1 \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)}} \]
                                        5. Applied rewrites72.2%

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

                                          \[\leadsto 1 \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\left(2 \cdot \frac{1}{ux} - 1\right)}} \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites72.5%

                                            \[\leadsto 1 \cdot \sqrt{\left(\frac{2}{ux} - 1\right) \cdot \color{blue}{\left(ux \cdot ux\right)}} \]
                                          2. Final simplification72.5%

                                            \[\leadsto \sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot 1 \]
                                          3. Add Preprocessing

                                          Alternative 13: 62.3% 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 59.5%

                                            \[\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 rewrites50.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)} \]
                                            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.f3259.0

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

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

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

                                            Alternative 14: 19.9% 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 59.5%

                                              \[\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 rewrites50.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)} \]
                                              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.f3220.3

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

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

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

                                                Alternative 15: 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 59.5%

                                                  \[\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 rewrites50.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)} \]
                                                  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 2024267 
                                                    (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)))))))