UniformSampleCone, y

Percentage Accurate: 57.5% → 98.3%
Time: 6.8s
Alternatives: 11
Speedup: 4.8×

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} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \end{array} \]
(FPCore (ux uy maxCos)
  :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)))
  (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
  (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* t_0 t_0))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = (single(1.0) - ux) + (ux * maxCos);
	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0)));
end
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}

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

\[\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} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \end{array} \]
(FPCore (ux uy maxCos)
  :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)))
  (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
  (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* t_0 t_0))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = (single(1.0) - ux) + (ux * maxCos);
	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0)));
end
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}

Alternative 1: 98.3% accurate, 1.0× speedup?

\[\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)\]
\[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) - -1\right)} \]
(FPCore (ux uy maxCos)
  :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 (* (- ux (* maxCos ux)) (- (fma maxCos ux (- 1.0 ux)) -1.0)))))
float code(float ux, float uy, float maxCos) {
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((ux - (maxCos * ux)) * (fmaf(maxCos, ux, (1.0f - ux)) - -1.0f)));
}
function code(ux, uy, maxCos)
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(fma(maxCos, ux, Float32(Float32(1.0) - ux)) - Float32(-1.0)))))
end
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) - -1\right)}
Derivation
  1. Initial program 57.5%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

      Alternative 2: 98.3% accurate, 1.1× speedup?

      \[\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)\]
      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(2 + ux \cdot \left(maxCos - 1\right)\right)} \]
      (FPCore (ux uy maxCos)
        :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 (* (- ux (* maxCos ux)) (+ 2.0 (* ux (- maxCos 1.0)))))))
      float code(float ux, float uy, float maxCos) {
      	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((ux - (maxCos * ux)) * (2.0f + (ux * (maxCos - 1.0f)))));
      }
      
      function code(ux, uy, maxCos)
      	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(Float32(2.0) + Float32(ux * Float32(maxCos - Float32(1.0)))))))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt(((ux - (maxCos * ux)) * (single(2.0) + (ux * (maxCos - single(1.0))))));
      end
      
      \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(2 + ux \cdot \left(maxCos - 1\right)\right)}
      
      Derivation
      1. Initial program 57.5%

        \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

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

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

            Alternative 3: 98.3% accurate, 1.1× speedup?

            \[\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)\]
            \[\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \]
            (FPCore (ux uy maxCos)
              :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 (* 2.0 (* uy PI)))
             (sqrt (* (- ux (* maxCos ux)) (- (+ 2.0 (* maxCos ux)) ux)))))
            float code(float ux, float uy, float maxCos) {
            	return sinf((2.0f * (uy * ((float) M_PI)))) * sqrtf(((ux - (maxCos * ux)) * ((2.0f + (maxCos * ux)) - ux)));
            }
            
            function code(ux, uy, maxCos)
            	return Float32(sin(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(Float32(Float32(2.0) + Float32(maxCos * ux)) - ux))))
            end
            
            function tmp = code(ux, uy, maxCos)
            	tmp = sin((single(2.0) * (uy * single(pi)))) * sqrt(((ux - (maxCos * ux)) * ((single(2.0) + (maxCos * ux)) - ux)));
            end
            
            \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)}
            
            Derivation
            1. Initial program 57.5%

              \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

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

                Alternative 4: 96.9% accurate, 1.1× speedup?

                \[\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)\]
                \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) - -1\right)} \]
                (FPCore (ux uy maxCos)
                  :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 (* (- ux (* maxCos ux)) (- (- 1.0 ux) -1.0)))))
                float code(float ux, float uy, float maxCos) {
                	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((ux - (maxCos * ux)) * ((1.0f - ux) - -1.0f)));
                }
                
                function code(ux, uy, maxCos)
                	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(Float32(Float32(1.0) - ux) - Float32(-1.0)))))
                end
                
                function tmp = code(ux, uy, maxCos)
                	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt(((ux - (maxCos * ux)) * ((single(1.0) - ux) - single(-1.0))));
                end
                
                \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) - -1\right)}
                
                Derivation
                1. Initial program 57.5%

                  \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

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

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

                      Alternative 5: 96.9% accurate, 1.2× speedup?

                      \[\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)\]
                      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(2 - ux\right)} \]
                      (FPCore (ux uy maxCos)
                        :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 (* (- ux (* maxCos ux)) (- 2.0 ux)))))
                      float code(float ux, float uy, float maxCos) {
                      	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((ux - (maxCos * ux)) * (2.0f - ux)));
                      }
                      
                      function code(ux, uy, maxCos)
                      	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(Float32(2.0) - ux))))
                      end
                      
                      function tmp = code(ux, uy, maxCos)
                      	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt(((ux - (maxCos * ux)) * (single(2.0) - ux)));
                      end
                      
                      \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(2 - ux\right)}
                      
                      Derivation
                      1. Initial program 57.5%

                        \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

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

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

                            Alternative 6: 95.7% accurate, 1.1× speedup?

                            \[\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} \mathbf{if}\;uy \leq 0.0001500000071246177:\\ \;\;\;\;\left(\pi \cdot \left(uy + uy\right)\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux - -1 \cdot \left(ux \cdot \left(1 - ux\right)\right)}\\ \end{array} \]
                            (FPCore (ux uy maxCos)
                              :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)))
                              (if (<= uy 0.0001500000071246177)
                              (*
                               (* PI (+ uy uy))
                               (sqrt (* (- ux (* maxCos ux)) (- (fma maxCos ux 2.0) ux))))
                              (*
                               (sin (* (* uy 2.0) PI))
                               (sqrt (- ux (* -1.0 (* ux (- 1.0 ux))))))))
                            float code(float ux, float uy, float maxCos) {
                            	float tmp;
                            	if (uy <= 0.0001500000071246177f) {
                            		tmp = (((float) M_PI) * (uy + uy)) * sqrtf(((ux - (maxCos * ux)) * (fmaf(maxCos, ux, 2.0f) - ux)));
                            	} else {
                            		tmp = sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux - (-1.0f * (ux * (1.0f - ux)))));
                            	}
                            	return tmp;
                            }
                            
                            function code(ux, uy, maxCos)
                            	tmp = Float32(0.0)
                            	if (uy <= Float32(0.0001500000071246177))
                            		tmp = Float32(Float32(Float32(pi) * Float32(uy + uy)) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(fma(maxCos, ux, Float32(2.0)) - ux))));
                            	else
                            		tmp = Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux - Float32(Float32(-1.0) * Float32(ux * Float32(Float32(1.0) - ux))))));
                            	end
                            	return tmp
                            end
                            
                            \begin{array}{l}
                            \mathbf{if}\;uy \leq 0.0001500000071246177:\\
                            \;\;\;\;\left(\pi \cdot \left(uy + uy\right)\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right)}\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux - -1 \cdot \left(ux \cdot \left(1 - ux\right)\right)}\\
                            
                            
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if uy < 1.50000007e-4

                              1. Initial program 57.5%

                                \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

                                    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)}\right)\right) \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites81.4%

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

                                    if 1.50000007e-4 < uy

                                    1. Initial program 57.5%

                                      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites58.3%

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

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

                                          \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux - -1 \cdot \left(ux \cdot \left(1 - ux\right)\right)} \]
                                      4. Recombined 2 regimes into one program.
                                      5. Add Preprocessing

                                      Alternative 7: 95.7% accurate, 1.2× speedup?

                                      \[\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} \mathbf{if}\;uy \leq 0.0001500000071246177:\\ \;\;\;\;\left(\pi \cdot \left(uy + uy\right)\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 - ux\right) - -1\right)}\\ \end{array} \]
                                      (FPCore (ux uy maxCos)
                                        :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)))
                                        (if (<= uy 0.0001500000071246177)
                                        (*
                                         (* PI (+ uy uy))
                                         (sqrt (* (- ux (* maxCos ux)) (- (fma maxCos ux 2.0) ux))))
                                        (* (sin (* (* uy 2.0) PI)) (sqrt (* ux (- (- 1.0 ux) -1.0))))))
                                      float code(float ux, float uy, float maxCos) {
                                      	float tmp;
                                      	if (uy <= 0.0001500000071246177f) {
                                      		tmp = (((float) M_PI) * (uy + uy)) * sqrtf(((ux - (maxCos * ux)) * (fmaf(maxCos, ux, 2.0f) - ux)));
                                      	} else {
                                      		tmp = sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * ((1.0f - ux) - -1.0f)));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      function code(ux, uy, maxCos)
                                      	tmp = Float32(0.0)
                                      	if (uy <= Float32(0.0001500000071246177))
                                      		tmp = Float32(Float32(Float32(pi) * Float32(uy + uy)) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(fma(maxCos, ux, Float32(2.0)) - ux))));
                                      	else
                                      		tmp = Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux * Float32(Float32(Float32(1.0) - ux) - Float32(-1.0)))));
                                      	end
                                      	return tmp
                                      end
                                      
                                      \begin{array}{l}
                                      \mathbf{if}\;uy \leq 0.0001500000071246177:\\
                                      \;\;\;\;\left(\pi \cdot \left(uy + uy\right)\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right)}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 - ux\right) - -1\right)}\\
                                      
                                      
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if uy < 1.50000007e-4

                                        1. Initial program 57.5%

                                          \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

                                              \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)}\right)\right) \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites81.4%

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

                                              if 1.50000007e-4 < uy

                                              1. Initial program 57.5%

                                                \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

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

                                                      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 - ux\right) - -1\right)} \]
                                                  3. Recombined 2 regimes into one program.
                                                  4. Add Preprocessing

                                                  Alternative 8: 95.7% accurate, 1.2× speedup?

                                                  \[\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} t_0 := \pi \cdot \left(uy + uy\right)\\ \mathbf{if}\;uy \leq 0.0001500000071246177:\\ \;\;\;\;t\_0 \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(2 - ux\right) \cdot ux} \cdot \sin t\_0\\ \end{array} \]
                                                  (FPCore (ux uy maxCos)
                                                    :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)))
                                                    (let* ((t_0 (* PI (+ uy uy))))
                                                    (if (<= uy 0.0001500000071246177)
                                                      (* t_0 (sqrt (* (- ux (* maxCos ux)) (- (fma maxCos ux 2.0) ux))))
                                                      (* (sqrt (* (- 2.0 ux) ux)) (sin t_0)))))
                                                  float code(float ux, float uy, float maxCos) {
                                                  	float t_0 = ((float) M_PI) * (uy + uy);
                                                  	float tmp;
                                                  	if (uy <= 0.0001500000071246177f) {
                                                  		tmp = t_0 * sqrtf(((ux - (maxCos * ux)) * (fmaf(maxCos, ux, 2.0f) - ux)));
                                                  	} else {
                                                  		tmp = sqrtf(((2.0f - ux) * ux)) * sinf(t_0);
                                                  	}
                                                  	return tmp;
                                                  }
                                                  
                                                  function code(ux, uy, maxCos)
                                                  	t_0 = Float32(Float32(pi) * Float32(uy + uy))
                                                  	tmp = Float32(0.0)
                                                  	if (uy <= Float32(0.0001500000071246177))
                                                  		tmp = Float32(t_0 * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(fma(maxCos, ux, Float32(2.0)) - ux))));
                                                  	else
                                                  		tmp = Float32(sqrt(Float32(Float32(Float32(2.0) - ux) * ux)) * sin(t_0));
                                                  	end
                                                  	return tmp
                                                  end
                                                  
                                                  \begin{array}{l}
                                                  t_0 := \pi \cdot \left(uy + uy\right)\\
                                                  \mathbf{if}\;uy \leq 0.0001500000071246177:\\
                                                  \;\;\;\;t\_0 \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right)}\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\sqrt{\left(2 - ux\right) \cdot ux} \cdot \sin t\_0\\
                                                  
                                                  
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Split input into 2 regimes
                                                  2. if uy < 1.50000007e-4

                                                    1. Initial program 57.5%

                                                      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

                                                          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)}\right)\right) \]
                                                        2. Step-by-step derivation
                                                          1. Applied rewrites81.4%

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

                                                          if 1.50000007e-4 < uy

                                                          1. Initial program 57.5%

                                                            \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

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

                                                                  \[\leadsto \sqrt{\left(2 - ux\right) \cdot ux} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
                                                              3. Recombined 2 regimes into one program.
                                                              4. Add Preprocessing

                                                              Alternative 9: 81.4% accurate, 2.4× speedup?

                                                              \[\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)\]
                                                              \[\left(\pi \cdot \left(uy + uy\right)\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right)} \]
                                                              (FPCore (ux uy maxCos)
                                                                :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)))
                                                                (*
                                                               (* PI (+ uy uy))
                                                               (sqrt (* (- ux (* maxCos ux)) (- (fma maxCos ux 2.0) ux)))))
                                                              float code(float ux, float uy, float maxCos) {
                                                              	return (((float) M_PI) * (uy + uy)) * sqrtf(((ux - (maxCos * ux)) * (fmaf(maxCos, ux, 2.0f) - ux)));
                                                              }
                                                              
                                                              function code(ux, uy, maxCos)
                                                              	return Float32(Float32(Float32(pi) * Float32(uy + uy)) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(fma(maxCos, ux, Float32(2.0)) - ux))))
                                                              end
                                                              
                                                              \left(\pi \cdot \left(uy + uy\right)\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right)}
                                                              
                                                              Derivation
                                                              1. Initial program 57.5%

                                                                \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

                                                                    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)}\right)\right) \]
                                                                  2. Step-by-step derivation
                                                                    1. Applied rewrites81.4%

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

                                                                    Alternative 10: 76.8% accurate, 3.9× speedup?

                                                                    \[\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)\]
                                                                    \[2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - ux\right)}\right)\right) \]
                                                                    (FPCore (ux uy maxCos)
                                                                      :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)))
                                                                      (* 2.0 (* uy (* PI (sqrt (* ux (- 2.0 ux)))))))
                                                                    float code(float ux, float uy, float maxCos) {
                                                                    	return 2.0f * (uy * (((float) M_PI) * sqrtf((ux * (2.0f - ux)))));
                                                                    }
                                                                    
                                                                    function code(ux, uy, maxCos)
                                                                    	return Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(ux * Float32(Float32(2.0) - ux))))))
                                                                    end
                                                                    
                                                                    function tmp = code(ux, uy, maxCos)
                                                                    	tmp = single(2.0) * (uy * (single(pi) * sqrt((ux * (single(2.0) - ux)))));
                                                                    end
                                                                    
                                                                    2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - ux\right)}\right)\right)
                                                                    
                                                                    Derivation
                                                                    1. Initial program 57.5%

                                                                      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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. Applied rewrites98.3%

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

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

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

                                                                          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - ux\right)}\right)\right) \]
                                                                        3. Step-by-step derivation
                                                                          1. Applied rewrites76.8%

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

                                                                          Alternative 11: 63.2% accurate, 4.8× speedup?

                                                                          \[\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)\]
                                                                          \[\left(uy + uy\right) \cdot \left(\sqrt{ux + ux} \cdot \pi\right) \]
                                                                          (FPCore (ux uy maxCos)
                                                                            :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)))
                                                                            (* (+ uy uy) (* (sqrt (+ ux ux)) PI)))
                                                                          float code(float ux, float uy, float maxCos) {
                                                                          	return (uy + uy) * (sqrtf((ux + ux)) * ((float) M_PI));
                                                                          }
                                                                          
                                                                          function code(ux, uy, maxCos)
                                                                          	return Float32(Float32(uy + uy) * Float32(sqrt(Float32(ux + ux)) * Float32(pi)))
                                                                          end
                                                                          
                                                                          function tmp = code(ux, uy, maxCos)
                                                                          	tmp = (uy + uy) * (sqrt((ux + ux)) * single(pi));
                                                                          end
                                                                          
                                                                          \left(uy + uy\right) \cdot \left(\sqrt{ux + ux} \cdot \pi\right)
                                                                          
                                                                          Derivation
                                                                          1. Initial program 57.5%

                                                                            \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\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 uy around 0

                                                                            \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
                                                                          3. Step-by-step derivation
                                                                            1. Applied rewrites50.4%

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

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

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

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

                                                                                  \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right) \]
                                                                                2. Step-by-step derivation
                                                                                  1. Applied rewrites63.2%

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

                                                                                  Reproduce

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