Beckmann Sample, near normal, slope_y

Percentage Accurate: 58.2% → 98.3%
Time: 8.9s
Alternatives: 19
Speedup: 6.2×

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 \sin \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)))) (sin (* (* 2.0 PI) u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-logf((1.0f - u1))) * sinf(((2.0f * ((float) M_PI)) * u2));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * sin(Float32(Float32(Float32(2.0) * Float32(pi)) * u2)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = sqrt(-log((single(1.0) - u1))) * sin(((single(2.0) * single(pi)) * u2));
end
\sqrt{-\log \left(1 - u1\right)} \cdot \sin \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 19 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: 58.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 \sin \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)))) (sin (* (* 2.0 PI) u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-logf((1.0f - u1))) * sinf(((2.0f * ((float) M_PI)) * u2));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * sin(Float32(Float32(Float32(2.0) * Float32(pi)) * u2)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = sqrt(-log((single(1.0) - u1))) * sin(((single(2.0) * single(pi)) * u2));
end
\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right)

Alternative 1: 98.3% 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 \sin \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)))) (sin (* 6.2831854820251465 u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-log1pf(-u1)) * sinf((6.2831854820251465f * u2));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * sin(Float32(Float32(6.2831854820251465) * u2)))
end
\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(6.2831854820251465 \cdot u2\right)
Derivation
  1. Initial program 58.2%

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

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

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

    Alternative 2: 96.9% 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 := -\log \left(1 - u1\right)\\ \mathbf{if}\;t\_0 \leq 0.0024999999441206455:\\ \;\;\;\;\mathsf{fma}\left(u1 \cdot \sqrt{u1}, 0.25, \sqrt{u1}\right) \cdot \sin \left(u2 \cdot 6.2831854820251465\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_0} \cdot \sin \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 (- (log (- 1.0 u1)))))
      (if (<= t_0 0.0024999999441206455)
        (*
         (fma (* u1 (sqrt u1)) 0.25 (sqrt u1))
         (sin (* u2 6.2831854820251465)))
        (* (sqrt t_0) (sin (* 6.2831854820251465 u2))))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = -logf((1.0f - u1));
    	float tmp;
    	if (t_0 <= 0.0024999999441206455f) {
    		tmp = fmaf((u1 * sqrtf(u1)), 0.25f, sqrtf(u1)) * sinf((u2 * 6.2831854820251465f));
    	} else {
    		tmp = sqrtf(t_0) * sinf((6.2831854820251465f * u2));
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(-log(Float32(Float32(1.0) - u1)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.0024999999441206455))
    		tmp = Float32(fma(Float32(u1 * sqrt(u1)), Float32(0.25), sqrt(u1)) * sin(Float32(u2 * Float32(6.2831854820251465))));
    	else
    		tmp = Float32(sqrt(t_0) * sin(Float32(Float32(6.2831854820251465) * u2)));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    t_0 := -\log \left(1 - u1\right)\\
    \mathbf{if}\;t\_0 \leq 0.0024999999441206455:\\
    \;\;\;\;\mathsf{fma}\left(u1 \cdot \sqrt{u1}, 0.25, \sqrt{u1}\right) \cdot \sin \left(u2 \cdot 6.2831854820251465\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sqrt{t\_0} \cdot \sin \left(6.2831854820251465 \cdot u2\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1))) < 0.00249999994

      1. Initial program 58.2%

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

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

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

            \[\leadsto \mathsf{fma}\left(u1 \cdot \sqrt{u1}, 0.25, \sqrt{u1}\right) \cdot \sin \left(u2 \cdot \left(\pi + \pi\right)\right) \]
          2. Evaluated real constant88.0%

            \[\leadsto \mathsf{fma}\left(u1 \cdot \sqrt{u1}, 0.25, \sqrt{u1}\right) \cdot \sin \left(u2 \cdot 6.2831854820251465\right) \]

          if 0.00249999994 < (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))

          1. Initial program 58.2%

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

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

        Alternative 3: 96.8% 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 := \sin \left(6.2831854820251465 \cdot u2\right)\\ t_1 := -\log \left(1 - u1\right)\\ \mathbf{if}\;t\_1 \leq 0.0024999999441206455:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1} \cdot 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 (sin (* 6.2831854820251465 u2)))
               (t_1 (- (log (- 1.0 u1)))))
          (if (<= t_1 0.0024999999441206455)
            (* (sqrt (* (fma 0.5 u1 1.0) u1)) t_0)
            (* (sqrt t_1) t_0))))
        float code(float cosTheta_i, float u1, float u2) {
        	float t_0 = sinf((6.2831854820251465f * u2));
        	float t_1 = -logf((1.0f - u1));
        	float tmp;
        	if (t_1 <= 0.0024999999441206455f) {
        		tmp = sqrtf((fmaf(0.5f, u1, 1.0f) * u1)) * t_0;
        	} else {
        		tmp = sqrtf(t_1) * t_0;
        	}
        	return tmp;
        }
        
        function code(cosTheta_i, u1, u2)
        	t_0 = sin(Float32(Float32(6.2831854820251465) * u2))
        	t_1 = Float32(-log(Float32(Float32(1.0) - u1)))
        	tmp = Float32(0.0)
        	if (t_1 <= Float32(0.0024999999441206455))
        		tmp = Float32(sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1)) * t_0);
        	else
        		tmp = Float32(sqrt(t_1) * t_0);
        	end
        	return tmp
        end
        
        \begin{array}{l}
        t_0 := \sin \left(6.2831854820251465 \cdot u2\right)\\
        t_1 := -\log \left(1 - u1\right)\\
        \mathbf{if}\;t\_1 \leq 0.0024999999441206455:\\
        \;\;\;\;\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot t\_0\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{t\_1} \cdot t\_0\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1))) < 0.00249999994

          1. Initial program 58.2%

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

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

            \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \sin \left(6.2831854820251465 \cdot u2\right) \]
          4. Step-by-step derivation
            1. Applied rewrites87.7%

              \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \sin \left(6.2831854820251465 \cdot u2\right) \]
            2. Step-by-step derivation
              1. Applied rewrites87.7%

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

              if 0.00249999994 < (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))

              1. Initial program 58.2%

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

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

            Alternative 4: 96.1% 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.05000000074505806:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot \sin \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.05000000074505806)
              (*
               (sqrt (- (log1p (- u1))))
               (* u2 (fma -41.34170150756836 (* u2 u2) (+ PI PI))))
              (* (sqrt (* (fma 0.5 u1 1.0) u1)) (sin (* 6.2831854820251465 u2)))))
            float code(float cosTheta_i, float u1, float u2) {
            	float tmp;
            	if (((2.0f * ((float) M_PI)) * u2) <= 0.05000000074505806f) {
            		tmp = sqrtf(-log1pf(-u1)) * (u2 * fmaf(-41.34170150756836f, (u2 * u2), (((float) M_PI) + ((float) M_PI))));
            	} else {
            		tmp = sqrtf((fmaf(0.5f, u1, 1.0f) * u1)) * sinf((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.05000000074505806))
            		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * fma(Float32(-41.34170150756836), Float32(u2 * u2), Float32(Float32(pi) + Float32(pi)))));
            	else
            		tmp = Float32(sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1)) * sin(Float32(Float32(6.2831854820251465) * u2)));
            	end
            	return tmp
            end
            
            \begin{array}{l}
            \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.05000000074505806:\\
            \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot \sin \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.0500000007

              1. Initial program 58.2%

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

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

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

                    \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right), u2 \cdot u2, \pi + \pi\right)\right) \]
                  2. Evaluated real constant54.3%

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

                      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right) \]

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

                    1. Initial program 58.2%

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

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

                      \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \sin \left(6.2831854820251465 \cdot u2\right) \]
                    4. Step-by-step derivation
                      1. Applied rewrites87.7%

                        \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \sin \left(6.2831854820251465 \cdot u2\right) \]
                      2. Step-by-step derivation
                        1. Applied rewrites87.7%

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

                      Alternative 5: 94.4% 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.25:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{u1 \cdot \sin \left(2 \cdot \left(u2 \cdot \pi\right)\right)}{\sqrt{u1}}\\ \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.25)
                        (*
                         (sqrt (- (log1p (- u1))))
                         (* u2 (fma -41.34170150756836 (* u2 u2) (+ PI PI))))
                        (/ (* u1 (sin (* 2.0 (* u2 PI)))) (sqrt u1))))
                      float code(float cosTheta_i, float u1, float u2) {
                      	float tmp;
                      	if (((2.0f * ((float) M_PI)) * u2) <= 0.25f) {
                      		tmp = sqrtf(-log1pf(-u1)) * (u2 * fmaf(-41.34170150756836f, (u2 * u2), (((float) M_PI) + ((float) M_PI))));
                      	} else {
                      		tmp = (u1 * sinf((2.0f * (u2 * ((float) M_PI))))) / 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.25))
                      		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * fma(Float32(-41.34170150756836), Float32(u2 * u2), Float32(Float32(pi) + Float32(pi)))));
                      	else
                      		tmp = Float32(Float32(u1 * sin(Float32(Float32(2.0) * Float32(u2 * Float32(pi))))) / sqrt(u1));
                      	end
                      	return tmp
                      end
                      
                      \begin{array}{l}
                      \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.25:\\
                      \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{u1 \cdot \sin \left(2 \cdot \left(u2 \cdot \pi\right)\right)}{\sqrt{u1}}\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.25

                        1. Initial program 58.2%

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

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

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

                              \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right), u2 \cdot u2, \pi + \pi\right)\right) \]
                            2. Evaluated real constant54.3%

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

                                \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right) \]

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

                              1. Initial program 58.2%

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

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

                                  \[\leadsto \mathsf{fma}\left(0.25, \frac{{u1}^{2} \cdot \sin \left(2 \cdot \left(u2 \cdot \pi\right)\right)}{\sqrt{u1}}, \sin \left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{u1}\right) \]
                                2. Step-by-step derivation
                                  1. Applied rewrites87.9%

                                    \[\leadsto \frac{\mathsf{fma}\left(\sin \left(u2 \cdot \left(\pi + \pi\right)\right), u1, \left(0.25 \cdot \sin \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \left(u1 \cdot u1\right)\right)}{\sqrt{u1}} \]
                                  2. Taylor expanded in u2 around 0

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

                                      \[\leadsto \frac{u2 \cdot \mathsf{fma}\left(0.5, {u1}^{2} \cdot \pi, 2 \cdot \left(u1 \cdot \pi\right)\right)}{\sqrt{u1}} \]
                                    2. Taylor expanded in u1 around 0

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

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

                                    Alternative 6: 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.25:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \sin \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.25)
                                      (*
                                       (sqrt (- (log1p (- u1))))
                                       (* u2 (fma -41.34170150756836 (* u2 u2) (+ PI PI))))
                                      (* (sqrt u1) (sin (* 6.2831854820251465 u2)))))
                                    float code(float cosTheta_i, float u1, float u2) {
                                    	float tmp;
                                    	if (((2.0f * ((float) M_PI)) * u2) <= 0.25f) {
                                    		tmp = sqrtf(-log1pf(-u1)) * (u2 * fmaf(-41.34170150756836f, (u2 * u2), (((float) M_PI) + ((float) M_PI))));
                                    	} else {
                                    		tmp = sqrtf(u1) * sinf((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.25))
                                    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * fma(Float32(-41.34170150756836), Float32(u2 * u2), Float32(Float32(pi) + Float32(pi)))));
                                    	else
                                    		tmp = Float32(sqrt(u1) * sin(Float32(Float32(6.2831854820251465) * u2)));
                                    	end
                                    	return tmp
                                    end
                                    
                                    \begin{array}{l}
                                    \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.25:\\
                                    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right)\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\sqrt{u1} \cdot \sin \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.25

                                      1. Initial program 58.2%

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

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

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

                                            \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right), u2 \cdot u2, \pi + \pi\right)\right) \]
                                          2. Evaluated real constant54.3%

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

                                              \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right) \]

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

                                            1. Initial program 58.2%

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

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

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

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

                                            Alternative 7: 89.1% accurate, 1.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)\]
                                            \[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\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))))
                                             (* u2 (fma -41.34170150756836 (* u2 u2) (+ PI PI)))))
                                            float code(float cosTheta_i, float u1, float u2) {
                                            	return sqrtf(-log1pf(-u1)) * (u2 * fmaf(-41.34170150756836f, (u2 * u2), (((float) M_PI) + ((float) M_PI))));
                                            }
                                            
                                            function code(cosTheta_i, u1, u2)
                                            	return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * fma(Float32(-41.34170150756836), Float32(u2 * u2), Float32(Float32(pi) + Float32(pi)))))
                                            end
                                            
                                            \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right)
                                            
                                            Derivation
                                            1. Initial program 58.2%

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

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

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

                                                  \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right), u2 \cdot u2, \pi + \pi\right)\right) \]
                                                2. Evaluated real constant54.3%

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

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

                                                  Alternative 8: 87.9% accurate, 1.6× 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}\;1 - u1 \leq 0.9975000023841858:\\ \;\;\;\;\sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \left(\mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \pi\right) + \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \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 (<= (- 1.0 u1) 0.9975000023841858)
                                                    (*
                                                     (sqrt (- (log (- 1.0 u1))))
                                                     (* u2 (+ (fma (* -41.34170150756836 u2) u2 PI) PI)))
                                                    (*
                                                     (sqrt (* u1 (+ 1.0 (* 0.5 u1))))
                                                     (* u2 (fma (* -41.34170150756836 u2) u2 (+ PI PI))))))
                                                  float code(float cosTheta_i, float u1, float u2) {
                                                  	float tmp;
                                                  	if ((1.0f - u1) <= 0.9975000023841858f) {
                                                  		tmp = sqrtf(-logf((1.0f - u1))) * (u2 * (fmaf((-41.34170150756836f * u2), u2, ((float) M_PI)) + ((float) M_PI)));
                                                  	} else {
                                                  		tmp = sqrtf((u1 * (1.0f + (0.5f * u1)))) * (u2 * fmaf((-41.34170150756836f * u2), u2, (((float) M_PI) + ((float) M_PI))));
                                                  	}
                                                  	return tmp;
                                                  }
                                                  
                                                  function code(cosTheta_i, u1, u2)
                                                  	tmp = Float32(0.0)
                                                  	if (Float32(Float32(1.0) - u1) <= Float32(0.9975000023841858))
                                                  		tmp = Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * Float32(u2 * Float32(fma(Float32(Float32(-41.34170150756836) * u2), u2, Float32(pi)) + Float32(pi))));
                                                  	else
                                                  		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1)))) * Float32(u2 * fma(Float32(Float32(-41.34170150756836) * u2), u2, Float32(Float32(pi) + Float32(pi)))));
                                                  	end
                                                  	return tmp
                                                  end
                                                  
                                                  \begin{array}{l}
                                                  \mathbf{if}\;1 - u1 \leq 0.9975000023841858:\\
                                                  \;\;\;\;\sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \left(\mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \pi\right) + \pi\right)\right)\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \pi + \pi\right)\right)\\
                                                  
                                                  
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Split input into 2 regimes
                                                  2. if (-.f32 #s(literal 1 binary32) u1) < 0.997500002

                                                    1. Initial program 58.2%

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

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

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

                                                          \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right), u2 \cdot u2, \pi + \pi\right)\right) \]
                                                        2. Evaluated real constant54.3%

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

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

                                                          if 0.997500002 < (-.f32 #s(literal 1 binary32) u1)

                                                          1. Initial program 58.2%

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

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

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

                                                              \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, {u2}^{2} \cdot {\pi}^{3}, 2 \cdot \pi\right)\right) \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites80.0%

                                                                \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, {u2}^{2} \cdot {\pi}^{3}, 2 \cdot \pi\right)\right) \]
                                                              2. Step-by-step derivation
                                                                1. Applied rewrites80.0%

                                                                  \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\left(\left(-1.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right) \cdot \pi\right) \cdot u2, u2, \pi + \pi\right)\right) \]
                                                                2. Evaluated real constant80.0%

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

                                                              Alternative 9: 87.9% accurate, 1.6× 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}\;1 - u1 \leq 0.9975000023841858:\\ \;\;\;\;\sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, 6.2831854820251465\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \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 (<= (- 1.0 u1) 0.9975000023841858)
                                                                (*
                                                                 (sqrt (- (log (- 1.0 u1))))
                                                                 (* u2 (fma -41.34170150756836 (* u2 u2) 6.2831854820251465)))
                                                                (*
                                                                 (sqrt (* u1 (+ 1.0 (* 0.5 u1))))
                                                                 (* u2 (fma (* -41.34170150756836 u2) u2 (+ PI PI))))))
                                                              float code(float cosTheta_i, float u1, float u2) {
                                                              	float tmp;
                                                              	if ((1.0f - u1) <= 0.9975000023841858f) {
                                                              		tmp = sqrtf(-logf((1.0f - u1))) * (u2 * fmaf(-41.34170150756836f, (u2 * u2), 6.2831854820251465f));
                                                              	} else {
                                                              		tmp = sqrtf((u1 * (1.0f + (0.5f * u1)))) * (u2 * fmaf((-41.34170150756836f * u2), u2, (((float) M_PI) + ((float) M_PI))));
                                                              	}
                                                              	return tmp;
                                                              }
                                                              
                                                              function code(cosTheta_i, u1, u2)
                                                              	tmp = Float32(0.0)
                                                              	if (Float32(Float32(1.0) - u1) <= Float32(0.9975000023841858))
                                                              		tmp = Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * Float32(u2 * fma(Float32(-41.34170150756836), Float32(u2 * u2), Float32(6.2831854820251465))));
                                                              	else
                                                              		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1)))) * Float32(u2 * fma(Float32(Float32(-41.34170150756836) * u2), u2, Float32(Float32(pi) + Float32(pi)))));
                                                              	end
                                                              	return tmp
                                                              end
                                                              
                                                              \begin{array}{l}
                                                              \mathbf{if}\;1 - u1 \leq 0.9975000023841858:\\
                                                              \;\;\;\;\sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, 6.2831854820251465\right)\right)\\
                                                              
                                                              \mathbf{else}:\\
                                                              \;\;\;\;\sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \pi + \pi\right)\right)\\
                                                              
                                                              
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Split input into 2 regimes
                                                              2. if (-.f32 #s(literal 1 binary32) u1) < 0.997500002

                                                                1. Initial program 58.2%

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

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

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

                                                                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right), u2 \cdot u2, \pi + \pi\right)\right) \]
                                                                    2. Evaluated real constant54.3%

                                                                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836, u2 \cdot u2, \pi + \pi\right)\right) \]
                                                                    3. Evaluated real constant54.3%

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

                                                                    if 0.997500002 < (-.f32 #s(literal 1 binary32) u1)

                                                                    1. Initial program 58.2%

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

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

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

                                                                        \[\leadsto \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, {u2}^{2} \cdot {\pi}^{3}, 2 \cdot \pi\right)\right) \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites80.0%

                                                                          \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, {u2}^{2} \cdot {\pi}^{3}, 2 \cdot \pi\right)\right) \]
                                                                        2. Step-by-step derivation
                                                                          1. Applied rewrites80.0%

                                                                            \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\left(\left(-1.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right) \cdot \pi\right) \cdot u2, u2, \pi + \pi\right)\right) \]
                                                                          2. Evaluated real constant80.0%

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

                                                                        Alternative 10: 84.6% accurate, 1.6× 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.00865000020712614:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot 6.2831854820251465\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \mathsf{fma}\left(u2, \pi + \pi, \left(u2 \cdot \left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333\right)\right) \cdot 31.006277084350586\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.00865000020712614)
                                                                          (* (sqrt (- (log1p (- u1)))) (* u2 6.2831854820251465))
                                                                          (*
                                                                           (sqrt u1)
                                                                           (fma
                                                                            u2
                                                                            (+ PI PI)
                                                                            (* (* u2 (* (* u2 u2) -1.3333333333333333)) 31.006277084350586)))))
                                                                        float code(float cosTheta_i, float u1, float u2) {
                                                                        	float tmp;
                                                                        	if (((2.0f * ((float) M_PI)) * u2) <= 0.00865000020712614f) {
                                                                        		tmp = sqrtf(-log1pf(-u1)) * (u2 * 6.2831854820251465f);
                                                                        	} else {
                                                                        		tmp = sqrtf(u1) * fmaf(u2, (((float) M_PI) + ((float) M_PI)), ((u2 * ((u2 * u2) * -1.3333333333333333f)) * 31.006277084350586f));
                                                                        	}
                                                                        	return tmp;
                                                                        }
                                                                        
                                                                        function code(cosTheta_i, u1, u2)
                                                                        	tmp = Float32(0.0)
                                                                        	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.00865000020712614))
                                                                        		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * Float32(6.2831854820251465)));
                                                                        	else
                                                                        		tmp = Float32(sqrt(u1) * fma(u2, Float32(Float32(pi) + Float32(pi)), Float32(Float32(u2 * Float32(Float32(u2 * u2) * Float32(-1.3333333333333333))) * Float32(31.006277084350586))));
                                                                        	end
                                                                        	return tmp
                                                                        end
                                                                        
                                                                        \begin{array}{l}
                                                                        \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.00865000020712614:\\
                                                                        \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot 6.2831854820251465\right)\\
                                                                        
                                                                        \mathbf{else}:\\
                                                                        \;\;\;\;\sqrt{u1} \cdot \mathsf{fma}\left(u2, \pi + \pi, \left(u2 \cdot \left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333\right)\right) \cdot 31.006277084350586\right)\\
                                                                        
                                                                        
                                                                        \end{array}
                                                                        
                                                                        Derivation
                                                                        1. Split input into 2 regimes
                                                                        2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.00865000021

                                                                          1. Initial program 58.2%

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

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

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

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

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

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

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

                                                                                1. Initial program 58.2%

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

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

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

                                                                                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \mathsf{fma}\left(u2, \pi + \pi, \left(u2 \cdot \left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)\right) \]
                                                                                    2. Evaluated real constant54.3%

                                                                                      \[\leadsto \sqrt{-\log \left(1 - u1\right)} \cdot \mathsf{fma}\left(u2, \pi + \pi, \left(u2 \cdot \left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333\right)\right) \cdot 31.006277084350586\right) \]
                                                                                    3. Taylor expanded in u1 around 0

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

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

                                                                                    Alternative 11: 84.6% accurate, 1.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} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.00865000020712614:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot 6.2831854820251465\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(u2 \cdot u2, -41.34170150756836, \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.00865000020712614)
                                                                                      (* (sqrt (- (log1p (- u1)))) (* u2 6.2831854820251465))
                                                                                      (* (sqrt u1) (* u2 (fma (* u2 u2) -41.34170150756836 (+ PI PI))))))
                                                                                    float code(float cosTheta_i, float u1, float u2) {
                                                                                    	float tmp;
                                                                                    	if (((2.0f * ((float) M_PI)) * u2) <= 0.00865000020712614f) {
                                                                                    		tmp = sqrtf(-log1pf(-u1)) * (u2 * 6.2831854820251465f);
                                                                                    	} else {
                                                                                    		tmp = sqrtf(u1) * (u2 * fmaf((u2 * u2), -41.34170150756836f, (((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.00865000020712614))
                                                                                    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * Float32(6.2831854820251465)));
                                                                                    	else
                                                                                    		tmp = Float32(sqrt(u1) * Float32(u2 * fma(Float32(u2 * u2), Float32(-41.34170150756836), Float32(Float32(pi) + Float32(pi)))));
                                                                                    	end
                                                                                    	return tmp
                                                                                    end
                                                                                    
                                                                                    \begin{array}{l}
                                                                                    \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.00865000020712614:\\
                                                                                    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot 6.2831854820251465\right)\\
                                                                                    
                                                                                    \mathbf{else}:\\
                                                                                    \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(u2 \cdot u2, -41.34170150756836, \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.00865000021

                                                                                      1. Initial program 58.2%

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

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

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

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

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

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

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

                                                                                            1. Initial program 58.2%

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

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

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

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

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

                                                                                                    \[\leadsto \sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(u2 \cdot u2, \left(-1.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right) \cdot \pi, \pi + \pi\right)\right) \]
                                                                                                  2. Evaluated real constant70.2%

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

                                                                                                Alternative 12: 84.5% accurate, 1.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} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.00865000020712614:\\ \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{-\mathsf{log1p}\left(-u1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(u2 \cdot u2, -41.34170150756836, \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.00865000020712614)
                                                                                                  (* 6.2831854820251465 (* u2 (sqrt (- (log1p (- u1))))))
                                                                                                  (* (sqrt u1) (* u2 (fma (* u2 u2) -41.34170150756836 (+ PI PI))))))
                                                                                                float code(float cosTheta_i, float u1, float u2) {
                                                                                                	float tmp;
                                                                                                	if (((2.0f * ((float) M_PI)) * u2) <= 0.00865000020712614f) {
                                                                                                		tmp = 6.2831854820251465f * (u2 * sqrtf(-log1pf(-u1)));
                                                                                                	} else {
                                                                                                		tmp = sqrtf(u1) * (u2 * fmaf((u2 * u2), -41.34170150756836f, (((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.00865000020712614))
                                                                                                		tmp = Float32(Float32(6.2831854820251465) * Float32(u2 * sqrt(Float32(-log1p(Float32(-u1))))));
                                                                                                	else
                                                                                                		tmp = Float32(sqrt(u1) * Float32(u2 * fma(Float32(u2 * u2), Float32(-41.34170150756836), Float32(Float32(pi) + Float32(pi)))));
                                                                                                	end
                                                                                                	return tmp
                                                                                                end
                                                                                                
                                                                                                \begin{array}{l}
                                                                                                \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.00865000020712614:\\
                                                                                                \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{-\mathsf{log1p}\left(-u1\right)}\right)\\
                                                                                                
                                                                                                \mathbf{else}:\\
                                                                                                \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(u2 \cdot u2, -41.34170150756836, \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.00865000021

                                                                                                  1. Initial program 58.2%

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

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

                                                                                                    \[\leadsto \frac{13176795}{2097152} \cdot \left(u2 \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                  4. Step-by-step derivation
                                                                                                    1. Applied rewrites51.2%

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

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

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

                                                                                                      1. Initial program 58.2%

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

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

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

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

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

                                                                                                              \[\leadsto \sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(u2 \cdot u2, \left(-1.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right) \cdot \pi, \pi + \pi\right)\right) \]
                                                                                                            2. Evaluated real constant70.2%

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

                                                                                                          Alternative 13: 83.1% accurate, 1.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}\;1 - u1 \leq 0.9975000023841858:\\ \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{-\log \left(1 - u1\right)}\right)\\ \mathbf{elif}\;1 - u1 \leq 0.9999899864196777:\\ \;\;\;\;6.2831854820251465 \cdot \left(\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot u2\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \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 (<= (- 1.0 u1) 0.9975000023841858)
                                                                                                            (* 6.2831854820251465 (* u2 (sqrt (- (log (- 1.0 u1))))))
                                                                                                            (if (<= (- 1.0 u1) 0.9999899864196777)
                                                                                                              (* 6.2831854820251465 (* (sqrt (* (fma 0.5 u1 1.0) u1)) u2))
                                                                                                              (*
                                                                                                               (sqrt u1)
                                                                                                               (* u2 (fma (* -41.34170150756836 u2) u2 (+ PI PI)))))))
                                                                                                          float code(float cosTheta_i, float u1, float u2) {
                                                                                                          	float tmp;
                                                                                                          	if ((1.0f - u1) <= 0.9975000023841858f) {
                                                                                                          		tmp = 6.2831854820251465f * (u2 * sqrtf(-logf((1.0f - u1))));
                                                                                                          	} else if ((1.0f - u1) <= 0.9999899864196777f) {
                                                                                                          		tmp = 6.2831854820251465f * (sqrtf((fmaf(0.5f, u1, 1.0f) * u1)) * u2);
                                                                                                          	} else {
                                                                                                          		tmp = sqrtf(u1) * (u2 * fmaf((-41.34170150756836f * u2), u2, (((float) M_PI) + ((float) M_PI))));
                                                                                                          	}
                                                                                                          	return tmp;
                                                                                                          }
                                                                                                          
                                                                                                          function code(cosTheta_i, u1, u2)
                                                                                                          	tmp = Float32(0.0)
                                                                                                          	if (Float32(Float32(1.0) - u1) <= Float32(0.9975000023841858))
                                                                                                          		tmp = Float32(Float32(6.2831854820251465) * Float32(u2 * sqrt(Float32(-log(Float32(Float32(1.0) - u1))))));
                                                                                                          	elseif (Float32(Float32(1.0) - u1) <= Float32(0.9999899864196777))
                                                                                                          		tmp = Float32(Float32(6.2831854820251465) * Float32(sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1)) * u2));
                                                                                                          	else
                                                                                                          		tmp = Float32(sqrt(u1) * Float32(u2 * fma(Float32(Float32(-41.34170150756836) * u2), u2, Float32(Float32(pi) + Float32(pi)))));
                                                                                                          	end
                                                                                                          	return tmp
                                                                                                          end
                                                                                                          
                                                                                                          \begin{array}{l}
                                                                                                          \mathbf{if}\;1 - u1 \leq 0.9975000023841858:\\
                                                                                                          \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{-\log \left(1 - u1\right)}\right)\\
                                                                                                          
                                                                                                          \mathbf{elif}\;1 - u1 \leq 0.9999899864196777:\\
                                                                                                          \;\;\;\;6.2831854820251465 \cdot \left(\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot u2\right)\\
                                                                                                          
                                                                                                          \mathbf{else}:\\
                                                                                                          \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \pi + \pi\right)\right)\\
                                                                                                          
                                                                                                          
                                                                                                          \end{array}
                                                                                                          
                                                                                                          Derivation
                                                                                                          1. Split input into 3 regimes
                                                                                                          2. if (-.f32 #s(literal 1 binary32) u1) < 0.997500002

                                                                                                            1. Initial program 58.2%

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

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

                                                                                                              \[\leadsto \frac{13176795}{2097152} \cdot \left(u2 \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                            4. Step-by-step derivation
                                                                                                              1. Applied rewrites51.2%

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

                                                                                                              if 0.997500002 < (-.f32 #s(literal 1 binary32) u1) < 0.999989986

                                                                                                              1. Initial program 58.2%

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

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

                                                                                                                \[\leadsto \frac{13176795}{2097152} \cdot \left(u2 \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                              4. Step-by-step derivation
                                                                                                                1. Applied rewrites51.2%

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

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

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

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

                                                                                                                    if 0.999989986 < (-.f32 #s(literal 1 binary32) u1)

                                                                                                                    1. Initial program 58.2%

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

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

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

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

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

                                                                                                                            \[\leadsto \sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(\left(\left(-1.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right) \cdot \pi\right) \cdot u2, u2, \pi + \pi\right)\right) \]
                                                                                                                          2. Evaluated real constant70.2%

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

                                                                                                                        Alternative 14: 80.3% accurate, 1.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 := -\log \left(1 - u1\right)\\ \mathbf{if}\;t\_0 \leq 0.0024999999441206455:\\ \;\;\;\;6.2831854820251465 \cdot \left(\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot u2\right)\\ \mathbf{else}:\\ \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{t\_0}\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 (- (log (- 1.0 u1)))))
                                                                                                                          (if (<= t_0 0.0024999999441206455)
                                                                                                                            (* 6.2831854820251465 (* (sqrt (* (fma 0.5 u1 1.0) u1)) u2))
                                                                                                                            (* 6.2831854820251465 (* u2 (sqrt t_0))))))
                                                                                                                        float code(float cosTheta_i, float u1, float u2) {
                                                                                                                        	float t_0 = -logf((1.0f - u1));
                                                                                                                        	float tmp;
                                                                                                                        	if (t_0 <= 0.0024999999441206455f) {
                                                                                                                        		tmp = 6.2831854820251465f * (sqrtf((fmaf(0.5f, u1, 1.0f) * u1)) * u2);
                                                                                                                        	} else {
                                                                                                                        		tmp = 6.2831854820251465f * (u2 * sqrtf(t_0));
                                                                                                                        	}
                                                                                                                        	return tmp;
                                                                                                                        }
                                                                                                                        
                                                                                                                        function code(cosTheta_i, u1, u2)
                                                                                                                        	t_0 = Float32(-log(Float32(Float32(1.0) - u1)))
                                                                                                                        	tmp = Float32(0.0)
                                                                                                                        	if (t_0 <= Float32(0.0024999999441206455))
                                                                                                                        		tmp = Float32(Float32(6.2831854820251465) * Float32(sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1)) * u2));
                                                                                                                        	else
                                                                                                                        		tmp = Float32(Float32(6.2831854820251465) * Float32(u2 * sqrt(t_0)));
                                                                                                                        	end
                                                                                                                        	return tmp
                                                                                                                        end
                                                                                                                        
                                                                                                                        \begin{array}{l}
                                                                                                                        t_0 := -\log \left(1 - u1\right)\\
                                                                                                                        \mathbf{if}\;t\_0 \leq 0.0024999999441206455:\\
                                                                                                                        \;\;\;\;6.2831854820251465 \cdot \left(\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot u2\right)\\
                                                                                                                        
                                                                                                                        \mathbf{else}:\\
                                                                                                                        \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{t\_0}\right)\\
                                                                                                                        
                                                                                                                        
                                                                                                                        \end{array}
                                                                                                                        
                                                                                                                        Derivation
                                                                                                                        1. Split input into 2 regimes
                                                                                                                        2. if (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1))) < 0.00249999994

                                                                                                                          1. Initial program 58.2%

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

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

                                                                                                                            \[\leadsto \frac{13176795}{2097152} \cdot \left(u2 \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                                          4. Step-by-step derivation
                                                                                                                            1. Applied rewrites51.2%

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

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

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

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

                                                                                                                                if 0.00249999994 < (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))

                                                                                                                                1. Initial program 58.2%

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

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

                                                                                                                                  \[\leadsto \frac{13176795}{2097152} \cdot \left(u2 \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                                                4. Step-by-step derivation
                                                                                                                                  1. Applied rewrites51.2%

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

                                                                                                                                Alternative 15: 73.9% accurate, 3.3× 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)\]
                                                                                                                                \[6.2831854820251465 \cdot \left(\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \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)))
                                                                                                                                  (* 6.2831854820251465 (* (sqrt (* (fma 0.5 u1 1.0) u1)) u2)))
                                                                                                                                float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                	return 6.2831854820251465f * (sqrtf((fmaf(0.5f, u1, 1.0f) * u1)) * u2);
                                                                                                                                }
                                                                                                                                
                                                                                                                                function code(cosTheta_i, u1, u2)
                                                                                                                                	return Float32(Float32(6.2831854820251465) * Float32(sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1)) * u2))
                                                                                                                                end
                                                                                                                                
                                                                                                                                6.2831854820251465 \cdot \left(\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot u2\right)
                                                                                                                                
                                                                                                                                Derivation
                                                                                                                                1. Initial program 58.2%

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

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

                                                                                                                                  \[\leadsto \frac{13176795}{2097152} \cdot \left(u2 \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                                                4. Step-by-step derivation
                                                                                                                                  1. Applied rewrites51.2%

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

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

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

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

                                                                                                                                      Alternative 16: 73.8% accurate, 3.3× 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)\]
                                                                                                                                      \[6.2831854820251465 \cdot \left(u2 \cdot \sqrt{\mathsf{fma}\left(u1, 0.5 \cdot u1, u1\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)))
                                                                                                                                        (* 6.2831854820251465 (* u2 (sqrt (fma u1 (* 0.5 u1) u1)))))
                                                                                                                                      float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                      	return 6.2831854820251465f * (u2 * sqrtf(fmaf(u1, (0.5f * u1), u1)));
                                                                                                                                      }
                                                                                                                                      
                                                                                                                                      function code(cosTheta_i, u1, u2)
                                                                                                                                      	return Float32(Float32(6.2831854820251465) * Float32(u2 * sqrt(fma(u1, Float32(Float32(0.5) * u1), u1))))
                                                                                                                                      end
                                                                                                                                      
                                                                                                                                      6.2831854820251465 \cdot \left(u2 \cdot \sqrt{\mathsf{fma}\left(u1, 0.5 \cdot u1, u1\right)}\right)
                                                                                                                                      
                                                                                                                                      Derivation
                                                                                                                                      1. Initial program 58.2%

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

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

                                                                                                                                        \[\leadsto \frac{13176795}{2097152} \cdot \left(u2 \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                                                      4. Step-by-step derivation
                                                                                                                                        1. Applied rewrites51.2%

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

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

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

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

                                                                                                                                            Alternative 17: 65.9% accurate, 3.3× 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)\]
                                                                                                                                            \[\frac{1}{\frac{0.5}{u2 \cdot \left(\pi \cdot \sqrt{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)))
                                                                                                                                              (/ 1.0 (/ 0.5 (* u2 (* PI (sqrt u1))))))
                                                                                                                                            float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                            	return 1.0f / (0.5f / (u2 * (((float) M_PI) * sqrtf(u1))));
                                                                                                                                            }
                                                                                                                                            
                                                                                                                                            function code(cosTheta_i, u1, u2)
                                                                                                                                            	return Float32(Float32(1.0) / Float32(Float32(0.5) / Float32(u2 * Float32(Float32(pi) * sqrt(u1)))))
                                                                                                                                            end
                                                                                                                                            
                                                                                                                                            function tmp = code(cosTheta_i, u1, u2)
                                                                                                                                            	tmp = single(1.0) / (single(0.5) / (u2 * (single(pi) * sqrt(u1))));
                                                                                                                                            end
                                                                                                                                            
                                                                                                                                            \frac{1}{\frac{0.5}{u2 \cdot \left(\pi \cdot \sqrt{u1}\right)}}
                                                                                                                                            
                                                                                                                                            Derivation
                                                                                                                                            1. Initial program 58.2%

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

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

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

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

                                                                                                                                                  \[\leadsto \frac{1}{\frac{\frac{1}{2}}{u2 \cdot \left(\pi \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right)}} \]
                                                                                                                                                3. Step-by-step derivation
                                                                                                                                                  1. Applied rewrites51.2%

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

                                                                                                                                                    \[\leadsto \frac{1}{\frac{0.5}{u2 \cdot \left(\pi \cdot \sqrt{u1}\right)}} \]
                                                                                                                                                  3. Step-by-step derivation
                                                                                                                                                    1. Applied rewrites65.9%

                                                                                                                                                      \[\leadsto \frac{1}{\frac{0.5}{u2 \cdot \left(\pi \cdot \sqrt{u1}\right)}} \]
                                                                                                                                                    2. Add Preprocessing

                                                                                                                                                    Alternative 18: 65.9% accurate, 6.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)\]
                                                                                                                                                    \[u2 \cdot \left(6.2831854820251465 \cdot \sqrt{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)))
                                                                                                                                                      (* u2 (* 6.2831854820251465 (sqrt u1))))
                                                                                                                                                    float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                    	return u2 * (6.2831854820251465f * 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 = u2 * (6.2831854820251465e0 * sqrt(u1))
                                                                                                                                                    end function
                                                                                                                                                    
                                                                                                                                                    function code(cosTheta_i, u1, u2)
                                                                                                                                                    	return Float32(u2 * Float32(Float32(6.2831854820251465) * sqrt(u1)))
                                                                                                                                                    end
                                                                                                                                                    
                                                                                                                                                    function tmp = code(cosTheta_i, u1, u2)
                                                                                                                                                    	tmp = u2 * (single(6.2831854820251465) * sqrt(u1));
                                                                                                                                                    end
                                                                                                                                                    
                                                                                                                                                    u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1}\right)
                                                                                                                                                    
                                                                                                                                                    Derivation
                                                                                                                                                    1. Initial program 58.2%

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

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

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

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

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

                                                                                                                                                          \[\leadsto u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1}\right) \]
                                                                                                                                                        4. Step-by-step derivation
                                                                                                                                                          1. Applied rewrites65.9%

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

                                                                                                                                                          Alternative 19: 65.9% accurate, 6.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)\]
                                                                                                                                                          \[6.2831854820251465 \cdot \left(u2 \cdot \sqrt{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)))
                                                                                                                                                            (* 6.2831854820251465 (* u2 (sqrt u1))))
                                                                                                                                                          float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                          	return 6.2831854820251465f * (u2 * 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 = 6.2831854820251465e0 * (u2 * sqrt(u1))
                                                                                                                                                          end function
                                                                                                                                                          
                                                                                                                                                          function code(cosTheta_i, u1, u2)
                                                                                                                                                          	return Float32(Float32(6.2831854820251465) * Float32(u2 * sqrt(u1)))
                                                                                                                                                          end
                                                                                                                                                          
                                                                                                                                                          function tmp = code(cosTheta_i, u1, u2)
                                                                                                                                                          	tmp = single(6.2831854820251465) * (u2 * sqrt(u1));
                                                                                                                                                          end
                                                                                                                                                          
                                                                                                                                                          6.2831854820251465 \cdot \left(u2 \cdot \sqrt{u1}\right)
                                                                                                                                                          
                                                                                                                                                          Derivation
                                                                                                                                                          1. Initial program 58.2%

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

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

                                                                                                                                                            \[\leadsto \frac{13176795}{2097152} \cdot \left(u2 \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right) \]
                                                                                                                                                          4. Step-by-step derivation
                                                                                                                                                            1. Applied rewrites51.2%

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

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

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

                                                                                                                                                              Reproduce

                                                                                                                                                              ?
                                                                                                                                                              herbie shell --seed 2026086 
                                                                                                                                                              (FPCore (cosTheta_i u1 u2)
                                                                                                                                                                :name "Beckmann Sample, near normal, slope_y"
                                                                                                                                                                :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)))) (sin (* (* 2.0 PI) u2))))