UniformSampleCone, y

Percentage Accurate: 57.7% → 98.2%
Time: 10.4s
Alternatives: 13
Speedup: 4.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\\ \sin \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))))
   (* (sin (* (* 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\\
\sin \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 13 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.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \sin \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))))
   (* (sin (* (* 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\\
\sin \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.2% accurate, 0.9× speedup?

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

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

    \[\sin \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 0

    \[\leadsto \sin \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)}} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

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

      \[\leadsto \sin \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) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)} \cdot ux} \]
    4. metadata-evalN/A

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
    9. fp-cancel-sub-signN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 2: 98.2% accurate, 0.9× speedup?

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

          \[\sin \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 0

          \[\leadsto \sin \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)}} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

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

            \[\leadsto \sin \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) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)} \cdot ux} \]
          4. metadata-evalN/A

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

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

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

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

            \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
          9. fp-cancel-sub-signN/A

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

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

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

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

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

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

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

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

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

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

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

            Alternative 3: 98.3% accurate, 1.0× speedup?

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

              \[\sin \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 0

              \[\leadsto \sin \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)}} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto \sin \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) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)} \cdot ux} \]
              4. metadata-evalN/A

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

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

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

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

                \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
              9. fp-cancel-sub-signN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 4: 97.6% accurate, 1.0× speedup?

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

                    \[\sin \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 0

                    \[\leadsto \sin \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)}} \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

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

                      \[\leadsto \sin \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) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)} \cdot ux} \]
                    4. metadata-evalN/A

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

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

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

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

                      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
                    9. fp-cancel-sub-signN/A

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

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

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

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

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

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

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

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

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

                    Alternative 5: 96.8% accurate, 1.1× speedup?

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

                      \[\sin \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 0

                      \[\leadsto \sin \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)}} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

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

                        \[\leadsto \sin \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) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)} \cdot ux} \]
                      4. metadata-evalN/A

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

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

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

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

                        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
                      9. fp-cancel-sub-signN/A

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

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

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

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

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

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

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

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

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

                        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2 \cdot ux, maxCos, \left(2 - ux\right) \cdot ux\right)} \]
                      3. Step-by-step derivation
                        1. Applied rewrites97.2%

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

                        Alternative 6: 95.7% accurate, 1.1× speedup?

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

                          1. Initial program 52.2%

                            \[\sin \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 0

                            \[\leadsto \sin \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)}} \]
                          4. Step-by-step derivation
                            1. *-commutativeN/A

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

                              \[\leadsto \sin \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) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)} \cdot ux} \]
                            4. metadata-evalN/A

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

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

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

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

                              \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
                            9. fp-cancel-sub-signN/A

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

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

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

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

                              \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 - \color{blue}{{\left(maxCos - 1\right)}^{2}} \cdot ux\right) \cdot ux} \]
                            14. lower--.f3298.4

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

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

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

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

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

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

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

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

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

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

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

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

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

                              if 9.99999975e-5 < uy

                              1. Initial program 53.5%

                                \[\sin \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 0

                                \[\leadsto \sin \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)}} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

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

                                  \[\leadsto \sin \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) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)} \cdot ux} \]
                                4. metadata-evalN/A

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

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

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

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

                                  \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
                                9. fp-cancel-sub-signN/A

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

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

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

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

                                  \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 - \color{blue}{{\left(maxCos - 1\right)}^{2}} \cdot ux\right) \cdot ux} \]
                                14. lower--.f3297.9

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

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

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

                                  \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot \color{blue}{ux}} \]
                              8. Recombined 2 regimes into one program.
                              9. Add Preprocessing

                              Alternative 7: 76.6% accurate, 1.8× speedup?

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

                                1. Initial program 87.4%

                                  \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - \left|ux - \left(maxCos \cdot ux + 1\right)\right| \cdot \left|\color{blue}{\left(maxCos \cdot ux + 1\right) - ux}\right|} \]
                                  17. fabs-subN/A

                                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - \left|ux - \left(maxCos \cdot ux + 1\right)\right| \cdot \color{blue}{\left|ux - \left(maxCos \cdot ux + 1\right)\right|}} \]
                                  18. sqr-absN/A

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

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

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

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

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

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

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

                                1. Initial program 35.5%

                                  \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

                                    \[\leadsto \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\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 \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)} \cdot uy\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 \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)} \cdot uy\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                  6. lower-PI.f3233.7

                                    \[\leadsto \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot 2\right) \cdot uy\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 rewrites33.7%

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \]
                                10. Recombined 2 regimes into one program.
                                11. Add Preprocessing

                                Alternative 8: 75.5% accurate, 1.9× speedup?

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

                                  1. Initial program 87.4%

                                    \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

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

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

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

                                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \color{blue}{\left(1 - ux\right)}} \]
                                  7. Step-by-step derivation
                                    1. lower--.f3271.6

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

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

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

                                  1. Initial program 35.5%

                                    \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

                                      \[\leadsto \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\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 \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)} \cdot uy\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 \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)} \cdot uy\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    6. lower-PI.f3233.7

                                      \[\leadsto \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot 2\right) \cdot uy\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 rewrites33.7%

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \]
                                  10. Recombined 2 regimes into one program.
                                  11. Add Preprocessing

                                  Alternative 9: 81.3% accurate, 2.4× speedup?

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

                                    \[\sin \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 0

                                    \[\leadsto \sin \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)}} \]
                                  4. Step-by-step derivation
                                    1. *-commutativeN/A

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

                                      \[\leadsto \sin \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) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)} \cdot ux} \]
                                    4. metadata-evalN/A

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

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

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

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

                                      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)} \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
                                    9. fp-cancel-sub-signN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      Alternative 10: 76.7% accurate, 2.7× speedup?

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

                                        1. Initial program 34.9%

                                          \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

                                            \[\leadsto \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\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 \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)} \cdot uy\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 \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot 2\right)} \cdot uy\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                          6. lower-PI.f3233.1

                                            \[\leadsto \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot 2\right) \cdot uy\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 rewrites33.1%

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

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

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

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

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

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

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

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

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

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

                                          if 1.72e-4 < ux

                                          1. Initial program 86.7%

                                            \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -\mathsf{fma}\left(ux, maxCos, 1 - ux\right), 1\right)}} \]
                                        10. Recombined 2 regimes into one program.
                                        11. Add Preprocessing

                                        Alternative 11: 65.6% accurate, 4.5× speedup?

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

                                          \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

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

                                            \[\leadsto \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot 2\right) \cdot uy\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 rewrites46.9%

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

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

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

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

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

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

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

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

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

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

                                          Alternative 12: 25.3% accurate, 4.9× speedup?

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

                                            \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

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

                                              \[\leadsto \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot 2\right) \cdot uy\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 rewrites46.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 13: 25.4% accurate, 6.0× speedup?

                                          \[\begin{array}{l} \\ \sqrt{2 \cdot ux} \cdot \left(2 \cdot uy\right) \end{array} \]
                                          (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* 2.0 ux)) (* 2.0 uy)))
                                          float code(float ux, float uy, float maxCos) {
                                          	return sqrtf((2.0f * ux)) * (2.0f * uy);
                                          }
                                          
                                          module fmin_fmax_functions
                                              implicit none
                                              private
                                              public fmax
                                              public fmin
                                          
                                              interface fmax
                                                  module procedure fmax88
                                                  module procedure fmax44
                                                  module procedure fmax84
                                                  module procedure fmax48
                                              end interface
                                              interface fmin
                                                  module procedure fmin88
                                                  module procedure fmin44
                                                  module procedure fmin84
                                                  module procedure fmin48
                                              end interface
                                          contains
                                              real(8) function fmax88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmax44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmax84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmax48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmin44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmin48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                              end function
                                          end module
                                          
                                          real(4) function code(ux, uy, maxcos)
                                          use fmin_fmax_functions
                                              real(4), intent (in) :: ux
                                              real(4), intent (in) :: uy
                                              real(4), intent (in) :: maxcos
                                              code = sqrt((2.0e0 * ux)) * (2.0e0 * uy)
                                          end function
                                          
                                          function code(ux, uy, maxCos)
                                          	return Float32(sqrt(Float32(Float32(2.0) * ux)) * Float32(Float32(2.0) * uy))
                                          end
                                          
                                          function tmp = code(ux, uy, maxCos)
                                          	tmp = sqrt((single(2.0) * ux)) * (single(2.0) * uy);
                                          end
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \sqrt{2 \cdot ux} \cdot \left(2 \cdot uy\right)
                                          \end{array}
                                          
                                          Derivation
                                          1. Initial program 52.7%

                                            \[\sin \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(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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 \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\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. associate-*r*N/A

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

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

                                              \[\leadsto \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot 2\right) \cdot uy\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 rewrites46.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            Reproduce

                                            ?
                                            herbie shell --seed 2024351 
                                            (FPCore (ux uy maxCos)
                                              :name "UniformSampleCone, y"
                                              :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)))
                                              (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))