UniformSampleCone, x

Percentage Accurate: 57.1% → 98.8%
Time: 12.1s
Alternatives: 15
Speedup: 7.1×

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.1% 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.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 55.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 2: 87.4% accurate, 0.5× speedup?

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

      1. Initial program 30.6%

        \[\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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        11. lower-PI.f3223.1

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

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

          \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negN/A

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

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

          \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}\right)\right) + 1} \]
        5. distribute-rgt-neg-inN/A

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

          \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)}} \]
        7. lift-+.f32N/A

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

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

          \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
        10. +-commutativeN/A

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

          \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
        12. lower-neg.f3215.3

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right), -\color{blue}{\left(maxCos \cdot ux + \left(1 - ux\right)\right)}, 1\right)} \]
        17. lift-fma.f3215.3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(\left(1 - \left(maxCos - 1\right)\right) - maxCos\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
        15. lower-PI.f3294.2

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

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

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

      1. Initial program 83.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\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. Taylor expanded in uy around 0

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

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

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

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

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

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

            \[\leadsto \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}} \]
          7. lower-fma.f3272.5

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

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

          \[\leadsto \sqrt{{ux}^{2} \cdot \left(2 \cdot \frac{1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right)} \]
        6. Step-by-step derivation
          1. Applied rewrites82.8%

            \[\leadsto \sqrt{\left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \]
        7. Recombined 2 regimes into one program.
        8. Final simplification88.8%

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

        Alternative 3: 86.6% accurate, 0.5× speedup?

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

          1. Initial program 38.0%

            \[\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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
            11. lower-PI.f3230.6

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

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
            2. sub-negN/A

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

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}\right)\right) + 1} \]
            5. distribute-rgt-neg-inN/A

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)}} \]
            7. lift-+.f32N/A

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

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
            12. lower-neg.f3216.1

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right), -\color{blue}{\left(maxCos \cdot ux + \left(1 - ux\right)\right)}, 1\right)} \]
            17. lift-fma.f3216.1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \sqrt{\left(\left(1 - \left(maxCos - 1\right)\right) - maxCos\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
            15. lower-PI.f3290.7

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

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

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

          1. Initial program 88.9%

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

            \[\leadsto \color{blue}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
            11. lower-PI.f3280.9

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

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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--.f3280.9

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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)} \]
          7. Applied rewrites80.5%

            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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)} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification87.3%

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

        Alternative 4: 83.3% accurate, 0.5× speedup?

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

          1. Initial program 38.0%

            \[\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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
            11. lower-PI.f3230.6

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \]
            3. Step-by-step derivation
              1. lower-cos.f32N/A

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

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

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

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

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

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

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

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

            1. Initial program 88.9%

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

              \[\leadsto \color{blue}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
              11. lower-PI.f3280.9

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

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

                \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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--.f3280.9

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

                \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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)} \]
            7. Applied rewrites80.5%

              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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)} \]
          11. Recombined 2 regimes into one program.
          12. Final simplification67.2%

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

          Alternative 5: 98.8% accurate, 0.6× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \mathbf{if}\;maxCos \leq 2.499999990010493 \cdot 10^{-12}:\\ \;\;\;\;\sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\left(\frac{\frac{\frac{2}{ux} - 1}{maxCos}}{maxCos} - \left(1 - \frac{2 - \frac{2}{ux}}{maxCos}\right)\right) \cdot \left(ux \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)))))
             (if (<= maxCos 2.499999990010493e-12)
               (*
                (sqrt (* (- (fma -2.0 maxCos 2.0) (* (pow (- maxCos 1.0) 2.0) ux)) ux))
                t_0)
               (*
                (sqrt
                 (*
                  (* maxCos maxCos)
                  (*
                   (-
                    (/ (/ (- (/ 2.0 ux) 1.0) maxCos) maxCos)
                    (- 1.0 (/ (- 2.0 (/ 2.0 ux)) 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)\\
          \mathbf{if}\;maxCos \leq 2.499999990010493 \cdot 10^{-12}:\\
          \;\;\;\;\sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux} \cdot t\_0\\
          
          \mathbf{else}:\\
          \;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\left(\frac{\frac{\frac{2}{ux} - 1}{maxCos}}{maxCos} - \left(1 - \frac{2 - \frac{2}{ux}}{maxCos}\right)\right) \cdot \left(ux \cdot ux\right)\right)} \cdot t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if maxCos < 2.49999999e-12

            1. Initial program 56.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if 2.49999999e-12 < maxCos

              1. Initial program 54.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\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. Taylor expanded in maxCos around inf

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

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

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

                Alternative 6: 98.7% 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 := \frac{2}{ux} - 1\\ \mathbf{if}\;maxCos \leq 6.000000052353016 \cdot 10^{-9}:\\ \;\;\;\;\sqrt{t\_1 \cdot \left(ux \cdot ux\right)} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\left(\frac{\frac{t\_1}{maxCos}}{maxCos} - \left(1 - \frac{2 - \frac{2}{ux}}{maxCos}\right)\right) \cdot \left(ux \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 (- (/ 2.0 ux) 1.0)))
                   (if (<= maxCos 6.000000052353016e-9)
                     (* (sqrt (* t_1 (* ux ux))) t_0)
                     (*
                      (sqrt
                       (*
                        (* maxCos maxCos)
                        (*
                         (- (/ (/ t_1 maxCos) maxCos) (- 1.0 (/ (- 2.0 (/ 2.0 ux)) 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 := \frac{2}{ux} - 1\\
                \mathbf{if}\;maxCos \leq 6.000000052353016 \cdot 10^{-9}:\\
                \;\;\;\;\sqrt{t\_1 \cdot \left(ux \cdot ux\right)} \cdot t\_0\\
                
                \mathbf{else}:\\
                \;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\left(\frac{\frac{t\_1}{maxCos}}{maxCos} - \left(1 - \frac{2 - \frac{2}{ux}}{maxCos}\right)\right) \cdot \left(ux \cdot ux\right)\right)} \cdot t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if maxCos < 6.00000005e-9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if 6.00000005e-9 < maxCos

                    1. Initial program 52.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. lower-fma.f32N/A

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

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

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

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

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

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

                        \[\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. Taylor expanded in maxCos around inf

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

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

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

                      Alternative 7: 89.8% accurate, 0.8× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-1 + ux\right) - maxCos \cdot ux\\ \mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.00019999999494757503:\\ \;\;\;\;\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{\left(\left(1 - \left(maxCos - 1\right)\right) - maxCos\right) \cdot ux}\\ \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} \end{array} \]
                      (FPCore (ux uy maxCos)
                       :precision binary32
                       (let* ((t_0 (- (+ -1.0 ux) (* maxCos ux))))
                         (if (<= (- 1.0 (* t_0 t_0)) 0.00019999999494757503)
                           (*
                            (cos (* (* (PI) uy) 2.0))
                            (sqrt (* (- (- 1.0 (- maxCos 1.0)) maxCos) ux)))
                           (*
                            (sqrt (- 1.0 (* (- 1.0 ux) (- (* maxCos ux) (+ -1.0 ux)))))
                            (cos (* (PI) (* 2.0 uy)))))))
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := \left(-1 + ux\right) - maxCos \cdot ux\\
                      \mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.00019999999494757503:\\
                      \;\;\;\;\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{\left(\left(1 - \left(maxCos - 1\right)\right) - maxCos\right) \cdot ux}\\
                      
                      \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}
                      \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)))) < 1.99999995e-4

                        1. Initial program 34.0%

                          \[\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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                          11. lower-PI.f3230.3

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

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

                            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                          2. sub-negN/A

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

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

                            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}\right)\right) + 1} \]
                          5. distribute-rgt-neg-inN/A

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

                            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)}} \]
                          7. lift-+.f32N/A

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

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

                            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                          10. +-commutativeN/A

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

                            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                          12. lower-neg.f3216.4

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

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

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

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

                            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right), -\color{blue}{\left(maxCos \cdot ux + \left(1 - ux\right)\right)}, 1\right)} \]
                          17. lift-fma.f3216.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \sqrt{\left(\left(1 - \left(maxCos - 1\right)\right) - maxCos\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
                          15. lower-PI.f3293.3

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

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

                        if 1.99999995e-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 87.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 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--.f3282.8

                            \[\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 rewrites82.8%

                          \[\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 simplification89.0%

                        \[\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.00019999999494757503:\\ \;\;\;\;\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{\left(\left(1 - \left(maxCos - 1\right)\right) - maxCos\right) \cdot ux}\\ \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 8: 95.5% accurate, 1.0× speedup?

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

                        1. Initial program 57.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          if 2.49999994e-5 < maxCos

                          1. Initial program 47.3%

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

                            \[\leadsto \color{blue}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            11. lower-PI.f3238.2

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                            2. sub-negN/A

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}\right)\right) + 1} \]
                            5. distribute-rgt-neg-inN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)}} \]
                            7. lift-+.f32N/A

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                            10. +-commutativeN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                            12. lower-neg.f3217.8

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right), -\color{blue}{\left(maxCos \cdot ux + \left(1 - ux\right)\right)}, 1\right)} \]
                            17. lift-fma.f3217.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \sqrt{\left(\left(1 - \left(maxCos - 1\right)\right) - maxCos\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
                            15. lower-PI.f3280.2

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

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

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

                        Alternative 9: 75.2% accurate, 2.1× speedup?

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

                          1. Initial program 34.0%

                            \[\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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            11. lower-PI.f3230.3

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                            2. sub-negN/A

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}\right)\right) + 1} \]
                            5. distribute-rgt-neg-inN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)}} \]
                            7. lift-+.f32N/A

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                            10. +-commutativeN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                            12. lower-neg.f3216.4

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right), -\color{blue}{\left(maxCos \cdot ux + \left(1 - ux\right)\right)}, 1\right)} \]
                            17. lift-fma.f3216.4

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)} \cdot ux} \]
                            4. mul-1-negN/A

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right)}\right) - maxCos\right) \cdot ux} \]
                            5. unsub-negN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\color{blue}{\left(1 - \left(maxCos - 1\right)\right)} - maxCos\right) \cdot ux} \]
                            7. lower--.f3273.1

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

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

                          if 9.99999975e-5 < ux

                          1. Initial program 87.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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            11. lower-PI.f3274.1

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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--.f3274.1

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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 \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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-*.f3274.1

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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)} \]
                          7. Applied rewrites74.1%

                            \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\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)} \]
                        3. Recombined 2 regimes into one program.
                        4. Final simplification73.5%

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

                        Alternative 10: 75.2% accurate, 2.1× speedup?

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

                          1. Initial program 34.0%

                            \[\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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            11. lower-PI.f3230.3

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                            2. sub-negN/A

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}\right)\right) + 1} \]
                            5. distribute-rgt-neg-inN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)}} \]
                            7. lift-+.f32N/A

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                            10. +-commutativeN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                            12. lower-neg.f3216.4

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right), -\color{blue}{\left(maxCos \cdot ux + \left(1 - ux\right)\right)}, 1\right)} \]
                            17. lift-fma.f3216.4

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)} \cdot ux} \]
                            4. mul-1-negN/A

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right)}\right) - maxCos\right) \cdot ux} \]
                            5. unsub-negN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\color{blue}{\left(1 - \left(maxCos - 1\right)\right)} - maxCos\right) \cdot ux} \]
                            7. lower--.f3273.1

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

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

                          if 9.99999975e-5 < ux

                          1. Initial program 87.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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            11. lower-PI.f3274.1

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

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

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

                        Alternative 11: 75.2% accurate, 2.7× speedup?

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

                          1. Initial program 34.0%

                            \[\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}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            11. lower-PI.f3230.3

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
                            2. sub-negN/A

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}\right)\right) + 1} \]
                            5. distribute-rgt-neg-inN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)}} \]
                            7. lift-+.f32N/A

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                            10. +-commutativeN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1 - ux\right)}, \mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right), 1\right)} \]
                            12. lower-neg.f3216.4

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right), -\color{blue}{\left(maxCos \cdot ux + \left(1 - ux\right)\right)}, 1\right)} \]
                            17. lift-fma.f3216.4

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{\left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)} \cdot ux} \]
                            4. mul-1-negN/A

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right)}\right) - maxCos\right) \cdot ux} \]
                            5. unsub-negN/A

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

                              \[\leadsto \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\color{blue}{\left(1 - \left(maxCos - 1\right)\right)} - maxCos\right) \cdot ux} \]
                            7. lower--.f3273.1

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

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

                          if 9.99999975e-5 < ux

                          1. Initial program 87.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\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. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

                              \[\leadsto \color{blue}{\sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}} \]
                            5. Step-by-step derivation
                              1. Applied rewrites74.1%

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

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

                            Alternative 12: 71.6% accurate, 2.9× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(ux, maxCos, 1\right) - ux\\ \mathbf{if}\;maxCos \cdot ux - \left(-1 + ux\right) \leq 0.9998999834060669:\\ \;\;\;\;\sqrt{1 - t\_0 \cdot t\_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\ \end{array} \end{array} \]
                            (FPCore (ux uy maxCos)
                             :precision binary32
                             (let* ((t_0 (- (fma ux maxCos 1.0) ux)))
                               (if (<= (- (* maxCos ux) (+ -1.0 ux)) 0.9998999834060669)
                                 (sqrt (- 1.0 (* t_0 t_0)))
                                 (sqrt (* (fma -2.0 maxCos 2.0) ux)))))
                            float code(float ux, float uy, float maxCos) {
                            	float t_0 = fmaf(ux, maxCos, 1.0f) - ux;
                            	float tmp;
                            	if (((maxCos * ux) - (-1.0f + ux)) <= 0.9998999834060669f) {
                            		tmp = sqrtf((1.0f - (t_0 * t_0)));
                            	} else {
                            		tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux));
                            	}
                            	return tmp;
                            }
                            
                            function code(ux, uy, maxCos)
                            	t_0 = Float32(fma(ux, maxCos, Float32(1.0)) - ux)
                            	tmp = Float32(0.0)
                            	if (Float32(Float32(maxCos * ux) - Float32(Float32(-1.0) + ux)) <= Float32(0.9998999834060669))
                            		tmp = sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0)));
                            	else
                            		tmp = sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux));
                            	end
                            	return tmp
                            end
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \mathsf{fma}\left(ux, maxCos, 1\right) - ux\\
                            \mathbf{if}\;maxCos \cdot ux - \left(-1 + ux\right) \leq 0.9998999834060669:\\
                            \;\;\;\;\sqrt{1 - t\_0 \cdot t\_0}\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
                            
                            
                            \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 87.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\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. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

                                  \[\leadsto \color{blue}{\sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}} \]
                                5. Step-by-step derivation
                                  1. Applied rewrites59.2%

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

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

                                  1. Initial program 34.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\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. Taylor expanded in uy around 0

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

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

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

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

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

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

                                        \[\leadsto \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}} \]
                                      7. lower-fma.f3229.9

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

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

                                      \[\leadsto \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \]
                                    6. Step-by-step derivation
                                      1. Applied rewrites68.8%

                                        \[\leadsto \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \]
                                    7. Recombined 2 regimes into one program.
                                    8. Final simplification69.9%

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

                                    Alternative 13: 73.0% accurate, 3.3× speedup?

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

                                      1. Initial program 34.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          \[\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. Taylor expanded in uy around 0

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

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

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

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

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

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

                                            \[\leadsto \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}} \]
                                          7. lower-fma.f3229.9

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

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

                                          \[\leadsto \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites68.8%

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

                                          if 9.99999975e-5 < ux

                                          1. Initial program 87.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              \[\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. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

                                              \[\leadsto \color{blue}{\sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}} \]
                                            5. Step-by-step derivation
                                              1. Applied rewrites74.1%

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

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

                                            Alternative 14: 62.0% accurate, 7.1× speedup?

                                            \[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \end{array} \]
                                            (FPCore (ux uy maxCos) :precision binary32 (sqrt (* (fma -2.0 maxCos 2.0) ux)))
                                            float code(float ux, float uy, float maxCos) {
                                            	return sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux));
                                            }
                                            
                                            function code(ux, uy, maxCos)
                                            	return sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux))
                                            end
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}
                                            \end{array}
                                            
                                            Derivation
                                            1. Initial program 55.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                \[\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. Taylor expanded in uy around 0

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

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

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

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

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

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

                                                  \[\leadsto \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}} \]
                                                7. lower-fma.f3246.4

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

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

                                                \[\leadsto \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \]
                                              6. Step-by-step derivation
                                                1. Applied rewrites61.0%

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

                                                Alternative 15: 6.6% accurate, 11.1× speedup?

                                                \[\begin{array}{l} \\ \sqrt{1 - 1} \end{array} \]
                                                (FPCore (ux uy maxCos) :precision binary32 (sqrt (- 1.0 1.0)))
                                                float code(float ux, float uy, float maxCos) {
                                                	return sqrtf((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))
                                                end function
                                                
                                                function code(ux, uy, maxCos)
                                                	return sqrt(Float32(Float32(1.0) - Float32(1.0)))
                                                end
                                                
                                                function tmp = code(ux, uy, maxCos)
                                                	tmp = sqrt((single(1.0) - single(1.0)));
                                                end
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \sqrt{1 - 1}
                                                \end{array}
                                                
                                                Derivation
                                                1. Initial program 55.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    \[\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. Taylor expanded in uy around 0

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

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

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

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

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

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

                                                      \[\leadsto \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}} \]
                                                    7. lower-fma.f3246.4

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

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

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

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

                                                    Reproduce

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