UniformSampleCone, x

Percentage Accurate: 57.5% → 98.8%
Time: 10.8s
Alternatives: 9
Speedup: 7.1×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 98.8% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 2: 98.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\sqrt{ux - \left(maxCos \cdot ux + ux \cdot \left(\left(maxCos - 1\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\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 - \left(maxCos \cdot ux + ux \cdot \left(\left(maxCos - 1\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \]
      7. Applied rewrites29.3%

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

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

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

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

        Alternative 3: 92.8% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 4: 58.0% accurate, 1.8× speedup?

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

          1. Initial program 73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 6.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. Step-by-step derivation
              1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \sqrt{ux - ux \cdot \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux, maxCos - 1, maxCos\right)} \]
              13. lower--.f3228.8

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

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

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

          Alternative 5: 30.4% accurate, 4.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 6: 48.0% accurate, 4.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(ux, maxCos, 1\right) - ux\\ \sqrt{1 - t\_0 \cdot t\_0} \end{array} \end{array} \]
          (FPCore (ux uy maxCos)
           :precision binary32
           (let* ((t_0 (- (fma ux maxCos 1.0) ux))) (sqrt (- 1.0 (* t_0 t_0)))))
          float code(float ux, float uy, float maxCos) {
          	float t_0 = fmaf(ux, maxCos, 1.0f) - ux;
          	return sqrtf((1.0f - (t_0 * t_0)));
          }
          
          function code(ux, uy, maxCos)
          	t_0 = Float32(fma(ux, maxCos, Float32(1.0)) - ux)
          	return sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0)))
          end
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \mathsf{fma}\left(ux, maxCos, 1\right) - ux\\
          \sqrt{1 - t\_0 \cdot t\_0}
          \end{array}
          \end{array}
          
          Derivation
          1. Initial program 58.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}{\sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
          4. Step-by-step derivation
            1. lower-sqrt.f32N/A

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

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

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

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

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

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

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

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

            Alternative 7: 19.9% accurate, 5.4× speedup?

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

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

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

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

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

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

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

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

              \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot {ux}^{2}} \]
            7. Step-by-step derivation
              1. Applied rewrites19.8%

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

              Alternative 8: 62.2% accurate, 7.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 9: -0.0% accurate, 7.4× speedup?

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

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

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

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

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

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

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

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

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

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

                    Reproduce

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