UniformSampleCone, x

Percentage Accurate: 57.2% → 98.8%
Time: 13.1s
Alternatives: 11
Speedup: 6.5×

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 11 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.2% 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.9× speedup?

\[\begin{array}{l} \\ \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - \left(\left(\left(\frac{2}{ux} + maxCos\right) - 1\right) \cdot maxCos - \left(maxCos - 1\right)\right)\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 ux)
     (- (* (- (+ (/ 2.0 ux) maxCos) 1.0) maxCos) (- maxCos 1.0)))))
  (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}

\\
\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - \left(\left(\left(\frac{2}{ux} + maxCos\right) - 1\right) \cdot maxCos - \left(maxCos - 1\right)\right)\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Derivation
  1. Initial program 55.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. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\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(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
    4. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(maxCos \cdot \left(\left(maxCos + 2 \cdot \frac{1}{ux}\right) - 1\right) - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)} \]
  9. 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}{ux} - \left(\left(\left(\frac{2}{ux} + maxCos\right) - 1\right) \cdot maxCos - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)} \]
    2. Final simplification98.7%

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

    Alternative 2: 98.1% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \sqrt{\left(\frac{2}{ux} - \left(\left(\frac{2}{ux} - 1\right) \cdot maxCos - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \end{array} \]
    (FPCore (ux uy maxCos)
     :precision binary32
     (*
      (sqrt
       (*
        (- (/ 2.0 ux) (- (* (- (/ 2.0 ux) 1.0) maxCos) (- maxCos 1.0)))
        (* ux ux)))
      (cos (* (PI) (* 2.0 uy)))))
    \begin{array}{l}
    
    \\
    \sqrt{\left(\frac{2}{ux} - \left(\left(\frac{2}{ux} - 1\right) \cdot maxCos - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
    \end{array}
    
    Derivation
    1. Initial program 55.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. Step-by-step derivation
      1. lift--.f32N/A

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

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

        \[\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(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      4. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 3: 97.5% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \sqrt{\left(\frac{2}{ux} - \left(\frac{maxCos}{ux} \cdot 2 - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \end{array} \]
      (FPCore (ux uy maxCos)
       :precision binary32
       (*
        (sqrt (* (- (/ 2.0 ux) (- (* (/ maxCos ux) 2.0) (- maxCos 1.0))) (* ux ux)))
        (cos (* (PI) (* 2.0 uy)))))
      \begin{array}{l}
      
      \\
      \sqrt{\left(\frac{2}{ux} - \left(\frac{maxCos}{ux} \cdot 2 - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
      \end{array}
      
      Derivation
      1. Initial program 55.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. Step-by-step derivation
        1. lift--.f32N/A

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

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

          \[\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(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        4. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 4: 96.4% accurate, 1.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.00019500000053085387:\\ \;\;\;\;\sqrt{\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux + \left(-2 \cdot maxCos\right) \cdot ux} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(2 - ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\ \end{array} \end{array} \]
        (FPCore (ux uy maxCos)
         :precision binary32
         (if (<= (* 2.0 uy) 0.00019500000053085387)
           (*
            (sqrt
             (+ (* (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) ux) (* (* -2.0 maxCos) ux)))
            1.0)
           (* (sqrt (* (- 2.0 ux) ux)) (cos (* (PI) (* 2.0 uy))))))
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;2 \cdot uy \leq 0.00019500000053085387:\\
        \;\;\;\;\sqrt{\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux + \left(-2 \cdot maxCos\right) \cdot ux} \cdot 1\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{\left(2 - ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f32 uy #s(literal 2 binary32)) < 1.95000001e-4

          1. Initial program 56.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}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
          4. Step-by-step derivation
            1. Applied rewrites56.0%

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

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

                \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{1}} \]
              2. Taylor expanded in ux around 0

                \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
              3. Applied rewrites33.5%

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

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

                if 1.95000001e-4 < (*.f32 uy #s(literal 2 binary32))

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

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

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

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

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

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

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

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

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

                    \[\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)}} \]
                  2. Taylor expanded in ux around 0

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

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

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

                  Alternative 5: 96.4% accurate, 1.1× speedup?

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

                    1. Initial program 56.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}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    4. Step-by-step derivation
                      1. Applied rewrites56.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if 1.95000001e-4 < (*.f32 uy #s(literal 2 binary32))

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

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

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

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

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

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

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

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

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

                          \[\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)}} \]
                        2. Taylor expanded in ux around 0

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux} \]
                        4. Recombined 2 regimes into one program.
                        5. Final simplification96.2%

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

                        Alternative 6: 89.6% accurate, 1.1× speedup?

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

                          1. Initial program 57.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\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)}} \]
                              2. Taylor expanded in ux around 0

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

                                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot 2} \]
                              4. Recombined 2 regimes into one program.
                              5. Final simplification89.2%

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

                              Alternative 7: 80.1% accurate, 3.4× speedup?

                              \[\begin{array}{l} \\ \sqrt{\left(\left(\left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) \cdot ux - \left(maxCos - 2\right)\right) - maxCos\right) \cdot ux} \cdot 1 \end{array} \]
                              (FPCore (ux uy maxCos)
                               :precision binary32
                               (*
                                (sqrt
                                 (*
                                  (- (- (* (* (- 1.0 maxCos) (- maxCos 1.0)) ux) (- maxCos 2.0)) maxCos)
                                  ux))
                                1.0))
                              float code(float ux, float uy, float maxCos) {
                              	return sqrtf(((((((1.0f - maxCos) * (maxCos - 1.0f)) * ux) - (maxCos - 2.0f)) - maxCos) * ux)) * 1.0f;
                              }
                              
                              real(4) function code(ux, uy, maxcos)
                                  real(4), intent (in) :: ux
                                  real(4), intent (in) :: uy
                                  real(4), intent (in) :: maxcos
                                  code = sqrt(((((((1.0e0 - maxcos) * (maxcos - 1.0e0)) * ux) - (maxcos - 2.0e0)) - maxcos) * ux)) * 1.0e0
                              end function
                              
                              function code(ux, uy, maxCos)
                              	return Float32(sqrt(Float32(Float32(Float32(Float32(Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos - Float32(1.0))) * ux) - Float32(maxCos - Float32(2.0))) - maxCos) * ux)) * Float32(1.0))
                              end
                              
                              function tmp = code(ux, uy, maxCos)
                              	tmp = sqrt(((((((single(1.0) - maxCos) * (maxCos - single(1.0))) * ux) - (maxCos - single(2.0))) - maxCos) * ux)) * single(1.0);
                              end
                              
                              \begin{array}{l}
                              
                              \\
                              \sqrt{\left(\left(\left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) \cdot ux - \left(maxCos - 2\right)\right) - maxCos\right) \cdot ux} \cdot 1
                              \end{array}
                              
                              Derivation
                              1. Initial program 55.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}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                              4. Step-by-step derivation
                                1. Applied rewrites46.2%

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

                                    \[\leadsto 1 \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. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto 1 \cdot \sqrt{\color{blue}{\left(\left(\left(2 - maxCos\right) + \left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right)\right) \cdot ux\right) - maxCos\right) \cdot ux}} \]
                                9. Final simplification76.0%

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

                                Alternative 8: 79.1% accurate, 3.6× speedup?

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

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

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

                                      \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{1}} \]
                                    2. Taylor expanded in ux around 0

                                      \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                                    3. Applied rewrites25.7%

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

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

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

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

                                      Alternative 9: 75.7% accurate, 6.5× speedup?

                                      \[\begin{array}{l} \\ \sqrt{\left(2 - ux\right) \cdot ux} \cdot 1 \end{array} \]
                                      (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- 2.0 ux) ux)) 1.0))
                                      float code(float ux, float uy, float maxCos) {
                                      	return sqrtf(((2.0f - ux) * ux)) * 1.0f;
                                      }
                                      
                                      real(4) function code(ux, uy, maxcos)
                                          real(4), intent (in) :: ux
                                          real(4), intent (in) :: uy
                                          real(4), intent (in) :: maxcos
                                          code = sqrt(((2.0e0 - ux) * ux)) * 1.0e0
                                      end function
                                      
                                      function code(ux, uy, maxCos)
                                      	return Float32(sqrt(Float32(Float32(Float32(2.0) - ux) * ux)) * Float32(1.0))
                                      end
                                      
                                      function tmp = code(ux, uy, maxCos)
                                      	tmp = sqrt(((single(2.0) - ux) * ux)) * single(1.0);
                                      end
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \sqrt{\left(2 - ux\right) \cdot ux} \cdot 1
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 55.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}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites46.2%

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

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

                                            \[\leadsto 1 \cdot \sqrt{1 - \color{blue}{1}} \]
                                          2. Taylor expanded in ux around 0

                                            \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                                          3. Applied rewrites25.7%

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

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

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

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

                                            Alternative 10: 19.9% accurate, 7.1× speedup?

                                            \[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot 1 \end{array} \]
                                            (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (fma -1.0 1.0 1.0)) 1.0))
                                            float code(float ux, float uy, float maxCos) {
                                            	return sqrtf(fmaf(-1.0f, 1.0f, 1.0f)) * 1.0f;
                                            }
                                            
                                            function code(ux, uy, maxCos)
                                            	return Float32(sqrt(fma(Float32(-1.0), Float32(1.0), Float32(1.0))) * Float32(1.0))
                                            end
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot 1
                                            \end{array}
                                            
                                            Derivation
                                            1. Initial program 55.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}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                            4. Step-by-step derivation
                                              1. Applied rewrites46.2%

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

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

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

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

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

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

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

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

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

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

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

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

                                                  Alternative 11: 6.6% accurate, 8.2× speedup?

                                                  \[\begin{array}{l} \\ \sqrt{1 - 1} \cdot 1 \end{array} \]
                                                  (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 1.0)) 1.0))
                                                  float code(float ux, float uy, float maxCos) {
                                                  	return sqrtf((1.0f - 1.0f)) * 1.0f;
                                                  }
                                                  
                                                  real(4) function code(ux, uy, maxcos)
                                                      real(4), intent (in) :: ux
                                                      real(4), intent (in) :: uy
                                                      real(4), intent (in) :: maxcos
                                                      code = sqrt((1.0e0 - 1.0e0)) * 1.0e0
                                                  end function
                                                  
                                                  function code(ux, uy, maxCos)
                                                  	return Float32(sqrt(Float32(Float32(1.0) - Float32(1.0))) * Float32(1.0))
                                                  end
                                                  
                                                  function tmp = code(ux, uy, maxCos)
                                                  	tmp = sqrt((single(1.0) - single(1.0))) * single(1.0);
                                                  end
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  \sqrt{1 - 1} \cdot 1
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Initial program 55.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}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                  4. Step-by-step derivation
                                                    1. Applied rewrites46.2%

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

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

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

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

                                                      Reproduce

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