UniformSampleCone, y

Percentage Accurate: 57.6% → 98.3%
Time: 6.3s
Alternatives: 11
Speedup: 4.6×

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

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

Initial Program: 57.6% accurate, 1.0× speedup?

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

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

\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot \mathsf{fma}\left(-1, {\left(maxCos - 1\right)}^{2}, 2 \cdot \frac{1}{ux}\right) - maxCos \cdot 2\right) \cdot ux}
\end{array}
Derivation
  1. Initial program 54.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. Applied rewrites98.2%

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

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

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

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

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

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

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

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

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

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

                      Alternative 4: 97.7% 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(maxCos, 2 \cdot ux - 2, -ux\right) + 2\right) \cdot ux} \end{array} \]
                      (FPCore (ux uy maxCos)
                       :precision binary32
                       (*
                        (sin (* (* uy 2.0) (PI)))
                        (sqrt (* (+ (fma maxCos (- (* 2.0 ux) 2.0) (- ux)) 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(maxCos, 2 \cdot ux - 2, -ux\right) + 2\right) \cdot ux}
                      \end{array}
                      
                      Derivation
                      1. Initial program 54.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. Applied rewrites98.2%

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

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

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

                            Alternative 5: 97.7% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

                                            Alternative 7: 85.5% accurate, 1.1× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \leq 0.0024999999441206455:\\ \;\;\;\;\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot ux}\\ \end{array} \end{array} \]
                                            (FPCore (ux uy maxCos)
                                             :precision binary32
                                             (if (<= uy 0.0024999999441206455)
                                               (* (* 2.0 (* uy (PI))) (sqrt (* (- 2.0 ux) ux)))
                                               (* (sin (* (* uy 2.0) (PI))) (sqrt (* 2.0 ux)))))
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            \mathbf{if}\;uy \leq 0.0024999999441206455:\\
                                            \;\;\;\;\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot ux}\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. if uy < 0.00249999994

                                              1. Initial program 54.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. Applied rewrites98.5%

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

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

                                                    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + -1 \cdot ux\right) \cdot ux} \]
                                                  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(2 + -1 \cdot ux\right) \cdot ux} \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites91.1%

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

                                                    if 0.00249999994 < uy

                                                    1. Initial program 53.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 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. Applied rewrites97.5%

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

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

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

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

                                                            \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot ux} \]
                                                        4. Recombined 2 regimes into one program.
                                                        5. Final simplification86.1%

                                                          \[\leadsto \begin{array}{l} \mathbf{if}\;uy \leq 0.0024999999441206455:\\ \;\;\;\;\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot ux}\\ \end{array} \]
                                                        6. Add Preprocessing

                                                        Alternative 8: 92.4% accurate, 1.2× 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} \end{array} \]
                                                        (FPCore (ux uy maxCos)
                                                         :precision binary32
                                                         (* (sin (* (* uy 2.0) (PI))) (sqrt (* (- 2.0 ux) ux))))
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Initial program 54.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. Applied rewrites98.2%

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

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

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

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

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

                                                                Alternative 9: 81.8% accurate, 1.3× speedup?

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

                                                                  1. Initial program 55.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 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. Applied rewrites98.6%

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

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

                                                                        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + -1 \cdot ux\right) \cdot ux} \]
                                                                      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(2 + -1 \cdot ux\right) \cdot ux} \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites81.8%

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

                                                                        if 7.99999975e-20 < maxCos

                                                                        1. Initial program 52.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 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. Applied rewrites97.9%

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

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

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

                                                                            Alternative 10: 77.4% accurate, 4.6× speedup?

                                                                            \[\begin{array}{l} \\ \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux} \end{array} \]
                                                                            (FPCore (ux uy maxCos)
                                                                             :precision binary32
                                                                             (* (* 2.0 (* uy (PI))) (sqrt (* (- 2.0 ux) ux))))
                                                                            \begin{array}{l}
                                                                            
                                                                            \\
                                                                            \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}
                                                                            \end{array}
                                                                            
                                                                            Derivation
                                                                            1. Initial program 54.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. Applied rewrites98.2%

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

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

                                                                                  \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + -1 \cdot ux\right) \cdot ux} \]
                                                                                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(2 + -1 \cdot ux\right) \cdot ux} \]
                                                                                3. Step-by-step derivation
                                                                                  1. Applied rewrites75.8%

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

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

                                                                                  Alternative 11: 7.1% accurate, 5.8× speedup?

                                                                                  \[\begin{array}{l} \\ \left(\mathsf{PI}\left(\right) \cdot \left(uy + uy\right)\right) \cdot \sqrt{1 - 1} \end{array} \]
                                                                                  (FPCore (ux uy maxCos)
                                                                                   :precision binary32
                                                                                   (* (* (PI) (+ uy uy)) (sqrt (- 1.0 1.0))))
                                                                                  \begin{array}{l}
                                                                                  
                                                                                  \\
                                                                                  \left(\mathsf{PI}\left(\right) \cdot \left(uy + uy\right)\right) \cdot \sqrt{1 - 1}
                                                                                  \end{array}
                                                                                  
                                                                                  Derivation
                                                                                  1. Initial program 54.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 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 rewrites46.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 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. Step-by-step derivation
                                                                                        1. Applied rewrites7.1%

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

                                                                                        Reproduce

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