UniformSampleCone, y

Percentage Accurate: 57.5% → 98.2%
Time: 6.4s
Alternatives: 14
Speedup: 1.3×

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 14 alternatives:

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

Initial Program: 57.5% 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.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}\\ t_1 := \frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux}\\ \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{t\_1 \cdot t\_1 - t\_0 \cdot t\_0}{t\_1 + t\_0} \cdot \left(ux \cdot ux\right)} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (pow (fma -1.0 maxCos 1.0) 2.0))
        (t_1 (/ (fma -2.0 maxCos 2.0) ux)))
   (*
    (sin (* (* uy 2.0) (PI)))
    (sqrt (* (/ (- (* t_1 t_1) (* t_0 t_0)) (+ t_1 t_0)) (* ux ux))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}\\
t_1 := \frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux}\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{t\_1 \cdot t\_1 - t\_0 \cdot t\_0}{t\_1 + t\_0} \cdot \left(ux \cdot ux\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 59.1%

    \[\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 -inf

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

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

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

      Alternative 2: 85.7% accurate, 0.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.9980000257492065:\\ \;\;\;\;\left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{1 - \left(\frac{1 - ux \cdot ux}{1 + ux} + ux \cdot maxCos\right) \cdot t\_0}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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.9980000257492065)
           (*
            (* (PI) (* 2.0 uy))
            (sqrt
             (- 1.0 (* (+ (/ (- 1.0 (* ux ux)) (+ 1.0 ux)) (* ux maxCos)) t_0))))
           (* (sin (* (* uy 2.0) (PI))) (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.9980000257492065:\\
      \;\;\;\;\left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{1 - \left(\frac{1 - ux \cdot ux}{1 + ux} + ux \cdot maxCos\right) \cdot t\_0}\\
      
      \mathbf{else}:\\
      \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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.998000026

        1. Initial program 91.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. Applied rewrites81.5%

            \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(2 \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. Step-by-step derivation
            1. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 43.1%

            \[\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(2 - 2 \cdot maxCos\right)}} \]
          4. Step-by-step derivation
            1. Applied rewrites89.1%

              \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}} \]
          5. Recombined 2 regimes into one program.
          6. 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{ux \cdot \left(2 + \mathsf{fma}\left(-2, maxCos, \left(-ux\right) \cdot \left(1 + maxCos \cdot \left(maxCos - 2\right)\right)\right)\right)} \end{array} \]
          (FPCore (ux uy maxCos)
           :precision binary32
           (*
            (sin (* (* uy 2.0) (PI)))
            (sqrt
             (*
              ux
              (+ 2.0 (fma -2.0 maxCos (* (- ux) (+ 1.0 (* maxCos (- maxCos 2.0))))))))))
          \begin{array}{l}
          
          \\
          \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(-2, maxCos, \left(-ux\right) \cdot \left(1 + maxCos \cdot \left(maxCos - 2\right)\right)\right)\right)}
          \end{array}
          
          Derivation
          1. Initial program 59.1%

            \[\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 -inf

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

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

                \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} \cdot \frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2} \cdot {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}}{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} + {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}} \cdot \left(\color{blue}{ux} \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{ux \cdot \color{blue}{\left(2 + \left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\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{ux \cdot \color{blue}{\left(2 + \mathsf{fma}\left(-2, maxCos, -1 \cdot \left(ux \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)\right)}} \]
                2. Taylor expanded in maxCos around 0

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

                    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(-2, maxCos, \left(-ux\right) \cdot \left(1 + maxCos \cdot \left(maxCos - 2\right)\right)\right)\right)} \]
                  3. 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{ux \cdot \left(2 + \mathsf{fma}\left(-1, ux, maxCos \cdot \left(2 \cdot ux - 2\right)\right)\right)} \end{array} \]
                  (FPCore (ux uy maxCos)
                   :precision binary32
                   (*
                    (sin (* (* uy 2.0) (PI)))
                    (sqrt (* ux (+ 2.0 (fma -1.0 ux (* maxCos (- (* 2.0 ux) 2.0))))))))
                  \begin{array}{l}
                  
                  \\
                  \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(-1, ux, maxCos \cdot \left(2 \cdot ux - 2\right)\right)\right)}
                  \end{array}
                  
                  Derivation
                  1. Initial program 59.1%

                    \[\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 -inf

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

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

                        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} \cdot \frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2} \cdot {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}}{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} + {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}} \cdot \left(\color{blue}{ux} \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{ux \cdot \color{blue}{\left(2 + \left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\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{ux \cdot \color{blue}{\left(2 + \mathsf{fma}\left(-2, maxCos, -1 \cdot \left(ux \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)\right)}} \]
                        2. Taylor expanded in maxCos around 0

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

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

                          Alternative 5: 95.3% accurate, 1.1× speedup?

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

                            1. Initial program 59.0%

                              \[\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 -inf

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

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

                                  \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} \cdot \frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2} \cdot {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}}{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} + {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}} \cdot \left(\color{blue}{ux} \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{ux \cdot \color{blue}{\left(2 + \left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\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{ux \cdot \color{blue}{\left(2 + \mathsf{fma}\left(-2, maxCos, -1 \cdot \left(ux \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)\right)}} \]
                                  2. Taylor expanded in maxCos around 0

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

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

                                    if 4.99999999e-7 < maxCos

                                    1. Initial program 59.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 -inf

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

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

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

                                          \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(maxCos \cdot maxCos\right) \cdot \left(-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{2 \cdot \frac{1}{ux} - 1}{maxCos}, 2 \cdot \frac{1}{ux}\right) - 2}{maxCos} - 1\right)\right) \cdot \left(\color{blue}{ux} \cdot 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(\left(maxCos \cdot maxCos\right) \cdot \left(-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{2 \cdot \frac{1}{ux} - 1}{maxCos}, 2 \cdot \frac{1}{ux}\right) - 2}{maxCos} - 1\right)\right) \cdot \left(ux \cdot ux\right)} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites84.3%

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

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

                                        Alternative 6: 96.9% accurate, 1.1× speedup?

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

                                          \[\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 -inf

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

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

                                              \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\frac{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} \cdot \frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2} \cdot {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}}{\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} + {\left(\mathsf{fma}\left(-1, maxCos, 1\right)\right)}^{2}} \cdot \left(\color{blue}{ux} \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{ux \cdot \color{blue}{\left(2 + \left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\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{ux \cdot \color{blue}{\left(2 + \mathsf{fma}\left(-2, maxCos, -1 \cdot \left(ux \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)\right)}} \]
                                              2. Taylor expanded in maxCos around 0

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

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

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

                                                Alternative 7: 63.3% accurate, 1.3× speedup?

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

                                                  1. Initial program 60.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. Applied rewrites53.9%

                                                      \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(2 \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. Taylor expanded in ux around inf

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

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

                                                      if 2.00000003e-16 < maxCos

                                                      1. Initial program 56.8%

                                                        \[\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 -inf

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

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

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

                                                            \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(maxCos \cdot maxCos\right) \cdot \left(-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{2 \cdot \frac{1}{ux} - 1}{maxCos}, 2 \cdot \frac{1}{ux}\right) - 2}{maxCos} - 1\right)\right) \cdot \left(\color{blue}{ux} \cdot 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(\left(maxCos \cdot maxCos\right) \cdot \left(-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{2 \cdot \frac{1}{ux} - 1}{maxCos}, 2 \cdot \frac{1}{ux}\right) - 2}{maxCos} - 1\right)\right) \cdot \left(ux \cdot ux\right)} \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites80.4%

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

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

                                                          Alternative 8: 51.5% accurate, 2.3× speedup?

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

                                                            \[\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. Applied rewrites52.4%

                                                              \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(2 \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. Taylor expanded in ux around inf

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

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

                                                              Alternative 9: 50.7% accurate, 2.8× speedup?

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

                                                                \[\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. Applied rewrites52.4%

                                                                  \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(2 \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. Taylor expanded in ux around 0

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

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

                                                                  Alternative 10: 50.6% accurate, 3.0× speedup?

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

                                                                    \[\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. Step-by-step derivation
                                                                    1. lift-+.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                    Alternative 11: 49.3% accurate, 3.3× speedup?

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

                                                                      \[\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. Applied rewrites52.4%

                                                                        \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(2 \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. Taylor expanded in maxCos around 0

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

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

                                                                        Alternative 12: 41.7% accurate, 3.6× speedup?

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

                                                                          \[\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{1 - \color{blue}{\left(1 + ux \cdot \left(2 \cdot maxCos - 2\right)\right)}} \]
                                                                        4. Step-by-step derivation
                                                                          1. Applied rewrites46.8%

                                                                            \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\mathsf{fma}\left(maxCos \cdot 2 - 2, ux, 1\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{1 - \mathsf{fma}\left(maxCos \cdot 2 - 2, ux, 1\right)} \]
                                                                          3. Step-by-step derivation
                                                                            1. Applied rewrites43.0%

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

                                                                            Alternative 13: 41.0% accurate, 4.5× speedup?

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

                                                                              \[\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{1 - \color{blue}{\left(1 + ux \cdot \left(2 \cdot maxCos - 2\right)\right)}} \]
                                                                            4. Step-by-step derivation
                                                                              1. Applied rewrites46.8%

                                                                                \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\mathsf{fma}\left(maxCos \cdot 2 - 2, ux, 1\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{1 - \mathsf{fma}\left(maxCos \cdot 2 - 2, ux, 1\right)} \]
                                                                              3. Step-by-step derivation
                                                                                1. Applied rewrites43.0%

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

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

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

                                                                                  Alternative 14: 7.1% accurate, 5.4× speedup?

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

                                                                                    \[\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. Applied rewrites52.4%

                                                                                      \[\leadsto \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(2 \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. Taylor expanded in ux around 0

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

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

                                                                                      Reproduce

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