UniformSampleCone, x

Percentage Accurate: 57.6% → 99.0%
Time: 10.9s
Alternatives: 8
Speedup: 6.5×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 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.6% 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: 99.0% accurate, 0.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 91.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \sqrt{\left(\left(2 - \mathsf{fma}\left(-2, ux, 2\right) \cdot maxCos\right) - 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 (* (fma -2.0 ux 2.0) maxCos)) ux) ux))
  (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 96.2% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 1.99999999e-6 < maxCos

        1. Initial program 54.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 rewrites47.1%

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

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

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

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

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

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

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

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

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

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

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

          Alternative 4: 96.1% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if 1.99999999e-6 < maxCos

              1. Initial program 54.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 rewrites47.1%

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 5: 78.0% accurate, 4.1× speedup?

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

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

                  \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                4. Step-by-step derivation
                  1. Applied rewrites45.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 0

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 6: 76.2% accurate, 6.5× speedup?

                    \[\begin{array}{l} \\ \sqrt{\left(2 - ux\right) \cdot ux} \cdot 1 \end{array} \]
                    (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- 2.0 ux) ux)) 1.0))
                    float code(float ux, float uy, float maxCos) {
                    	return sqrtf(((2.0f - ux) * ux)) * 1.0f;
                    }
                    
                    real(4) function code(ux, uy, maxcos)
                        real(4), intent (in) :: ux
                        real(4), intent (in) :: uy
                        real(4), intent (in) :: maxcos
                        code = sqrt(((2.0e0 - ux) * ux)) * 1.0e0
                    end function
                    
                    function code(ux, uy, maxCos)
                    	return Float32(sqrt(Float32(Float32(Float32(2.0) - ux) * ux)) * Float32(1.0))
                    end
                    
                    function tmp = code(ux, uy, maxCos)
                    	tmp = sqrt(((single(2.0) - ux) * ux)) * single(1.0);
                    end
                    
                    \begin{array}{l}
                    
                    \\
                    \sqrt{\left(2 - ux\right) \cdot ux} \cdot 1
                    \end{array}
                    
                    Derivation
                    1. Initial program 55.3%

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

                      \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    4. Step-by-step derivation
                      1. Applied rewrites45.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 0

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 7: 19.6% accurate, 7.1× speedup?

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

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

                          \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                        4. Step-by-step derivation
                          1. Applied rewrites45.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 0

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

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

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

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

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

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

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

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

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

                            Alternative 8: 6.6% accurate, 8.2× speedup?

                            \[\begin{array}{l} \\ \sqrt{1 - 1} \cdot 1 \end{array} \]
                            (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 1.0)) 1.0))
                            float code(float ux, float uy, float maxCos) {
                            	return sqrtf((1.0f - 1.0f)) * 1.0f;
                            }
                            
                            real(4) function code(ux, uy, maxcos)
                                real(4), intent (in) :: ux
                                real(4), intent (in) :: uy
                                real(4), intent (in) :: maxcos
                                code = sqrt((1.0e0 - 1.0e0)) * 1.0e0
                            end function
                            
                            function code(ux, uy, maxCos)
                            	return Float32(sqrt(Float32(Float32(1.0) - Float32(1.0))) * Float32(1.0))
                            end
                            
                            function tmp = code(ux, uy, maxCos)
                            	tmp = sqrt((single(1.0) - single(1.0))) * single(1.0);
                            end
                            
                            \begin{array}{l}
                            
                            \\
                            \sqrt{1 - 1} \cdot 1
                            \end{array}
                            
                            Derivation
                            1. Initial program 55.3%

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

                              \[\leadsto \color{blue}{1} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            4. Step-by-step derivation
                              1. Applied rewrites45.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 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 2024271 
                                (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)))))))