Beckmann Sample, near normal, slope_x

Percentage Accurate: 57.2% → 99.2%
Time: 9.1s
Alternatives: 24
Speedup: 18.5×

Specification

?
\[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
(FPCore (cosTheta_i u1 u2)
  :precision binary32
  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
          (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
     (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
  (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-logf((1.0f - u1))) * cosf(((2.0f * ((float) M_PI)) * u2));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = sqrt(-log((single(1.0) - u1))) * cos(((single(2.0) * single(pi)) * u2));
end
\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)

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

\[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
(FPCore (cosTheta_i u1 u2)
  :precision binary32
  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
          (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
     (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
  (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-logf((1.0f - u1))) * cosf(((2.0f * ((float) M_PI)) * u2));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = sqrt(-log((single(1.0) - u1))) * cos(((single(2.0) * single(pi)) * u2));
end
\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)

Alternative 1: 99.2% accurate, 0.9× speedup?

\[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\mathsf{fma}\left(-2 \cdot u2, \pi, 1.5707963705062866\right)\right) \]
(FPCore (cosTheta_i u1 u2)
  :precision binary32
  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
          (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
     (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
  (*
 (sqrt (- (log1p (- u1))))
 (sin (fma (* -2.0 u2) PI 1.5707963705062866))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-log1pf(-u1)) * sinf(fmaf((-2.0f * u2), ((float) M_PI), 1.5707963705062866f));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * sin(fma(Float32(Float32(-2.0) * u2), Float32(pi), Float32(1.5707963705062866))))
end
\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\mathsf{fma}\left(-2 \cdot u2, \pi, 1.5707963705062866\right)\right)
Derivation
  1. Initial program 57.2%

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Step-by-step derivation
    1. Applied rewrites57.2%

      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\mathsf{fma}\left(-2 \cdot u2, \pi, 0.5 \cdot \pi\right)\right) \]
    2. Evaluated real constant57.2%

      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\mathsf{fma}\left(-2 \cdot u2, \pi, 1.5707963705062866\right)\right) \]
    3. Step-by-step derivation
      1. Applied rewrites99.2%

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\mathsf{fma}\left(-2 \cdot u2, \pi, 1.5707963705062866\right)\right) \]
      2. Add Preprocessing

      Alternative 2: 99.0% accurate, 1.0× speedup?

      \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
      \[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
      (FPCore (cosTheta_i u1 u2)
        :precision binary32
        :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
           (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
        (* (sqrt (- (log1p (- u1)))) (cos (* 6.2831854820251465 u2))))
      float code(float cosTheta_i, float u1, float u2) {
      	return sqrtf(-log1pf(-u1)) * cosf((6.2831854820251465f * u2));
      }
      
      function code(cosTheta_i, u1, u2)
      	return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * cos(Float32(Float32(6.2831854820251465) * u2)))
      end
      
      \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right)
      
      Derivation
      1. Initial program 57.2%

        \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
      2. Evaluated real constant57.2%

        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
      3. Step-by-step derivation
        1. Applied rewrites99.0%

          \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
        2. Add Preprocessing

        Alternative 3: 96.7% accurate, 0.9× speedup?

        \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
        \[\begin{array}{l} t_0 := \sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.05999999865889549:\\ \;\;\;\;t\_0 + -19.739209900765786 \cdot \left({u2}^{2} \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right)\\ \end{array} \]
        (FPCore (cosTheta_i u1 u2)
          :precision binary32
          :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                  (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
             (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
          (let* ((t_0 (sqrt (- (log1p (- u1))))))
          (if (<= (* (* 2.0 PI) u2) 0.05999999865889549)
            (+ t_0 (* -19.739209900765786 (* (pow u2 2.0) t_0)))
            (*
             (sqrt (fma (* 0.5 u1) u1 u1))
             (cos (* 6.2831854820251465 u2))))))
        float code(float cosTheta_i, float u1, float u2) {
        	float t_0 = sqrtf(-log1pf(-u1));
        	float tmp;
        	if (((2.0f * ((float) M_PI)) * u2) <= 0.05999999865889549f) {
        		tmp = t_0 + (-19.739209900765786f * (powf(u2, 2.0f) * t_0));
        	} else {
        		tmp = sqrtf(fmaf((0.5f * u1), u1, u1)) * cosf((6.2831854820251465f * u2));
        	}
        	return tmp;
        }
        
        function code(cosTheta_i, u1, u2)
        	t_0 = sqrt(Float32(-log1p(Float32(-u1))))
        	tmp = Float32(0.0)
        	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.05999999865889549))
        		tmp = Float32(t_0 + Float32(Float32(-19.739209900765786) * Float32((u2 ^ Float32(2.0)) * t_0)));
        	else
        		tmp = Float32(sqrt(fma(Float32(Float32(0.5) * u1), u1, u1)) * cos(Float32(Float32(6.2831854820251465) * u2)));
        	end
        	return tmp
        end
        
        \begin{array}{l}
        t_0 := \sqrt{-\mathsf{log1p}\left(-u1\right)}\\
        \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.05999999865889549:\\
        \;\;\;\;t\_0 + -19.739209900765786 \cdot \left({u2}^{2} \cdot t\_0\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0599999987

          1. Initial program 57.2%

            \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
          2. Evaluated real constant57.2%

            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
          3. Taylor expanded in u2 around 0

            \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{-173627926472025}{8796093022208} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
          4. Step-by-step derivation
            1. Applied rewrites52.4%

              \[\leadsto \sqrt{-\log \left(1 - u1\right)} + -19.739209900765786 \cdot \left({u2}^{2} \cdot \sqrt{-\log \left(1 - u1\right)}\right) \]
            2. Step-by-step derivation
              1. Applied rewrites88.0%

                \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} + -19.739209900765786 \cdot \left({u2}^{2} \cdot \sqrt{-\mathsf{log1p}\left(-u1\right)}\right) \]

              if 0.0599999987 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

              1. Initial program 57.2%

                \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
              2. Taylor expanded in u1 around 0

                \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
              3. Step-by-step derivation
                1. Applied rewrites88.3%

                  \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                2. Step-by-step derivation
                  1. Applied rewrites88.3%

                    \[\leadsto \sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                  2. Evaluated real constant88.3%

                    \[\leadsto \sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                3. Recombined 2 regimes into one program.
                4. Add Preprocessing

                Alternative 4: 96.6% accurate, 0.9× speedup?

                \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.05999999865889549:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right)\\ \end{array} \]
                (FPCore (cosTheta_i u1 u2)
                  :precision binary32
                  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                          (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                     (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                  (if (<= (* (* 2.0 PI) u2) 0.05999999865889549)
                  (*
                   (sqrt (- (log1p (- u1))))
                   (fma (* -19.739209900765786 u2) u2 1.0))
                  (* (sqrt (fma (* 0.5 u1) u1 u1)) (cos (* 6.2831854820251465 u2)))))
                float code(float cosTheta_i, float u1, float u2) {
                	float tmp;
                	if (((2.0f * ((float) M_PI)) * u2) <= 0.05999999865889549f) {
                		tmp = sqrtf(-log1pf(-u1)) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                	} else {
                		tmp = sqrtf(fmaf((0.5f * u1), u1, u1)) * cosf((6.2831854820251465f * u2));
                	}
                	return tmp;
                }
                
                function code(cosTheta_i, u1, u2)
                	tmp = Float32(0.0)
                	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.05999999865889549))
                		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)));
                	else
                		tmp = Float32(sqrt(fma(Float32(Float32(0.5) * u1), u1, u1)) * cos(Float32(Float32(6.2831854820251465) * u2)));
                	end
                	return tmp
                end
                
                \begin{array}{l}
                \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.05999999865889549:\\
                \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right)\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0599999987

                  1. Initial program 57.2%

                    \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                  2. Evaluated real constant57.2%

                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                  3. Taylor expanded in u2 around 0

                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                  4. Step-by-step derivation
                    1. Applied rewrites52.4%

                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                    2. Step-by-step derivation
                      1. Applied rewrites88.0%

                        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                      2. Step-by-step derivation
                        1. Applied rewrites88.0%

                          \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]

                        if 0.0599999987 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                        1. Initial program 57.2%

                          \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                        2. Taylor expanded in u1 around 0

                          \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                        3. Step-by-step derivation
                          1. Applied rewrites88.3%

                            \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                          2. Step-by-step derivation
                            1. Applied rewrites88.3%

                              \[\leadsto \sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                            2. Evaluated real constant88.3%

                              \[\leadsto \sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                          3. Recombined 2 regimes into one program.
                          4. Add Preprocessing

                          Alternative 5: 96.6% accurate, 0.9× speedup?

                          \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                          \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.05999999865889549:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot \cos \left(6.2831854820251465 \cdot u2\right)\\ \end{array} \]
                          (FPCore (cosTheta_i u1 u2)
                            :precision binary32
                            :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                    (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                               (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                            (if (<= (* (* 2.0 PI) u2) 0.05999999865889549)
                            (*
                             (sqrt (- (log1p (- u1))))
                             (fma (* -19.739209900765786 u2) u2 1.0))
                            (* (sqrt (* (fma 0.5 u1 1.0) u1)) (cos (* 6.2831854820251465 u2)))))
                          float code(float cosTheta_i, float u1, float u2) {
                          	float tmp;
                          	if (((2.0f * ((float) M_PI)) * u2) <= 0.05999999865889549f) {
                          		tmp = sqrtf(-log1pf(-u1)) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                          	} else {
                          		tmp = sqrtf((fmaf(0.5f, u1, 1.0f) * u1)) * cosf((6.2831854820251465f * u2));
                          	}
                          	return tmp;
                          }
                          
                          function code(cosTheta_i, u1, u2)
                          	tmp = Float32(0.0)
                          	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.05999999865889549))
                          		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)));
                          	else
                          		tmp = Float32(sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1)) * cos(Float32(Float32(6.2831854820251465) * u2)));
                          	end
                          	return tmp
                          end
                          
                          \begin{array}{l}
                          \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.05999999865889549:\\
                          \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot \cos \left(6.2831854820251465 \cdot u2\right)\\
                          
                          
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0599999987

                            1. Initial program 57.2%

                              \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                            2. Evaluated real constant57.2%

                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                            3. Taylor expanded in u2 around 0

                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                            4. Step-by-step derivation
                              1. Applied rewrites52.4%

                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                              2. Step-by-step derivation
                                1. Applied rewrites88.0%

                                  \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                2. Step-by-step derivation
                                  1. Applied rewrites88.0%

                                    \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]

                                  if 0.0599999987 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                  1. Initial program 57.2%

                                    \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                  2. Taylor expanded in u1 around 0

                                    \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites88.3%

                                      \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                    2. Evaluated real constant88.3%

                                      \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites88.3%

                                        \[\leadsto \sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                    4. Recombined 2 regimes into one program.
                                    5. Add Preprocessing

                                    Alternative 6: 94.5% accurate, 0.9× speedup?

                                    \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                    \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.11999999731779099:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \cos \left(\mathsf{fma}\left(\mathsf{fma}\left(-2, u2, 1\right), \pi, \pi\right)\right)\\ \end{array} \]
                                    (FPCore (cosTheta_i u1 u2)
                                      :precision binary32
                                      :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                              (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                         (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                      (if (<= (* (* 2.0 PI) u2) 0.11999999731779099)
                                      (*
                                       (sqrt (- (log1p (- u1))))
                                       (fma (* -19.739209900765786 u2) u2 1.0))
                                      (* (sqrt u1) (cos (fma (fma -2.0 u2 1.0) PI PI)))))
                                    float code(float cosTheta_i, float u1, float u2) {
                                    	float tmp;
                                    	if (((2.0f * ((float) M_PI)) * u2) <= 0.11999999731779099f) {
                                    		tmp = sqrtf(-log1pf(-u1)) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                                    	} else {
                                    		tmp = sqrtf(u1) * cosf(fmaf(fmaf(-2.0f, u2, 1.0f), ((float) M_PI), ((float) M_PI)));
                                    	}
                                    	return tmp;
                                    }
                                    
                                    function code(cosTheta_i, u1, u2)
                                    	tmp = Float32(0.0)
                                    	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.11999999731779099))
                                    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)));
                                    	else
                                    		tmp = Float32(sqrt(u1) * cos(fma(fma(Float32(-2.0), u2, Float32(1.0)), Float32(pi), Float32(pi))));
                                    	end
                                    	return tmp
                                    end
                                    
                                    \begin{array}{l}
                                    \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.11999999731779099:\\
                                    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sqrt{u1} \cdot \cos \left(\mathsf{fma}\left(\mathsf{fma}\left(-2, u2, 1\right), \pi, \pi\right)\right)\\
                                    
                                    
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.119999997

                                      1. Initial program 57.2%

                                        \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                      2. Evaluated real constant57.2%

                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                      3. Taylor expanded in u2 around 0

                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites52.4%

                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites88.0%

                                            \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                          2. Step-by-step derivation
                                            1. Applied rewrites88.0%

                                              \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]

                                            if 0.119999997 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                            1. Initial program 57.2%

                                              \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                            2. Taylor expanded in u1 around 0

                                              \[\leadsto \sqrt{u1} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites76.7%

                                                \[\leadsto \sqrt{u1} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites76.6%

                                                  \[\leadsto \sqrt{u1} \cdot \cos \left(\mathsf{fma}\left(-2 \cdot u2, \pi, \pi\right) + \pi\right) \]
                                                2. Step-by-step derivation
                                                  1. Applied rewrites76.6%

                                                    \[\leadsto \sqrt{u1} \cdot \cos \left(\mathsf{fma}\left(\mathsf{fma}\left(-2, u2, 1\right), \pi, \pi\right)\right) \]
                                                3. Recombined 2 regimes into one program.
                                                4. Add Preprocessing

                                                Alternative 7: 94.4% accurate, 1.0× speedup?

                                                \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.11999999731779099:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(-2, u2, 0.5\right) \cdot \pi\right)\\ \end{array} \]
                                                (FPCore (cosTheta_i u1 u2)
                                                  :precision binary32
                                                  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                          (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                     (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                  (if (<= (* (* 2.0 PI) u2) 0.11999999731779099)
                                                  (*
                                                   (sqrt (- (log1p (- u1))))
                                                   (fma (* -19.739209900765786 u2) u2 1.0))
                                                  (* (sqrt u1) (sin (* (fma -2.0 u2 0.5) PI)))))
                                                float code(float cosTheta_i, float u1, float u2) {
                                                	float tmp;
                                                	if (((2.0f * ((float) M_PI)) * u2) <= 0.11999999731779099f) {
                                                		tmp = sqrtf(-log1pf(-u1)) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                                                	} else {
                                                		tmp = sqrtf(u1) * sinf((fmaf(-2.0f, u2, 0.5f) * ((float) M_PI)));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(cosTheta_i, u1, u2)
                                                	tmp = Float32(0.0)
                                                	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.11999999731779099))
                                                		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)));
                                                	else
                                                		tmp = Float32(sqrt(u1) * sin(Float32(fma(Float32(-2.0), u2, Float32(0.5)) * Float32(pi))));
                                                	end
                                                	return tmp
                                                end
                                                
                                                \begin{array}{l}
                                                \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.11999999731779099:\\
                                                \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(-2, u2, 0.5\right) \cdot \pi\right)\\
                                                
                                                
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.119999997

                                                  1. Initial program 57.2%

                                                    \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                  2. Evaluated real constant57.2%

                                                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                  3. Taylor expanded in u2 around 0

                                                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                  4. Step-by-step derivation
                                                    1. Applied rewrites52.4%

                                                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                    2. Step-by-step derivation
                                                      1. Applied rewrites88.0%

                                                        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                      2. Step-by-step derivation
                                                        1. Applied rewrites88.0%

                                                          \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]

                                                        if 0.119999997 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                                        1. Initial program 57.2%

                                                          \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                        2. Taylor expanded in u1 around 0

                                                          \[\leadsto \sqrt{u1} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites76.7%

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

                                                              \[\leadsto \sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(-2, u2, 0.5\right) \cdot \pi\right) \]
                                                          3. Recombined 2 regimes into one program.
                                                          4. Add Preprocessing

                                                          Alternative 8: 94.4% accurate, 1.0× speedup?

                                                          \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                          \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.11999999731779099:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(\left|u2\right|, 6.2831854820251465, 1.5707963705062866\right)\right)\\ \end{array} \]
                                                          (FPCore (cosTheta_i u1 u2)
                                                            :precision binary32
                                                            :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                    (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                               (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                            (if (<= (* (* 2.0 PI) u2) 0.11999999731779099)
                                                            (*
                                                             (sqrt (- (log1p (- u1))))
                                                             (fma (* -19.739209900765786 u2) u2 1.0))
                                                            (*
                                                             (sqrt u1)
                                                             (sin (fma (fabs u2) 6.2831854820251465 1.5707963705062866)))))
                                                          float code(float cosTheta_i, float u1, float u2) {
                                                          	float tmp;
                                                          	if (((2.0f * ((float) M_PI)) * u2) <= 0.11999999731779099f) {
                                                          		tmp = sqrtf(-log1pf(-u1)) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                                                          	} else {
                                                          		tmp = sqrtf(u1) * sinf(fmaf(fabsf(u2), 6.2831854820251465f, 1.5707963705062866f));
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          function code(cosTheta_i, u1, u2)
                                                          	tmp = Float32(0.0)
                                                          	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.11999999731779099))
                                                          		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)));
                                                          	else
                                                          		tmp = Float32(sqrt(u1) * sin(fma(abs(u2), Float32(6.2831854820251465), Float32(1.5707963705062866))));
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          \begin{array}{l}
                                                          \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.11999999731779099:\\
                                                          \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;\sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(\left|u2\right|, 6.2831854820251465, 1.5707963705062866\right)\right)\\
                                                          
                                                          
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 2 regimes
                                                          2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.119999997

                                                            1. Initial program 57.2%

                                                              \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                            2. Evaluated real constant57.2%

                                                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                            3. Taylor expanded in u2 around 0

                                                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                            4. Step-by-step derivation
                                                              1. Applied rewrites52.4%

                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                              2. Step-by-step derivation
                                                                1. Applied rewrites88.0%

                                                                  \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                2. Step-by-step derivation
                                                                  1. Applied rewrites88.0%

                                                                    \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]

                                                                  if 0.119999997 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                                                  1. Initial program 57.2%

                                                                    \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                  2. Taylor expanded in u1 around 0

                                                                    \[\leadsto \sqrt{u1} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites76.7%

                                                                      \[\leadsto \sqrt{u1} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                    2. Evaluated real constant76.7%

                                                                      \[\leadsto \sqrt{u1} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                    3. Step-by-step derivation
                                                                      1. Applied rewrites76.7%

                                                                        \[\leadsto \sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(\left|u2\right|, 6.2831854820251465, 0.5 \cdot \pi\right)\right) \]
                                                                      2. Evaluated real constant76.7%

                                                                        \[\leadsto \sqrt{u1} \cdot \sin \left(\mathsf{fma}\left(\left|u2\right|, 6.2831854820251465, 1.5707963705062866\right)\right) \]
                                                                    4. Recombined 2 regimes into one program.
                                                                    5. Add Preprocessing

                                                                    Alternative 9: 94.4% accurate, 1.1× speedup?

                                                                    \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                    \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.11999999731779099:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \cos \left(6.2831854820251465 \cdot u2\right)\\ \end{array} \]
                                                                    (FPCore (cosTheta_i u1 u2)
                                                                      :precision binary32
                                                                      :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                              (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                         (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                      (if (<= (* (* 2.0 PI) u2) 0.11999999731779099)
                                                                      (*
                                                                       (sqrt (- (log1p (- u1))))
                                                                       (fma (* -19.739209900765786 u2) u2 1.0))
                                                                      (* (sqrt u1) (cos (* 6.2831854820251465 u2)))))
                                                                    float code(float cosTheta_i, float u1, float u2) {
                                                                    	float tmp;
                                                                    	if (((2.0f * ((float) M_PI)) * u2) <= 0.11999999731779099f) {
                                                                    		tmp = sqrtf(-log1pf(-u1)) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                                                                    	} else {
                                                                    		tmp = sqrtf(u1) * cosf((6.2831854820251465f * u2));
                                                                    	}
                                                                    	return tmp;
                                                                    }
                                                                    
                                                                    function code(cosTheta_i, u1, u2)
                                                                    	tmp = Float32(0.0)
                                                                    	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.11999999731779099))
                                                                    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)));
                                                                    	else
                                                                    		tmp = Float32(sqrt(u1) * cos(Float32(Float32(6.2831854820251465) * u2)));
                                                                    	end
                                                                    	return tmp
                                                                    end
                                                                    
                                                                    \begin{array}{l}
                                                                    \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.11999999731779099:\\
                                                                    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\
                                                                    
                                                                    \mathbf{else}:\\
                                                                    \;\;\;\;\sqrt{u1} \cdot \cos \left(6.2831854820251465 \cdot u2\right)\\
                                                                    
                                                                    
                                                                    \end{array}
                                                                    
                                                                    Derivation
                                                                    1. Split input into 2 regimes
                                                                    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.119999997

                                                                      1. Initial program 57.2%

                                                                        \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                      2. Evaluated real constant57.2%

                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                      3. Taylor expanded in u2 around 0

                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                      4. Step-by-step derivation
                                                                        1. Applied rewrites52.4%

                                                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                        2. Step-by-step derivation
                                                                          1. Applied rewrites88.0%

                                                                            \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                          2. Step-by-step derivation
                                                                            1. Applied rewrites88.0%

                                                                              \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]

                                                                            if 0.119999997 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                                                            1. Initial program 57.2%

                                                                              \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                            2. Taylor expanded in u1 around 0

                                                                              \[\leadsto \sqrt{u1} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                            3. Step-by-step derivation
                                                                              1. Applied rewrites76.7%

                                                                                \[\leadsto \sqrt{u1} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                              2. Evaluated real constant76.7%

                                                                                \[\leadsto \sqrt{u1} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                            4. Recombined 2 regimes into one program.
                                                                            5. Add Preprocessing

                                                                            Alternative 10: 88.0% accurate, 1.4× speedup?

                                                                            \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                            \[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                            (FPCore (cosTheta_i u1 u2)
                                                                              :precision binary32
                                                                              :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                      (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                 (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                              (*
                                                                             (sqrt (- (log1p (- u1))))
                                                                             (+ 1.0 (* -19.739209900765786 (pow u2 2.0)))))
                                                                            float code(float cosTheta_i, float u1, float u2) {
                                                                            	return sqrtf(-log1pf(-u1)) * (1.0f + (-19.739209900765786f * powf(u2, 2.0f)));
                                                                            }
                                                                            
                                                                            function code(cosTheta_i, u1, u2)
                                                                            	return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(Float32(1.0) + Float32(Float32(-19.739209900765786) * (u2 ^ Float32(2.0)))))
                                                                            end
                                                                            
                                                                            \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right)
                                                                            
                                                                            Derivation
                                                                            1. Initial program 57.2%

                                                                              \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                            2. Evaluated real constant57.2%

                                                                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                            3. Taylor expanded in u2 around 0

                                                                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                            4. Step-by-step derivation
                                                                              1. Applied rewrites52.4%

                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                              2. Step-by-step derivation
                                                                                1. Applied rewrites88.0%

                                                                                  \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                2. Add Preprocessing

                                                                                Alternative 11: 88.0% accurate, 2.1× speedup?

                                                                                \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                \[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]
                                                                                (FPCore (cosTheta_i u1 u2)
                                                                                  :precision binary32
                                                                                  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                          (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                     (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                  (* (sqrt (- (log1p (- u1)))) (fma (* -19.739209900765786 u2) u2 1.0)))
                                                                                float code(float cosTheta_i, float u1, float u2) {
                                                                                	return sqrtf(-log1pf(-u1)) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                                                                                }
                                                                                
                                                                                function code(cosTheta_i, u1, u2)
                                                                                	return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)))
                                                                                end
                                                                                
                                                                                \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)
                                                                                
                                                                                Derivation
                                                                                1. Initial program 57.2%

                                                                                  \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                2. Evaluated real constant57.2%

                                                                                  \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                3. Taylor expanded in u2 around 0

                                                                                  \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                4. Step-by-step derivation
                                                                                  1. Applied rewrites52.4%

                                                                                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                  2. Step-by-step derivation
                                                                                    1. Applied rewrites88.0%

                                                                                      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                    2. Step-by-step derivation
                                                                                      1. Applied rewrites88.0%

                                                                                        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]
                                                                                      2. Add Preprocessing

                                                                                      Alternative 12: 86.6% accurate, 0.7× speedup?

                                                                                      \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                      \[\begin{array}{l} t_0 := \sqrt{-\log \left(1 - u1\right)}\\ \mathbf{if}\;t\_0 \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.05000000074505806:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \mathsf{fma}\left(-19.739209900765786, u2 \cdot u2, 1\right)\\ \end{array} \]
                                                                                      (FPCore (cosTheta_i u1 u2)
                                                                                        :precision binary32
                                                                                        :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                           (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                        (let* ((t_0 (sqrt (- (log (- 1.0 u1))))))
                                                                                        (if (<= (* t_0 (cos (* (* 2.0 PI) u2))) 0.05000000074505806)
                                                                                          (*
                                                                                           (sqrt (* u1 (+ 1.0 (* 0.5 u1))))
                                                                                           (+ 1.0 (* (* -19.739209900765786 u2) u2)))
                                                                                          (* t_0 (fma -19.739209900765786 (* u2 u2) 1.0)))))
                                                                                      float code(float cosTheta_i, float u1, float u2) {
                                                                                      	float t_0 = sqrtf(-logf((1.0f - u1)));
                                                                                      	float tmp;
                                                                                      	if ((t_0 * cosf(((2.0f * ((float) M_PI)) * u2))) <= 0.05000000074505806f) {
                                                                                      		tmp = sqrtf((u1 * (1.0f + (0.5f * u1)))) * (1.0f + ((-19.739209900765786f * u2) * u2));
                                                                                      	} else {
                                                                                      		tmp = t_0 * fmaf(-19.739209900765786f, (u2 * u2), 1.0f);
                                                                                      	}
                                                                                      	return tmp;
                                                                                      }
                                                                                      
                                                                                      function code(cosTheta_i, u1, u2)
                                                                                      	t_0 = sqrt(Float32(-log(Float32(Float32(1.0) - u1))))
                                                                                      	tmp = Float32(0.0)
                                                                                      	if (Float32(t_0 * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) <= Float32(0.05000000074505806))
                                                                                      		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1)))) * Float32(Float32(1.0) + Float32(Float32(Float32(-19.739209900765786) * u2) * u2)));
                                                                                      	else
                                                                                      		tmp = Float32(t_0 * fma(Float32(-19.739209900765786), Float32(u2 * u2), Float32(1.0)));
                                                                                      	end
                                                                                      	return tmp
                                                                                      end
                                                                                      
                                                                                      \begin{array}{l}
                                                                                      t_0 := \sqrt{-\log \left(1 - u1\right)}\\
                                                                                      \mathbf{if}\;t\_0 \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.05000000074505806:\\
                                                                                      \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right)\\
                                                                                      
                                                                                      \mathbf{else}:\\
                                                                                      \;\;\;\;t\_0 \cdot \mathsf{fma}\left(-19.739209900765786, u2 \cdot u2, 1\right)\\
                                                                                      
                                                                                      
                                                                                      \end{array}
                                                                                      
                                                                                      Derivation
                                                                                      1. Split input into 2 regimes
                                                                                      2. if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0500000007

                                                                                        1. Initial program 57.2%

                                                                                          \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                        2. Evaluated real constant57.2%

                                                                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                        3. Taylor expanded in u2 around 0

                                                                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                        4. Step-by-step derivation
                                                                                          1. Applied rewrites52.4%

                                                                                            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                          2. Taylor expanded in u1 around 0

                                                                                            \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                          3. Step-by-step derivation
                                                                                            1. Applied rewrites79.1%

                                                                                              \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                            2. Step-by-step derivation
                                                                                              1. Applied rewrites79.1%

                                                                                                \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right) \]

                                                                                              if 0.0500000007 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)))

                                                                                              1. Initial program 57.2%

                                                                                                \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                              2. Evaluated real constant57.2%

                                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                              3. Taylor expanded in u2 around 0

                                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                              4. Step-by-step derivation
                                                                                                1. Applied rewrites52.4%

                                                                                                  \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                2. Step-by-step derivation
                                                                                                  1. Applied rewrites52.4%

                                                                                                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786, u2 \cdot u2, 1\right) \]
                                                                                                3. Recombined 2 regimes into one program.
                                                                                                4. Add Preprocessing

                                                                                                Alternative 13: 85.4% accurate, 0.7× speedup?

                                                                                                \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                \[\begin{array}{l} \mathbf{if}\;\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.05000000074505806:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \end{array} \]
                                                                                                (FPCore (cosTheta_i u1 u2)
                                                                                                  :precision binary32
                                                                                                  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                          (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                     (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                  (if (<=
                                                                                                     (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2)))
                                                                                                     0.05000000074505806)
                                                                                                  (*
                                                                                                   (sqrt (* u1 (+ 1.0 (* 0.5 u1))))
                                                                                                   (+ 1.0 (* (* -19.739209900765786 u2) u2)))
                                                                                                  (sqrt (- (log1p (- u1))))))
                                                                                                float code(float cosTheta_i, float u1, float u2) {
                                                                                                	float tmp;
                                                                                                	if ((sqrtf(-logf((1.0f - u1))) * cosf(((2.0f * ((float) M_PI)) * u2))) <= 0.05000000074505806f) {
                                                                                                		tmp = sqrtf((u1 * (1.0f + (0.5f * u1)))) * (1.0f + ((-19.739209900765786f * u2) * u2));
                                                                                                	} else {
                                                                                                		tmp = sqrtf(-log1pf(-u1));
                                                                                                	}
                                                                                                	return tmp;
                                                                                                }
                                                                                                
                                                                                                function code(cosTheta_i, u1, u2)
                                                                                                	tmp = Float32(0.0)
                                                                                                	if (Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) <= Float32(0.05000000074505806))
                                                                                                		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1)))) * Float32(Float32(1.0) + Float32(Float32(Float32(-19.739209900765786) * u2) * u2)));
                                                                                                	else
                                                                                                		tmp = sqrt(Float32(-log1p(Float32(-u1))));
                                                                                                	end
                                                                                                	return tmp
                                                                                                end
                                                                                                
                                                                                                \begin{array}{l}
                                                                                                \mathbf{if}\;\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.05000000074505806:\\
                                                                                                \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right)\\
                                                                                                
                                                                                                \mathbf{else}:\\
                                                                                                \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\
                                                                                                
                                                                                                
                                                                                                \end{array}
                                                                                                
                                                                                                Derivation
                                                                                                1. Split input into 2 regimes
                                                                                                2. if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0500000007

                                                                                                  1. Initial program 57.2%

                                                                                                    \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                  2. Evaluated real constant57.2%

                                                                                                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                                  3. Taylor expanded in u2 around 0

                                                                                                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                                  4. Step-by-step derivation
                                                                                                    1. Applied rewrites52.4%

                                                                                                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                    2. Taylor expanded in u1 around 0

                                                                                                      \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                    3. Step-by-step derivation
                                                                                                      1. Applied rewrites79.1%

                                                                                                        \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                      2. Step-by-step derivation
                                                                                                        1. Applied rewrites79.1%

                                                                                                          \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right) \]

                                                                                                        if 0.0500000007 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)))

                                                                                                        1. Initial program 57.2%

                                                                                                          \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                        2. Taylor expanded in u2 around 0

                                                                                                          \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                        3. Step-by-step derivation
                                                                                                          1. Applied rewrites48.8%

                                                                                                            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                          2. Step-by-step derivation
                                                                                                            1. Applied rewrites79.4%

                                                                                                              \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \]
                                                                                                          3. Recombined 2 regimes into one program.
                                                                                                          4. Add Preprocessing

                                                                                                          Alternative 14: 85.4% accurate, 0.7× speedup?

                                                                                                          \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                          \[\begin{array}{l} \mathbf{if}\;\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.05000000074505806:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \end{array} \]
                                                                                                          (FPCore (cosTheta_i u1 u2)
                                                                                                            :precision binary32
                                                                                                            :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                    (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                               (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                            (if (<=
                                                                                                               (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2)))
                                                                                                               0.05000000074505806)
                                                                                                            (*
                                                                                                             (sqrt (* u1 (+ 1.0 (* 0.5 u1))))
                                                                                                             (fma (* -19.739209900765786 u2) u2 1.0))
                                                                                                            (sqrt (- (log1p (- u1))))))
                                                                                                          float code(float cosTheta_i, float u1, float u2) {
                                                                                                          	float tmp;
                                                                                                          	if ((sqrtf(-logf((1.0f - u1))) * cosf(((2.0f * ((float) M_PI)) * u2))) <= 0.05000000074505806f) {
                                                                                                          		tmp = sqrtf((u1 * (1.0f + (0.5f * u1)))) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                                                                                                          	} else {
                                                                                                          		tmp = sqrtf(-log1pf(-u1));
                                                                                                          	}
                                                                                                          	return tmp;
                                                                                                          }
                                                                                                          
                                                                                                          function code(cosTheta_i, u1, u2)
                                                                                                          	tmp = Float32(0.0)
                                                                                                          	if (Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) <= Float32(0.05000000074505806))
                                                                                                          		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1)))) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)));
                                                                                                          	else
                                                                                                          		tmp = sqrt(Float32(-log1p(Float32(-u1))));
                                                                                                          	end
                                                                                                          	return tmp
                                                                                                          end
                                                                                                          
                                                                                                          \begin{array}{l}
                                                                                                          \mathbf{if}\;\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.05000000074505806:\\
                                                                                                          \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\
                                                                                                          
                                                                                                          \mathbf{else}:\\
                                                                                                          \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\
                                                                                                          
                                                                                                          
                                                                                                          \end{array}
                                                                                                          
                                                                                                          Derivation
                                                                                                          1. Split input into 2 regimes
                                                                                                          2. if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0500000007

                                                                                                            1. Initial program 57.2%

                                                                                                              \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                            2. Evaluated real constant57.2%

                                                                                                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                                            3. Taylor expanded in u2 around 0

                                                                                                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                                            4. Step-by-step derivation
                                                                                                              1. Applied rewrites52.4%

                                                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                              2. Taylor expanded in u1 around 0

                                                                                                                \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                              3. Step-by-step derivation
                                                                                                                1. Applied rewrites79.1%

                                                                                                                  \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                2. Step-by-step derivation
                                                                                                                  1. Applied rewrites79.1%

                                                                                                                    \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]

                                                                                                                  if 0.0500000007 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)))

                                                                                                                  1. Initial program 57.2%

                                                                                                                    \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                  2. Taylor expanded in u2 around 0

                                                                                                                    \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                  3. Step-by-step derivation
                                                                                                                    1. Applied rewrites48.8%

                                                                                                                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                    2. Step-by-step derivation
                                                                                                                      1. Applied rewrites79.4%

                                                                                                                        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \]
                                                                                                                    3. Recombined 2 regimes into one program.
                                                                                                                    4. Add Preprocessing

                                                                                                                    Alternative 15: 85.4% accurate, 0.7× speedup?

                                                                                                                    \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                    \[\begin{array}{l} \mathbf{if}\;\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.05000000074505806:\\ \;\;\;\;\mathsf{fma}\left(-19.739209900765786, u2 \cdot u2, 1\right) \cdot \sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \end{array} \]
                                                                                                                    (FPCore (cosTheta_i u1 u2)
                                                                                                                      :precision binary32
                                                                                                                      :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                              (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                         (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                      (if (<=
                                                                                                                         (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2)))
                                                                                                                         0.05000000074505806)
                                                                                                                      (*
                                                                                                                       (fma -19.739209900765786 (* u2 u2) 1.0)
                                                                                                                       (sqrt (* (fma 0.5 u1 1.0) u1)))
                                                                                                                      (sqrt (- (log1p (- u1))))))
                                                                                                                    float code(float cosTheta_i, float u1, float u2) {
                                                                                                                    	float tmp;
                                                                                                                    	if ((sqrtf(-logf((1.0f - u1))) * cosf(((2.0f * ((float) M_PI)) * u2))) <= 0.05000000074505806f) {
                                                                                                                    		tmp = fmaf(-19.739209900765786f, (u2 * u2), 1.0f) * sqrtf((fmaf(0.5f, u1, 1.0f) * u1));
                                                                                                                    	} else {
                                                                                                                    		tmp = sqrtf(-log1pf(-u1));
                                                                                                                    	}
                                                                                                                    	return tmp;
                                                                                                                    }
                                                                                                                    
                                                                                                                    function code(cosTheta_i, u1, u2)
                                                                                                                    	tmp = Float32(0.0)
                                                                                                                    	if (Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) <= Float32(0.05000000074505806))
                                                                                                                    		tmp = Float32(fma(Float32(-19.739209900765786), Float32(u2 * u2), Float32(1.0)) * sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1)));
                                                                                                                    	else
                                                                                                                    		tmp = sqrt(Float32(-log1p(Float32(-u1))));
                                                                                                                    	end
                                                                                                                    	return tmp
                                                                                                                    end
                                                                                                                    
                                                                                                                    \begin{array}{l}
                                                                                                                    \mathbf{if}\;\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.05000000074505806:\\
                                                                                                                    \;\;\;\;\mathsf{fma}\left(-19.739209900765786, u2 \cdot u2, 1\right) \cdot \sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1}\\
                                                                                                                    
                                                                                                                    \mathbf{else}:\\
                                                                                                                    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\
                                                                                                                    
                                                                                                                    
                                                                                                                    \end{array}
                                                                                                                    
                                                                                                                    Derivation
                                                                                                                    1. Split input into 2 regimes
                                                                                                                    2. if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0500000007

                                                                                                                      1. Initial program 57.2%

                                                                                                                        \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                      2. Evaluated real constant57.2%

                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                                                      3. Taylor expanded in u2 around 0

                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                                                      4. Step-by-step derivation
                                                                                                                        1. Applied rewrites52.4%

                                                                                                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                        2. Taylor expanded in u1 around 0

                                                                                                                          \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                        3. Step-by-step derivation
                                                                                                                          1. Applied rewrites79.1%

                                                                                                                            \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                          2. Step-by-step derivation
                                                                                                                            1. Applied rewrites79.1%

                                                                                                                              \[\leadsto \mathsf{fma}\left(-19.739209900765786, u2 \cdot u2, 1\right) \cdot \sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \]

                                                                                                                            if 0.0500000007 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)))

                                                                                                                            1. Initial program 57.2%

                                                                                                                              \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                            2. Taylor expanded in u2 around 0

                                                                                                                              \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                            3. Step-by-step derivation
                                                                                                                              1. Applied rewrites48.8%

                                                                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                              2. Step-by-step derivation
                                                                                                                                1. Applied rewrites79.4%

                                                                                                                                  \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \]
                                                                                                                              3. Recombined 2 regimes into one program.
                                                                                                                              4. Add Preprocessing

                                                                                                                              Alternative 16: 83.0% accurate, 2.1× speedup?

                                                                                                                              \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                              \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.017999999225139618:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} - 19.739209900765786 \cdot \left(\left(u2 \cdot u2\right) \cdot \sqrt{u1}\right)\\ \end{array} \]
                                                                                                                              (FPCore (cosTheta_i u1 u2)
                                                                                                                                :precision binary32
                                                                                                                                :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                        (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                   (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                (if (<= (* (* 2.0 PI) u2) 0.017999999225139618)
                                                                                                                                (sqrt (- (log1p (- u1))))
                                                                                                                                (- (sqrt u1) (* 19.739209900765786 (* (* u2 u2) (sqrt u1))))))
                                                                                                                              float code(float cosTheta_i, float u1, float u2) {
                                                                                                                              	float tmp;
                                                                                                                              	if (((2.0f * ((float) M_PI)) * u2) <= 0.017999999225139618f) {
                                                                                                                              		tmp = sqrtf(-log1pf(-u1));
                                                                                                                              	} else {
                                                                                                                              		tmp = sqrtf(u1) - (19.739209900765786f * ((u2 * u2) * sqrtf(u1)));
                                                                                                                              	}
                                                                                                                              	return tmp;
                                                                                                                              }
                                                                                                                              
                                                                                                                              function code(cosTheta_i, u1, u2)
                                                                                                                              	tmp = Float32(0.0)
                                                                                                                              	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.017999999225139618))
                                                                                                                              		tmp = sqrt(Float32(-log1p(Float32(-u1))));
                                                                                                                              	else
                                                                                                                              		tmp = Float32(sqrt(u1) - Float32(Float32(19.739209900765786) * Float32(Float32(u2 * u2) * sqrt(u1))));
                                                                                                                              	end
                                                                                                                              	return tmp
                                                                                                                              end
                                                                                                                              
                                                                                                                              \begin{array}{l}
                                                                                                                              \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.017999999225139618:\\
                                                                                                                              \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\
                                                                                                                              
                                                                                                                              \mathbf{else}:\\
                                                                                                                              \;\;\;\;\sqrt{u1} - 19.739209900765786 \cdot \left(\left(u2 \cdot u2\right) \cdot \sqrt{u1}\right)\\
                                                                                                                              
                                                                                                                              
                                                                                                                              \end{array}
                                                                                                                              
                                                                                                                              Derivation
                                                                                                                              1. Split input into 2 regimes
                                                                                                                              2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0179999992

                                                                                                                                1. Initial program 57.2%

                                                                                                                                  \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                2. Taylor expanded in u2 around 0

                                                                                                                                  \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                3. Step-by-step derivation
                                                                                                                                  1. Applied rewrites48.8%

                                                                                                                                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                  2. Step-by-step derivation
                                                                                                                                    1. Applied rewrites79.4%

                                                                                                                                      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \]

                                                                                                                                    if 0.0179999992 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                                                                                                                    1. Initial program 57.2%

                                                                                                                                      \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                    2. Evaluated real constant57.2%

                                                                                                                                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                                                                    3. Taylor expanded in u2 around 0

                                                                                                                                      \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{-173627926472025}{8796093022208} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                                                    4. Step-by-step derivation
                                                                                                                                      1. Applied rewrites52.4%

                                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} + -19.739209900765786 \cdot \left({u2}^{2} \cdot \sqrt{-\log \left(1 - u1\right)}\right) \]
                                                                                                                                      2. Taylor expanded in u1 around 0

                                                                                                                                        \[\leadsto \sqrt{u1} + -19.739209900765786 \cdot \left({u2}^{2} \cdot \sqrt{u1}\right) \]
                                                                                                                                      3. Step-by-step derivation
                                                                                                                                        1. Applied rewrites69.5%

                                                                                                                                          \[\leadsto \sqrt{u1} + -19.739209900765786 \cdot \left({u2}^{2} \cdot \sqrt{u1}\right) \]
                                                                                                                                        2. Step-by-step derivation
                                                                                                                                          1. Applied rewrites69.5%

                                                                                                                                            \[\leadsto \sqrt{u1} - 19.739209900765786 \cdot \left(\left(u2 \cdot u2\right) \cdot \sqrt{u1}\right) \]
                                                                                                                                        3. Recombined 2 regimes into one program.
                                                                                                                                        4. Add Preprocessing

                                                                                                                                        Alternative 17: 83.0% accurate, 2.2× speedup?

                                                                                                                                        \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                        \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.017999999225139618:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot \sqrt{u1}, -19.739209900765786, \sqrt{u1}\right)\\ \end{array} \]
                                                                                                                                        (FPCore (cosTheta_i u1 u2)
                                                                                                                                          :precision binary32
                                                                                                                                          :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                  (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                             (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                          (if (<= (* (* 2.0 PI) u2) 0.017999999225139618)
                                                                                                                                          (sqrt (- (log1p (- u1))))
                                                                                                                                          (fma (* (* u2 u2) (sqrt u1)) -19.739209900765786 (sqrt u1))))
                                                                                                                                        float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                        	float tmp;
                                                                                                                                        	if (((2.0f * ((float) M_PI)) * u2) <= 0.017999999225139618f) {
                                                                                                                                        		tmp = sqrtf(-log1pf(-u1));
                                                                                                                                        	} else {
                                                                                                                                        		tmp = fmaf(((u2 * u2) * sqrtf(u1)), -19.739209900765786f, sqrtf(u1));
                                                                                                                                        	}
                                                                                                                                        	return tmp;
                                                                                                                                        }
                                                                                                                                        
                                                                                                                                        function code(cosTheta_i, u1, u2)
                                                                                                                                        	tmp = Float32(0.0)
                                                                                                                                        	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.017999999225139618))
                                                                                                                                        		tmp = sqrt(Float32(-log1p(Float32(-u1))));
                                                                                                                                        	else
                                                                                                                                        		tmp = fma(Float32(Float32(u2 * u2) * sqrt(u1)), Float32(-19.739209900765786), sqrt(u1));
                                                                                                                                        	end
                                                                                                                                        	return tmp
                                                                                                                                        end
                                                                                                                                        
                                                                                                                                        \begin{array}{l}
                                                                                                                                        \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.017999999225139618:\\
                                                                                                                                        \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\
                                                                                                                                        
                                                                                                                                        \mathbf{else}:\\
                                                                                                                                        \;\;\;\;\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot \sqrt{u1}, -19.739209900765786, \sqrt{u1}\right)\\
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        \end{array}
                                                                                                                                        
                                                                                                                                        Derivation
                                                                                                                                        1. Split input into 2 regimes
                                                                                                                                        2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0179999992

                                                                                                                                          1. Initial program 57.2%

                                                                                                                                            \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                          2. Taylor expanded in u2 around 0

                                                                                                                                            \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                          3. Step-by-step derivation
                                                                                                                                            1. Applied rewrites48.8%

                                                                                                                                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                            2. Step-by-step derivation
                                                                                                                                              1. Applied rewrites79.4%

                                                                                                                                                \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \]

                                                                                                                                              if 0.0179999992 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                                                                                                                              1. Initial program 57.2%

                                                                                                                                                \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                              2. Evaluated real constant57.2%

                                                                                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                                                                              3. Taylor expanded in u2 around 0

                                                                                                                                                \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{-173627926472025}{8796093022208} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                                                              4. Step-by-step derivation
                                                                                                                                                1. Applied rewrites52.4%

                                                                                                                                                  \[\leadsto \sqrt{-\log \left(1 - u1\right)} + -19.739209900765786 \cdot \left({u2}^{2} \cdot \sqrt{-\log \left(1 - u1\right)}\right) \]
                                                                                                                                                2. Step-by-step derivation
                                                                                                                                                  1. Applied rewrites52.4%

                                                                                                                                                    \[\leadsto \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot \sqrt{-\log \left(1 - u1\right)}, -19.739209900765786, \sqrt{-\log \left(1 - u1\right)}\right) \]
                                                                                                                                                  2. Taylor expanded in u1 around 0

                                                                                                                                                    \[\leadsto \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot \sqrt{u1}, -19.739209900765786, \sqrt{u1}\right) \]
                                                                                                                                                  3. Step-by-step derivation
                                                                                                                                                    1. Applied rewrites69.5%

                                                                                                                                                      \[\leadsto \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot \sqrt{u1}, -19.739209900765786, \sqrt{u1}\right) \]
                                                                                                                                                  4. Recombined 2 regimes into one program.
                                                                                                                                                  5. Add Preprocessing

                                                                                                                                                  Alternative 18: 83.0% accurate, 2.2× speedup?

                                                                                                                                                  \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                  \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.017999999225139618:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right)\\ \end{array} \]
                                                                                                                                                  (FPCore (cosTheta_i u1 u2)
                                                                                                                                                    :precision binary32
                                                                                                                                                    :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                            (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                                       (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                    (if (<= (* (* 2.0 PI) u2) 0.017999999225139618)
                                                                                                                                                    (sqrt (- (log1p (- u1))))
                                                                                                                                                    (* (sqrt u1) (+ 1.0 (* (* -19.739209900765786 u2) u2)))))
                                                                                                                                                  float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                  	float tmp;
                                                                                                                                                  	if (((2.0f * ((float) M_PI)) * u2) <= 0.017999999225139618f) {
                                                                                                                                                  		tmp = sqrtf(-log1pf(-u1));
                                                                                                                                                  	} else {
                                                                                                                                                  		tmp = sqrtf(u1) * (1.0f + ((-19.739209900765786f * u2) * u2));
                                                                                                                                                  	}
                                                                                                                                                  	return tmp;
                                                                                                                                                  }
                                                                                                                                                  
                                                                                                                                                  function code(cosTheta_i, u1, u2)
                                                                                                                                                  	tmp = Float32(0.0)
                                                                                                                                                  	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.017999999225139618))
                                                                                                                                                  		tmp = sqrt(Float32(-log1p(Float32(-u1))));
                                                                                                                                                  	else
                                                                                                                                                  		tmp = Float32(sqrt(u1) * Float32(Float32(1.0) + Float32(Float32(Float32(-19.739209900765786) * u2) * u2)));
                                                                                                                                                  	end
                                                                                                                                                  	return tmp
                                                                                                                                                  end
                                                                                                                                                  
                                                                                                                                                  \begin{array}{l}
                                                                                                                                                  \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.017999999225139618:\\
                                                                                                                                                  \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\
                                                                                                                                                  
                                                                                                                                                  \mathbf{else}:\\
                                                                                                                                                  \;\;\;\;\sqrt{u1} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right)\\
                                                                                                                                                  
                                                                                                                                                  
                                                                                                                                                  \end{array}
                                                                                                                                                  
                                                                                                                                                  Derivation
                                                                                                                                                  1. Split input into 2 regimes
                                                                                                                                                  2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0179999992

                                                                                                                                                    1. Initial program 57.2%

                                                                                                                                                      \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                    2. Taylor expanded in u2 around 0

                                                                                                                                                      \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                                    3. Step-by-step derivation
                                                                                                                                                      1. Applied rewrites48.8%

                                                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                                      2. Step-by-step derivation
                                                                                                                                                        1. Applied rewrites79.4%

                                                                                                                                                          \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \]

                                                                                                                                                        if 0.0179999992 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                                                                                                                                        1. Initial program 57.2%

                                                                                                                                                          \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                        2. Evaluated real constant57.2%

                                                                                                                                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                                                                                        3. Taylor expanded in u2 around 0

                                                                                                                                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                                                                                        4. Step-by-step derivation
                                                                                                                                                          1. Applied rewrites52.4%

                                                                                                                                                            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                          2. Taylor expanded in u1 around 0

                                                                                                                                                            \[\leadsto \sqrt{u1} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                          3. Step-by-step derivation
                                                                                                                                                            1. Applied rewrites69.5%

                                                                                                                                                              \[\leadsto \sqrt{u1} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                            2. Step-by-step derivation
                                                                                                                                                              1. Applied rewrites69.5%

                                                                                                                                                                \[\leadsto \sqrt{u1} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right) \]
                                                                                                                                                            3. Recombined 2 regimes into one program.
                                                                                                                                                            4. Add Preprocessing

                                                                                                                                                            Alternative 19: 79.4% accurate, 0.8× speedup?

                                                                                                                                                            \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                            \[\begin{array}{l} t_0 := \sqrt{-\log \left(1 - u1\right)}\\ \mathbf{if}\;t\_0 \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.025200000032782555:\\ \;\;\;\;\sqrt{u1} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                                                                                                                                                            (FPCore (cosTheta_i u1 u2)
                                                                                                                                                              :precision binary32
                                                                                                                                                              :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                                      (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                                                 (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                              (let* ((t_0 (sqrt (- (log (- 1.0 u1))))))
                                                                                                                                                              (if (<= (* t_0 (cos (* (* 2.0 PI) u2))) 0.025200000032782555)
                                                                                                                                                                (* (sqrt u1) (+ 1.0 (* (* -19.739209900765786 u2) u2)))
                                                                                                                                                                t_0)))
                                                                                                                                                            float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                            	float t_0 = sqrtf(-logf((1.0f - u1)));
                                                                                                                                                            	float tmp;
                                                                                                                                                            	if ((t_0 * cosf(((2.0f * ((float) M_PI)) * u2))) <= 0.025200000032782555f) {
                                                                                                                                                            		tmp = sqrtf(u1) * (1.0f + ((-19.739209900765786f * u2) * u2));
                                                                                                                                                            	} else {
                                                                                                                                                            		tmp = t_0;
                                                                                                                                                            	}
                                                                                                                                                            	return tmp;
                                                                                                                                                            }
                                                                                                                                                            
                                                                                                                                                            function code(cosTheta_i, u1, u2)
                                                                                                                                                            	t_0 = sqrt(Float32(-log(Float32(Float32(1.0) - u1))))
                                                                                                                                                            	tmp = Float32(0.0)
                                                                                                                                                            	if (Float32(t_0 * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) <= Float32(0.025200000032782555))
                                                                                                                                                            		tmp = Float32(sqrt(u1) * Float32(Float32(1.0) + Float32(Float32(Float32(-19.739209900765786) * u2) * u2)));
                                                                                                                                                            	else
                                                                                                                                                            		tmp = t_0;
                                                                                                                                                            	end
                                                                                                                                                            	return tmp
                                                                                                                                                            end
                                                                                                                                                            
                                                                                                                                                            function tmp_2 = code(cosTheta_i, u1, u2)
                                                                                                                                                            	t_0 = sqrt(-log((single(1.0) - u1)));
                                                                                                                                                            	tmp = single(0.0);
                                                                                                                                                            	if ((t_0 * cos(((single(2.0) * single(pi)) * u2))) <= single(0.025200000032782555))
                                                                                                                                                            		tmp = sqrt(u1) * (single(1.0) + ((single(-19.739209900765786) * u2) * u2));
                                                                                                                                                            	else
                                                                                                                                                            		tmp = t_0;
                                                                                                                                                            	end
                                                                                                                                                            	tmp_2 = tmp;
                                                                                                                                                            end
                                                                                                                                                            
                                                                                                                                                            \begin{array}{l}
                                                                                                                                                            t_0 := \sqrt{-\log \left(1 - u1\right)}\\
                                                                                                                                                            \mathbf{if}\;t\_0 \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.025200000032782555:\\
                                                                                                                                                            \;\;\;\;\sqrt{u1} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right)\\
                                                                                                                                                            
                                                                                                                                                            \mathbf{else}:\\
                                                                                                                                                            \;\;\;\;t\_0\\
                                                                                                                                                            
                                                                                                                                                            
                                                                                                                                                            \end{array}
                                                                                                                                                            
                                                                                                                                                            Derivation
                                                                                                                                                            1. Split input into 2 regimes
                                                                                                                                                            2. if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0252

                                                                                                                                                              1. Initial program 57.2%

                                                                                                                                                                \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                              2. Evaluated real constant57.2%

                                                                                                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                                                                                              3. Taylor expanded in u2 around 0

                                                                                                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                                                                                              4. Step-by-step derivation
                                                                                                                                                                1. Applied rewrites52.4%

                                                                                                                                                                  \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                                2. Taylor expanded in u1 around 0

                                                                                                                                                                  \[\leadsto \sqrt{u1} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                                3. Step-by-step derivation
                                                                                                                                                                  1. Applied rewrites69.5%

                                                                                                                                                                    \[\leadsto \sqrt{u1} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                                  2. Step-by-step derivation
                                                                                                                                                                    1. Applied rewrites69.5%

                                                                                                                                                                      \[\leadsto \sqrt{u1} \cdot \left(1 + \left(-19.739209900765786 \cdot u2\right) \cdot u2\right) \]

                                                                                                                                                                    if 0.0252 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)))

                                                                                                                                                                    1. Initial program 57.2%

                                                                                                                                                                      \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                    2. Taylor expanded in u2 around 0

                                                                                                                                                                      \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                                                    3. Step-by-step derivation
                                                                                                                                                                      1. Applied rewrites48.8%

                                                                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                                                    4. Recombined 2 regimes into one program.
                                                                                                                                                                    5. Add Preprocessing

                                                                                                                                                                    Alternative 20: 79.4% accurate, 0.8× speedup?

                                                                                                                                                                    \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                                    \[\begin{array}{l} t_0 := \sqrt{-\log \left(1 - u1\right)}\\ \mathbf{if}\;t\_0 \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.025200000032782555:\\ \;\;\;\;\sqrt{u1} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                                                                                                                                                                    (FPCore (cosTheta_i u1 u2)
                                                                                                                                                                      :precision binary32
                                                                                                                                                                      :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                                              (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                                                         (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                                      (let* ((t_0 (sqrt (- (log (- 1.0 u1))))))
                                                                                                                                                                      (if (<= (* t_0 (cos (* (* 2.0 PI) u2))) 0.025200000032782555)
                                                                                                                                                                        (* (sqrt u1) (fma (* -19.739209900765786 u2) u2 1.0))
                                                                                                                                                                        t_0)))
                                                                                                                                                                    float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                    	float t_0 = sqrtf(-logf((1.0f - u1)));
                                                                                                                                                                    	float tmp;
                                                                                                                                                                    	if ((t_0 * cosf(((2.0f * ((float) M_PI)) * u2))) <= 0.025200000032782555f) {
                                                                                                                                                                    		tmp = sqrtf(u1) * fmaf((-19.739209900765786f * u2), u2, 1.0f);
                                                                                                                                                                    	} else {
                                                                                                                                                                    		tmp = t_0;
                                                                                                                                                                    	}
                                                                                                                                                                    	return tmp;
                                                                                                                                                                    }
                                                                                                                                                                    
                                                                                                                                                                    function code(cosTheta_i, u1, u2)
                                                                                                                                                                    	t_0 = sqrt(Float32(-log(Float32(Float32(1.0) - u1))))
                                                                                                                                                                    	tmp = Float32(0.0)
                                                                                                                                                                    	if (Float32(t_0 * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) <= Float32(0.025200000032782555))
                                                                                                                                                                    		tmp = Float32(sqrt(u1) * fma(Float32(Float32(-19.739209900765786) * u2), u2, Float32(1.0)));
                                                                                                                                                                    	else
                                                                                                                                                                    		tmp = t_0;
                                                                                                                                                                    	end
                                                                                                                                                                    	return tmp
                                                                                                                                                                    end
                                                                                                                                                                    
                                                                                                                                                                    \begin{array}{l}
                                                                                                                                                                    t_0 := \sqrt{-\log \left(1 - u1\right)}\\
                                                                                                                                                                    \mathbf{if}\;t\_0 \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.025200000032782555:\\
                                                                                                                                                                    \;\;\;\;\sqrt{u1} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right)\\
                                                                                                                                                                    
                                                                                                                                                                    \mathbf{else}:\\
                                                                                                                                                                    \;\;\;\;t\_0\\
                                                                                                                                                                    
                                                                                                                                                                    
                                                                                                                                                                    \end{array}
                                                                                                                                                                    
                                                                                                                                                                    Derivation
                                                                                                                                                                    1. Split input into 2 regimes
                                                                                                                                                                    2. if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0252

                                                                                                                                                                      1. Initial program 57.2%

                                                                                                                                                                        \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                      2. Evaluated real constant57.2%

                                                                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(6.2831854820251465 \cdot u2\right) \]
                                                                                                                                                                      3. Taylor expanded in u2 around 0

                                                                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + \frac{-173627926472025}{8796093022208} \cdot {u2}^{2}\right) \]
                                                                                                                                                                      4. Step-by-step derivation
                                                                                                                                                                        1. Applied rewrites52.4%

                                                                                                                                                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                                        2. Taylor expanded in u1 around 0

                                                                                                                                                                          \[\leadsto \sqrt{u1} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                                        3. Step-by-step derivation
                                                                                                                                                                          1. Applied rewrites69.5%

                                                                                                                                                                            \[\leadsto \sqrt{u1} \cdot \left(1 + -19.739209900765786 \cdot {u2}^{2}\right) \]
                                                                                                                                                                          2. Step-by-step derivation
                                                                                                                                                                            1. Applied rewrites69.5%

                                                                                                                                                                              \[\leadsto \sqrt{u1} \cdot \mathsf{fma}\left(-19.739209900765786 \cdot u2, u2, 1\right) \]

                                                                                                                                                                            if 0.0252 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)))

                                                                                                                                                                            1. Initial program 57.2%

                                                                                                                                                                              \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                            2. Taylor expanded in u2 around 0

                                                                                                                                                                              \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                                                            3. Step-by-step derivation
                                                                                                                                                                              1. Applied rewrites48.8%

                                                                                                                                                                                \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                                                            4. Recombined 2 regimes into one program.
                                                                                                                                                                            5. Add Preprocessing

                                                                                                                                                                            Alternative 21: 78.4% accurate, 0.8× speedup?

                                                                                                                                                                            \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                                            \[\begin{array}{l} t_0 := \sqrt{-\log \left(1 - u1\right)}\\ \mathbf{if}\;t\_0 \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.07999999821186066:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                                                                                                                                                                            (FPCore (cosTheta_i u1 u2)
                                                                                                                                                                              :precision binary32
                                                                                                                                                                              :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                                                      (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                                                                 (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                                              (let* ((t_0 (sqrt (- (log (- 1.0 u1))))))
                                                                                                                                                                              (if (<= (* t_0 (cos (* (* 2.0 PI) u2))) 0.07999999821186066)
                                                                                                                                                                                (sqrt (fma (* 0.5 u1) u1 u1))
                                                                                                                                                                                t_0)))
                                                                                                                                                                            float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                            	float t_0 = sqrtf(-logf((1.0f - u1)));
                                                                                                                                                                            	float tmp;
                                                                                                                                                                            	if ((t_0 * cosf(((2.0f * ((float) M_PI)) * u2))) <= 0.07999999821186066f) {
                                                                                                                                                                            		tmp = sqrtf(fmaf((0.5f * u1), u1, u1));
                                                                                                                                                                            	} else {
                                                                                                                                                                            		tmp = t_0;
                                                                                                                                                                            	}
                                                                                                                                                                            	return tmp;
                                                                                                                                                                            }
                                                                                                                                                                            
                                                                                                                                                                            function code(cosTheta_i, u1, u2)
                                                                                                                                                                            	t_0 = sqrt(Float32(-log(Float32(Float32(1.0) - u1))))
                                                                                                                                                                            	tmp = Float32(0.0)
                                                                                                                                                                            	if (Float32(t_0 * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) <= Float32(0.07999999821186066))
                                                                                                                                                                            		tmp = sqrt(fma(Float32(Float32(0.5) * u1), u1, u1));
                                                                                                                                                                            	else
                                                                                                                                                                            		tmp = t_0;
                                                                                                                                                                            	end
                                                                                                                                                                            	return tmp
                                                                                                                                                                            end
                                                                                                                                                                            
                                                                                                                                                                            \begin{array}{l}
                                                                                                                                                                            t_0 := \sqrt{-\log \left(1 - u1\right)}\\
                                                                                                                                                                            \mathbf{if}\;t\_0 \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \leq 0.07999999821186066:\\
                                                                                                                                                                            \;\;\;\;\sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)}\\
                                                                                                                                                                            
                                                                                                                                                                            \mathbf{else}:\\
                                                                                                                                                                            \;\;\;\;t\_0\\
                                                                                                                                                                            
                                                                                                                                                                            
                                                                                                                                                                            \end{array}
                                                                                                                                                                            
                                                                                                                                                                            Derivation
                                                                                                                                                                            1. Split input into 2 regimes
                                                                                                                                                                            2. if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0799999982

                                                                                                                                                                              1. Initial program 57.2%

                                                                                                                                                                                \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                              2. Taylor expanded in u2 around 0

                                                                                                                                                                                \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                                                              3. Step-by-step derivation
                                                                                                                                                                                1. Applied rewrites48.8%

                                                                                                                                                                                  \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                                                                2. Taylor expanded in u1 around 0

                                                                                                                                                                                  \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \]
                                                                                                                                                                                3. Step-by-step derivation
                                                                                                                                                                                  1. Applied rewrites72.4%

                                                                                                                                                                                    \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \]
                                                                                                                                                                                  2. Step-by-step derivation
                                                                                                                                                                                    1. Applied rewrites72.4%

                                                                                                                                                                                      \[\leadsto \sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \]

                                                                                                                                                                                    if 0.0799999982 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)))

                                                                                                                                                                                    1. Initial program 57.2%

                                                                                                                                                                                      \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                                    2. Taylor expanded in u2 around 0

                                                                                                                                                                                      \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                                                                    3. Step-by-step derivation
                                                                                                                                                                                      1. Applied rewrites48.8%

                                                                                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                                                                    4. Recombined 2 regimes into one program.
                                                                                                                                                                                    5. Add Preprocessing

                                                                                                                                                                                    Alternative 22: 72.4% accurate, 5.1× speedup?

                                                                                                                                                                                    \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                                                    \[\sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \]
                                                                                                                                                                                    (FPCore (cosTheta_i u1 u2)
                                                                                                                                                                                      :precision binary32
                                                                                                                                                                                      :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                                                              (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                                                                         (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                                                      (sqrt (fma (* 0.5 u1) u1 u1)))
                                                                                                                                                                                    float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                                    	return sqrtf(fmaf((0.5f * u1), u1, u1));
                                                                                                                                                                                    }
                                                                                                                                                                                    
                                                                                                                                                                                    function code(cosTheta_i, u1, u2)
                                                                                                                                                                                    	return sqrt(fma(Float32(Float32(0.5) * u1), u1, u1))
                                                                                                                                                                                    end
                                                                                                                                                                                    
                                                                                                                                                                                    \sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)}
                                                                                                                                                                                    
                                                                                                                                                                                    Derivation
                                                                                                                                                                                    1. Initial program 57.2%

                                                                                                                                                                                      \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                                    2. Taylor expanded in u2 around 0

                                                                                                                                                                                      \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                                                                    3. Step-by-step derivation
                                                                                                                                                                                      1. Applied rewrites48.8%

                                                                                                                                                                                        \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                                                                      2. Taylor expanded in u1 around 0

                                                                                                                                                                                        \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \]
                                                                                                                                                                                      3. Step-by-step derivation
                                                                                                                                                                                        1. Applied rewrites72.4%

                                                                                                                                                                                          \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \]
                                                                                                                                                                                        2. Step-by-step derivation
                                                                                                                                                                                          1. Applied rewrites72.4%

                                                                                                                                                                                            \[\leadsto \sqrt{\mathsf{fma}\left(0.5 \cdot u1, u1, u1\right)} \]
                                                                                                                                                                                          2. Add Preprocessing

                                                                                                                                                                                          Alternative 23: 72.4% accurate, 5.1× speedup?

                                                                                                                                                                                          \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                                                          \[\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \]
                                                                                                                                                                                          (FPCore (cosTheta_i u1 u2)
                                                                                                                                                                                            :precision binary32
                                                                                                                                                                                            :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                                                                    (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                                                                               (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                                                            (sqrt (* (fma 0.5 u1 1.0) u1)))
                                                                                                                                                                                          float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                                          	return sqrtf((fmaf(0.5f, u1, 1.0f) * u1));
                                                                                                                                                                                          }
                                                                                                                                                                                          
                                                                                                                                                                                          function code(cosTheta_i, u1, u2)
                                                                                                                                                                                          	return sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1))
                                                                                                                                                                                          end
                                                                                                                                                                                          
                                                                                                                                                                                          \sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1}
                                                                                                                                                                                          
                                                                                                                                                                                          Derivation
                                                                                                                                                                                          1. Initial program 57.2%

                                                                                                                                                                                            \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                                          2. Taylor expanded in u2 around 0

                                                                                                                                                                                            \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                                                                          3. Step-by-step derivation
                                                                                                                                                                                            1. Applied rewrites48.8%

                                                                                                                                                                                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                                                                            2. Taylor expanded in u1 around 0

                                                                                                                                                                                              \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \]
                                                                                                                                                                                            3. Step-by-step derivation
                                                                                                                                                                                              1. Applied rewrites72.4%

                                                                                                                                                                                                \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \]
                                                                                                                                                                                              2. Step-by-step derivation
                                                                                                                                                                                                1. Applied rewrites72.4%

                                                                                                                                                                                                  \[\leadsto \sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \]
                                                                                                                                                                                                2. Add Preprocessing

                                                                                                                                                                                                Alternative 24: 64.7% accurate, 18.5× speedup?

                                                                                                                                                                                                \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                                                                \[\sqrt{u1} \]
                                                                                                                                                                                                (FPCore (cosTheta_i u1 u2)
                                                                                                                                                                                                  :precision binary32
                                                                                                                                                                                                  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                                                                          (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                                                                                     (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                                                                  (sqrt u1))
                                                                                                                                                                                                float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                                                	return sqrtf(u1);
                                                                                                                                                                                                }
                                                                                                                                                                                                
                                                                                                                                                                                                real(4) function code(costheta_i, u1, u2)
                                                                                                                                                                                                use fmin_fmax_functions
                                                                                                                                                                                                    real(4), intent (in) :: costheta_i
                                                                                                                                                                                                    real(4), intent (in) :: u1
                                                                                                                                                                                                    real(4), intent (in) :: u2
                                                                                                                                                                                                    code = sqrt(u1)
                                                                                                                                                                                                end function
                                                                                                                                                                                                
                                                                                                                                                                                                function code(cosTheta_i, u1, u2)
                                                                                                                                                                                                	return sqrt(u1)
                                                                                                                                                                                                end
                                                                                                                                                                                                
                                                                                                                                                                                                function tmp = code(cosTheta_i, u1, u2)
                                                                                                                                                                                                	tmp = sqrt(u1);
                                                                                                                                                                                                end
                                                                                                                                                                                                
                                                                                                                                                                                                \sqrt{u1}
                                                                                                                                                                                                
                                                                                                                                                                                                Derivation
                                                                                                                                                                                                1. Initial program 57.2%

                                                                                                                                                                                                  \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                                                2. Taylor expanded in u2 around 0

                                                                                                                                                                                                  \[\leadsto \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} \]
                                                                                                                                                                                                3. Step-by-step derivation
                                                                                                                                                                                                  1. Applied rewrites48.8%

                                                                                                                                                                                                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \]
                                                                                                                                                                                                  2. Taylor expanded in u1 around 0

                                                                                                                                                                                                    \[\leadsto \sqrt{u1} \]
                                                                                                                                                                                                  3. Step-by-step derivation
                                                                                                                                                                                                    1. Applied rewrites64.7%

                                                                                                                                                                                                      \[\leadsto \sqrt{u1} \]
                                                                                                                                                                                                    2. Add Preprocessing

                                                                                                                                                                                                    Reproduce

                                                                                                                                                                                                    ?
                                                                                                                                                                                                    herbie shell --seed 2026070 
                                                                                                                                                                                                    (FPCore (cosTheta_i u1 u2)
                                                                                                                                                                                                      :name "Beckmann Sample, near normal, slope_x"
                                                                                                                                                                                                      :precision binary32
                                                                                                                                                                                                      :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 1.0))) (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                                                                      (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2))))