UniformSampleCone, x

Percentage Accurate: 57.3% → 98.8%
Time: 11.9s
Alternatives: 14
Speedup: 5.8×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 57.3% accurate, 1.0× speedup?

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

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

Alternative 1: 98.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{\left(1 - ux\right) \cdot ux + ux}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\left(\frac{\frac{2}{maxCos}}{ux} + 2\right) - \left(\frac{2}{ux} - \frac{-1}{maxCos}\right)}{maxCos} \cdot \left(ux \cdot ux\right) - ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\


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

    1. Initial program 60.5%

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

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

        \[\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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
        6. cancel-sign-subN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \sqrt{ux + \left(1 - ux\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
        16. lower-PI.f3298.8

          \[\leadsto \sqrt{ux + \left(1 - ux\right) \cdot ux} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot uy\right) \cdot 2\right) \]
      6. Applied rewrites98.8%

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

      if 1.99999999e-8 < maxCos

      1. Initial program 58.1%

        \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. Add Preprocessing
      3. 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-*.f3256.3

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

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

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

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

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

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

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

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

          Alternative 2: 96.3% accurate, 0.6× speedup?

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

            1. Initial program 61.4%

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

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

                \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
              2. 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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
                6. cancel-sign-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                1. Initial program 59.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 3: 98.8% accurate, 0.6× speedup?

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

                      \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    2. Add Preprocessing
                    3. 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-*.f3270.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 rewrites70.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. Step-by-step derivation
                      1. Applied rewrites70.3%

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

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

                        Alternative 4: 89.2% accurate, 0.6× speedup?

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

                          1. Initial program 55.4%

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

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

                              \[\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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
                              6. cancel-sign-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              1. Initial program 61.8%

                                \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                              2. Add Preprocessing
                              3. Taylor expanded in 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 rewrites60.5%

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

                                    \[\leadsto 1 \cdot \sqrt{\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-rgt-inN/A

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

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

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

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

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

                                  \[\leadsto 1 \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}} \]
                                4. Taylor expanded in ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto 1 \cdot \sqrt{\left(\frac{2}{ux} - \left(\frac{maxCos}{ux} - \left(maxCos - 1\right)\right)\right) \cdot \color{blue}{\left(ux \cdot ux\right)} - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \]
                                  14. lower-*.f3294.6

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

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

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

                              Alternative 5: 98.9% accurate, 0.7× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;maxCos \leq 9.999999717180685 \cdot 10^{-10}:\\ \;\;\;\;\sqrt{\left(ux - ux \cdot ux\right) + ux} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\left(\frac{\frac{\left(\frac{2}{ux} - 1\right) \cdot ux}{maxCos} - \left(\frac{2}{ux} - 2\right) \cdot ux}{maxCos} - ux\right) \cdot \left(maxCos \cdot maxCos\right)\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 (<= maxCos 9.999999717180685e-10)
                                 (* (sqrt (+ (- ux (* ux ux)) ux)) (cos (* (* (PI) uy) 2.0)))
                                 (*
                                  (sqrt
                                   (*
                                    (*
                                     (-
                                      (/
                                       (- (/ (* (- (/ 2.0 ux) 1.0) ux) maxCos) (* (- (/ 2.0 ux) 2.0) ux))
                                       maxCos)
                                      ux)
                                     (* maxCos maxCos))
                                    ux))
                                  (cos (* (PI) (* 2.0 uy))))))
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;maxCos \leq 9.999999717180685 \cdot 10^{-10}:\\
                              \;\;\;\;\sqrt{\left(ux - ux \cdot ux\right) + ux} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\sqrt{\left(\left(\frac{\frac{\left(\frac{2}{ux} - 1\right) \cdot ux}{maxCos} - \left(\frac{2}{ux} - 2\right) \cdot ux}{maxCos} - ux\right) \cdot \left(maxCos \cdot maxCos\right)\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 maxCos < 9.99999972e-10

                                1. Initial program 59.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 rewrites51.6%

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

                                      \[\leadsto 1 \cdot \sqrt{\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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
                                    6. cancel-sign-subN/A

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \sqrt{ux + \left(1 - ux\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
                                    16. lower-PI.f3298.8

                                      \[\leadsto \sqrt{ux + \left(1 - ux\right) \cdot ux} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot uy\right) \cdot 2\right) \]
                                  6. Applied rewrites98.8%

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

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

                                    if 9.99999972e-10 < maxCos

                                    1. Initial program 61.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      Alternative 6: 98.9% accurate, 0.7× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;maxCos \leq 2.2000000043931323 \cdot 10^{-8}:\\ \;\;\;\;\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{\left(1 - ux\right) \cdot ux + ux}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\left(\left(\frac{\frac{2}{ux} - 1}{maxCos \cdot maxCos} - \frac{\frac{2}{ux} - 2}{maxCos}\right) \cdot ux - ux\right) \cdot \left(maxCos \cdot maxCos\right)\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 (<= maxCos 2.2000000043931323e-8)
                                         (* (cos (* (* (PI) uy) 2.0)) (sqrt (+ (* (- 1.0 ux) ux) ux)))
                                         (*
                                          (sqrt
                                           (*
                                            (*
                                             (-
                                              (*
                                               (-
                                                (/ (- (/ 2.0 ux) 1.0) (* maxCos maxCos))
                                                (/ (- (/ 2.0 ux) 2.0) maxCos))
                                               ux)
                                              ux)
                                             (* maxCos maxCos))
                                            ux))
                                          (cos (* (PI) (* 2.0 uy))))))
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;maxCos \leq 2.2000000043931323 \cdot 10^{-8}:\\
                                      \;\;\;\;\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{\left(1 - ux\right) \cdot ux + ux}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\sqrt{\left(\left(\left(\frac{\frac{2}{ux} - 1}{maxCos \cdot maxCos} - \frac{\frac{2}{ux} - 2}{maxCos}\right) \cdot ux - ux\right) \cdot \left(maxCos \cdot maxCos\right)\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 maxCos < 2.2e-8

                                        1. Initial program 60.5%

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

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

                                            \[\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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
                                            6. cancel-sign-subN/A

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \sqrt{ux + \left(1 - ux\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
                                            16. lower-PI.f3298.8

                                              \[\leadsto \sqrt{ux + \left(1 - ux\right) \cdot ux} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot uy\right) \cdot 2\right) \]
                                          6. Applied rewrites98.8%

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

                                          if 2.2e-8 < maxCos

                                          1. Initial program 58.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-*.f3255.3

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

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

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

                                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left({maxCos}^{2} \cdot \left(-1 \cdot ux + \left(\frac{ux \cdot \left(2 - 2 \cdot \frac{1}{ux}\right)}{maxCos} + \frac{ux \cdot \left(2 \cdot \frac{1}{ux} - 1\right)}{{maxCos}^{2}}\right)\right)\right) \cdot ux} \]
                                            3. 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(\left(ux \cdot \left(\frac{\frac{2}{ux} - 1}{maxCos \cdot maxCos} + \frac{2 - \frac{2}{ux}}{maxCos}\right) - ux\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot ux} \]
                                            4. Recombined 2 regimes into one program.
                                            5. Final simplification98.8%

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

                                            Alternative 7: 96.0% accurate, 1.1× speedup?

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

                                              1. Initial program 60.5%

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

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

                                                  \[\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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
                                                  6. cancel-sign-subN/A

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto \sqrt{ux + \left(1 - ux\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
                                                  16. lower-PI.f3298.4

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

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

                                                if 9.99999975e-6 < maxCos

                                                1. Initial program 56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  Alternative 8: 96.0% accurate, 1.1× speedup?

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

                                                    1. Initial program 60.5%

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

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

                                                        \[\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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                          \[\leadsto \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
                                                        6. cancel-sign-subN/A

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

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

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

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

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

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

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

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

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

                                                          \[\leadsto \sqrt{ux + \left(1 - ux\right) \cdot ux} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right) \]
                                                        16. lower-PI.f3298.4

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

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

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

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

                                                        if 9.99999975e-6 < maxCos

                                                        1. Initial program 56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                          Alternative 9: 79.3% accurate, 2.0× speedup?

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

                                                            \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                          2. Add Preprocessing
                                                          3. 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 rewrites52.4%

                                                              \[\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-rgt-inN/A

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

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

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

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

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

                                                              \[\leadsto 1 \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}} \]
                                                            4. Taylor expanded in ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                \[\leadsto 1 \cdot \sqrt{\left(\frac{2}{ux} - \left(\frac{maxCos}{ux} - \left(maxCos - 1\right)\right)\right) \cdot \color{blue}{\left(ux \cdot ux\right)} - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \]
                                                              14. lower-*.f3279.8

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

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

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

                                                            Alternative 10: 79.3% accurate, 2.3× speedup?

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

                                                              \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                            2. Add Preprocessing
                                                            3. 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 rewrites52.4%

                                                                \[\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-rgt-inN/A

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

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

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

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

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

                                                                \[\leadsto 1 \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}} \]
                                                              4. Taylor expanded in ux around -inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                  \[\leadsto 1 \cdot \sqrt{\left(\frac{2 - maxCos}{ux} - \left(1 - maxCos\right)\right) \cdot \color{blue}{\left(ux \cdot ux\right)} - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \]
                                                                20. lower-*.f3279.8

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

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

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

                                                              Alternative 11: 75.5% accurate, 5.8× speedup?

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

                                                                \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                              2. Add Preprocessing
                                                              3. 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 rewrites52.4%

                                                                  \[\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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                  \[\leadsto 1 \cdot \sqrt{\color{blue}{ux - -1 \cdot \left(ux \cdot \left(1 - ux\right)\right)}} \]
                                                                5. Step-by-step derivation
                                                                  1. associate-*r*N/A

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

                                                                    \[\leadsto 1 \cdot \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \]
                                                                  3. cancel-sign-subN/A

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

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

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

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

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

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

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

                                                                Alternative 12: 61.8% accurate, 5.8× speedup?

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

                                                                  \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                                2. Add Preprocessing
                                                                3. 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 rewrites52.4%

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

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

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

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

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

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

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

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

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

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

                                                                  Alternative 13: 30.4% accurate, 7.8× speedup?

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

                                                                    \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                                  2. Add Preprocessing
                                                                  3. 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 rewrites52.4%

                                                                      \[\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. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        \[\leadsto \sqrt{ux - \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot \left(1 - ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
                                                                      6. cancel-sign-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                                      2. Add Preprocessing
                                                                      3. 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 rewrites52.4%

                                                                          \[\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 2024268 
                                                                          (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)))))))