Beckmann Sample, near normal, slope_y

Percentage Accurate: 57.4% → 98.4%
Time: 8.9s
Alternatives: 29
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 29 alternatives:

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

Initial Program: 57.4% accurate, 1.0× speedup?

\[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\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.4% accurate, 0.8× speedup?

\[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\sqrt{-\frac{1}{\frac{2}{2 \cdot \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 (- (/ 1.0 (/ 2.0 (* 2.0 (log1p (- u1)))))))
 (sin (* 6.2831854820251465 u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-(1.0f / (2.0f / (2.0f * log1pf(-u1))))) * sinf((6.2831854820251465f * u2));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-Float32(Float32(1.0) / Float32(Float32(2.0) / Float32(Float32(2.0) * log1p(Float32(-u1))))))) * sin(Float32(Float32(6.2831854820251465) * u2)))
end
\sqrt{-\frac{1}{\frac{2}{2 \cdot \mathsf{log1p}\left(-u1\right)}}} \cdot \sin \left(6.2831854820251465 \cdot u2\right)
Derivation
  1. Initial program 57.4%

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Step-by-step derivation
    1. lift-log.f32N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \log \left(1 - u1\right)}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    2. pow1N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \log \left({\left(1 - u1\right)}^{1}\right)}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    3. log-powN/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \left(1 \cdot \log \left(\left|1 - u1\right|\right)\right)}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    4. metadata-evalN/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \left(\frac{2}{2} \cdot \log \left(\left|1 - u1\right|\right)\right)}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    5. associate-*l/N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{2 \cdot \log \left(\left|1 - u1\right|\right)}{2}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    6. div-flipN/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left(\left|1 - u1\right|\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    7. remove-sound-/N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left(\left|1 - u1\right|\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    8. lower-/.f32N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left(\left|1 - u1\right|\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    9. remove-sound-/N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left(\left|1 - u1\right|\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    10. lower-/.f32N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left(\left|1 - u1\right|\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    11. lower-*.f32N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left(\left|1 - u1\right|\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    12. *-lft-identityN/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \left(1 \cdot \log \left(\left|1 - u1\right|\right)\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    13. log-powN/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left({\left(1 - u1\right)}^{1}\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    14. pow1N/A

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left(1 - u1\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    15. lift-log.f3257.4%

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \frac{1}{\frac{2}{2 \cdot \log \left(1 - u1\right)}}}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  3. Applied rewrites57.4%

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

      \[\leadsto \sqrt{-\frac{1}{\frac{2}{2 \cdot \mathsf{log1p}\left(-u1\right)}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    2. Evaluated real constant98.3%

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

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

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

        \[\leadsto \sqrt{\sqrt{\left|\log \left(1 - u1\right)\right|}} \cdot \left(\sqrt{\sqrt{\left|\log \left(1 - u1\right)\right|}} \cdot \sin \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \]
      2. Applied rewrites57.4%

        \[\leadsto \frac{\sin \left(u2 \cdot \left(\pi + \pi\right)\right)}{\frac{1}{\sqrt{\left|\log \left(1 - u1\right)\right|}}} \]
      3. Evaluated real constant57.4%

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

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

        Alternative 3: 98.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{-\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 57.4%

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

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

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

          Alternative 4: 97.0% 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.002199999988079071:\\ \;\;\;\;\mathsf{fma}\left(\sqrt{u1} \cdot 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.002199999988079071)
              (*
               (fma (* (sqrt u1) 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.002199999988079071f) {
          		tmp = fmaf((sqrtf(u1) * 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.002199999988079071))
          		tmp = Float32(fma(Float32(sqrt(u1) * 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.002199999988079071:\\
          \;\;\;\;\mathsf{fma}\left(\sqrt{u1} \cdot 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.00219999999

            1. Initial program 57.4%

              \[\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.2%

                \[\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.2%

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

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

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

                1. Initial program 57.4%

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

                  \[\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 5: 97.0% 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.002199999988079071:\\ \;\;\;\;\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.002199999988079071)
                  (* (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.002199999988079071f) {
              		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.002199999988079071))
              		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.002199999988079071:\\
              \;\;\;\;\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.00219999999

                1. Initial program 57.4%

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

                  \[\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 rewrites88.0%

                    \[\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 rewrites88.0%

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

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

                    1. Initial program 57.4%

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

                      \[\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 6: 96.3% 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 \mathsf{fma}\left(u2, \pi + \pi, \left(u2 \cdot \left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333\right)\right) \cdot 31.006277084350586\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))))
                     (fma
                      u2
                      (+ PI PI)
                      (* (* u2 (* (* u2 u2) -1.3333333333333333)) 31.006277084350586)))
                    (* (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)) * fmaf(u2, (((float) M_PI) + ((float) M_PI)), ((u2 * ((u2 * u2) * -1.3333333333333333f)) * 31.006277084350586f));
                  	} 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)))) * fma(u2, Float32(Float32(pi) + Float32(pi)), Float32(Float32(u2 * Float32(Float32(u2 * u2) * Float32(-1.3333333333333333))) * Float32(31.006277084350586))));
                  	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 \mathsf{fma}\left(u2, \pi + \pi, \left(u2 \cdot \left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333\right)\right) \cdot 31.006277084350586\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 57.4%

                      \[\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 rewrites53.5%

                        \[\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 rewrites53.5%

                          \[\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 constant53.5%

                          \[\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. Step-by-step derivation
                          1. Applied rewrites89.2%

                            \[\leadsto \sqrt{-\mathsf{log1p}\left(-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) \]

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

                          1. Initial program 57.4%

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

                            \[\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 rewrites88.0%

                              \[\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 rewrites88.0%

                                \[\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 7: 94.5% accurate, 1.0× speedup?

                            \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                            \[\begin{array}{l} \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.18000000715255737:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-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)\\ \mathbf{else}:\\ \;\;\;\;\frac{u1}{\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.18000000715255737)
                              (*
                               (sqrt (- (log1p (- u1))))
                               (fma
                                u2
                                (+ PI PI)
                                (* (* u2 (* (* u2 u2) -1.3333333333333333)) 31.006277084350586)))
                              (* (/ u1 (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.18000000715255737f) {
                            		tmp = sqrtf(-log1pf(-u1)) * fmaf(u2, (((float) M_PI) + ((float) M_PI)), ((u2 * ((u2 * u2) * -1.3333333333333333f)) * 31.006277084350586f));
                            	} else {
                            		tmp = (u1 / 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.18000000715255737))
                            		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(u2, Float32(Float32(pi) + Float32(pi)), Float32(Float32(u2 * Float32(Float32(u2 * u2) * Float32(-1.3333333333333333))) * Float32(31.006277084350586))));
                            	else
                            		tmp = Float32(Float32(u1 / 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.18000000715255737:\\
                            \;\;\;\;\sqrt{-\mathsf{log1p}\left(-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)\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\frac{u1}{\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.180000007

                              1. Initial program 57.4%

                                \[\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 rewrites53.5%

                                  \[\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 rewrites53.5%

                                    \[\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 constant53.5%

                                    \[\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. Step-by-step derivation
                                    1. Applied rewrites89.2%

                                      \[\leadsto \sqrt{-\mathsf{log1p}\left(-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) \]

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

                                    1. Initial program 57.4%

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

                                      \[\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.8%

                                        \[\leadsto \sqrt{u1} \cdot \sin \left(6.2831854820251465 \cdot u2\right) \]
                                      2. Step-by-step derivation
                                        1. lift-sqrt.f32N/A

                                          \[\leadsto \frac{u1}{\sqrt{u1}} \cdot \sin \left(\frac{13176795}{2097152} \cdot u2\right) \]
                                        2. pow1/2N/A

                                          \[\leadsto \frac{u1}{{u1}^{\frac{1}{2}}} \cdot \sin \left(\frac{13176795}{2097152} \cdot u2\right) \]
                                        3. metadata-evalN/A

                                          \[\leadsto \frac{u1}{{u1}^{\left(1 - \frac{1}{2}\right)}} \cdot \sin \left(\frac{13176795}{2097152} \cdot u2\right) \]
                                        4. pow-divN/A

                                          \[\leadsto \frac{u1}{\frac{{u1}^{1}}{{u1}^{\frac{1}{2}}}} \cdot \sin \left(\frac{13176795}{2097152} \cdot u2\right) \]
                                        5. pow1N/A

                                          \[\leadsto \frac{u1}{\frac{u1}{{u1}^{\frac{1}{2}}}} \cdot \sin \left(\frac{13176795}{2097152} \cdot u2\right) \]
                                        6. pow1/2N/A

                                          \[\leadsto \frac{u1}{\frac{u1}{\sqrt{u1}}} \cdot \sin \left(\frac{13176795}{2097152} \cdot u2\right) \]
                                        7. lift-sqrt.f32N/A

                                          \[\leadsto \frac{u1}{\frac{u1}{\sqrt{u1}}} \cdot \sin \left(\frac{13176795}{2097152} \cdot u2\right) \]
                                        8. lift-/.f3276.8%

                                          \[\leadsto \frac{u1}{\frac{u1}{\sqrt{u1}}} \cdot \sin \left(6.2831854820251465 \cdot u2\right) \]
                                      3. Applied rewrites76.7%

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

                                    Alternative 8: 94.5% 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.18000000715255737:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-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)\\ \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.18000000715255737)
                                      (*
                                       (sqrt (- (log1p (- u1))))
                                       (fma
                                        u2
                                        (+ PI PI)
                                        (* (* u2 (* (* u2 u2) -1.3333333333333333)) 31.006277084350586)))
                                      (* (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.18000000715255737f) {
                                    		tmp = sqrtf(-log1pf(-u1)) * fmaf(u2, (((float) M_PI) + ((float) M_PI)), ((u2 * ((u2 * u2) * -1.3333333333333333f)) * 31.006277084350586f));
                                    	} 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.18000000715255737))
                                    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * fma(u2, Float32(Float32(pi) + Float32(pi)), Float32(Float32(u2 * Float32(Float32(u2 * u2) * Float32(-1.3333333333333333))) * Float32(31.006277084350586))));
                                    	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.18000000715255737:\\
                                    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-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)\\
                                    
                                    \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.180000007

                                      1. Initial program 57.4%

                                        \[\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 rewrites53.5%

                                          \[\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 rewrites53.5%

                                            \[\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 constant53.5%

                                            \[\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. Step-by-step derivation
                                            1. Applied rewrites89.2%

                                              \[\leadsto \sqrt{-\mathsf{log1p}\left(-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) \]

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

                                            1. Initial program 57.4%

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

                                              \[\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.8%

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

                                            Alternative 9: 89.2% accurate, 1.5× speedup?

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

                                              \[\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 rewrites53.5%

                                                \[\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 rewrites53.5%

                                                  \[\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 constant53.5%

                                                  \[\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. Step-by-step derivation
                                                  1. Applied rewrites89.2%

                                                    \[\leadsto \sqrt{-\mathsf{log1p}\left(-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) \]
                                                  2. Add Preprocessing

                                                  Alternative 10: 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 57.4%

                                                    \[\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 rewrites53.5%

                                                      \[\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 rewrites53.5%

                                                        \[\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 constant53.5%

                                                        \[\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 11: 88.0% 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.9976000189781189:\\ \;\;\;\;\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.9976000189781189)
                                                          (*
                                                           (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.9976000189781189f) {
                                                        		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.9976000189781189))
                                                        		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.9976000189781189:\\
                                                        \;\;\;\;\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.997600019

                                                          1. Initial program 57.4%

                                                            \[\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 rewrites53.5%

                                                              \[\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 rewrites53.5%

                                                                \[\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 constant53.5%

                                                                \[\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 rewrites53.5%

                                                                  \[\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.997600019 < (-.f32 #s(literal 1 binary32) u1)

                                                                1. Initial program 57.4%

                                                                  \[\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 \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites88.0%

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

                                                                    \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot 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 rewrites80.2%

                                                                      \[\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.2%

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

                                                                        \[\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 12: 88.0% 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.9976000189781189:\\ \;\;\;\;\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.9976000189781189)
                                                                      (*
                                                                       (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.9976000189781189f) {
                                                                    		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.9976000189781189))
                                                                    		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.9976000189781189:\\
                                                                    \;\;\;\;\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.997600019

                                                                      1. Initial program 57.4%

                                                                        \[\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 rewrites53.5%

                                                                          \[\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 rewrites53.5%

                                                                            \[\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 constant53.5%

                                                                            \[\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 constant53.5%

                                                                            \[\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.997600019 < (-.f32 #s(literal 1 binary32) u1)

                                                                          1. Initial program 57.4%

                                                                            \[\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 \sqrt{u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                          3. Step-by-step derivation
                                                                            1. Applied rewrites88.0%

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

                                                                              \[\leadsto \sqrt{u1 \cdot \left(1 + 0.5 \cdot 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 rewrites80.2%

                                                                                \[\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.2%

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

                                                                                  \[\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 13: 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.007199999876320362:\\ \;\;\;\;\sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot 6.2831854820251465\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \left(\mathsf{fma}\left(\left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333\right) \cdot 9.869604110717773, \pi, \pi\right) + \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.007199999876320362)
                                                                                (* (sqrt (fabs (log1p (- u1)))) (* u2 6.2831854820251465))
                                                                                (*
                                                                                 (sqrt u1)
                                                                                 (*
                                                                                  u2
                                                                                  (+
                                                                                   (fma
                                                                                    (* (* (* u2 u2) -1.3333333333333333) 9.869604110717773)
                                                                                    PI
                                                                                    PI)
                                                                                   PI)))))
                                                                              float code(float cosTheta_i, float u1, float u2) {
                                                                              	float tmp;
                                                                              	if (((2.0f * ((float) M_PI)) * u2) <= 0.007199999876320362f) {
                                                                              		tmp = sqrtf(fabsf(log1pf(-u1))) * (u2 * 6.2831854820251465f);
                                                                              	} else {
                                                                              		tmp = sqrtf(u1) * (u2 * (fmaf((((u2 * u2) * -1.3333333333333333f) * 9.869604110717773f), ((float) M_PI), ((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.007199999876320362))
                                                                              		tmp = Float32(sqrt(abs(log1p(Float32(-u1)))) * Float32(u2 * Float32(6.2831854820251465)));
                                                                              	else
                                                                              		tmp = Float32(sqrt(u1) * Float32(u2 * Float32(fma(Float32(Float32(Float32(u2 * u2) * Float32(-1.3333333333333333)) * Float32(9.869604110717773)), Float32(pi), Float32(pi)) + Float32(pi))));
                                                                              	end
                                                                              	return tmp
                                                                              end
                                                                              
                                                                              \begin{array}{l}
                                                                              \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.007199999876320362:\\
                                                                              \;\;\;\;\sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot 6.2831854820251465\right)\\
                                                                              
                                                                              \mathbf{else}:\\
                                                                              \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \left(\mathsf{fma}\left(\left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333\right) \cdot 9.869604110717773, \pi, \pi\right) + \pi\right)\right)\\
                                                                              
                                                                              
                                                                              \end{array}
                                                                              
                                                                              Derivation
                                                                              1. Split input into 2 regimes
                                                                              2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.00719999988

                                                                                1. Initial program 57.4%

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

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

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

                                                                                        \[\leadsto \sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot \left(\pi + \pi\right)\right) \]
                                                                                      2. Evaluated real constant81.3%

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

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

                                                                                      1. Initial program 57.4%

                                                                                        \[\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 rewrites53.5%

                                                                                          \[\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 rewrites53.5%

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

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

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

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

                                                                                          Alternative 14: 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.007199999876320362:\\ \;\;\;\;\sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot 6.2831854820251465\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333, 9.869604110717773, 1\right), \pi, \pi\right)\right)\\ \end{array} \]
                                                                                          (FPCore (cosTheta_i u1 u2)
                                                                                            :precision binary32
                                                                                            :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                    (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                               (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                            (if (<= (* (* 2.0 PI) u2) 0.007199999876320362)
                                                                                            (* (sqrt (fabs (log1p (- u1)))) (* u2 6.2831854820251465))
                                                                                            (*
                                                                                             (sqrt u1)
                                                                                             (*
                                                                                              u2
                                                                                              (fma
                                                                                               (fma (* (* u2 u2) -1.3333333333333333) 9.869604110717773 1.0)
                                                                                               PI
                                                                                               PI)))))
                                                                                          float code(float cosTheta_i, float u1, float u2) {
                                                                                          	float tmp;
                                                                                          	if (((2.0f * ((float) M_PI)) * u2) <= 0.007199999876320362f) {
                                                                                          		tmp = sqrtf(fabsf(log1pf(-u1))) * (u2 * 6.2831854820251465f);
                                                                                          	} else {
                                                                                          		tmp = sqrtf(u1) * (u2 * fmaf(fmaf(((u2 * u2) * -1.3333333333333333f), 9.869604110717773f, 1.0f), ((float) M_PI), ((float) M_PI)));
                                                                                          	}
                                                                                          	return tmp;
                                                                                          }
                                                                                          
                                                                                          function code(cosTheta_i, u1, u2)
                                                                                          	tmp = Float32(0.0)
                                                                                          	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.007199999876320362))
                                                                                          		tmp = Float32(sqrt(abs(log1p(Float32(-u1)))) * Float32(u2 * Float32(6.2831854820251465)));
                                                                                          	else
                                                                                          		tmp = Float32(sqrt(u1) * Float32(u2 * fma(fma(Float32(Float32(u2 * u2) * Float32(-1.3333333333333333)), Float32(9.869604110717773), Float32(1.0)), Float32(pi), Float32(pi))));
                                                                                          	end
                                                                                          	return tmp
                                                                                          end
                                                                                          
                                                                                          \begin{array}{l}
                                                                                          \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.007199999876320362:\\
                                                                                          \;\;\;\;\sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot 6.2831854820251465\right)\\
                                                                                          
                                                                                          \mathbf{else}:\\
                                                                                          \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333, 9.869604110717773, 1\right), \pi, \pi\right)\right)\\
                                                                                          
                                                                                          
                                                                                          \end{array}
                                                                                          
                                                                                          Derivation
                                                                                          1. Split input into 2 regimes
                                                                                          2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.00719999988

                                                                                            1. Initial program 57.4%

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

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

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

                                                                                                    \[\leadsto \sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot \left(\pi + \pi\right)\right) \]
                                                                                                  2. Evaluated real constant81.3%

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

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

                                                                                                  1. Initial program 57.4%

                                                                                                    \[\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 \sqrt{u1} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                  3. Step-by-step derivation
                                                                                                    1. Applied rewrites76.8%

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

                                                                                                      \[\leadsto \sqrt{u1} \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 rewrites70.8%

                                                                                                        \[\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.8%

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

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

                                                                                                      Alternative 15: 84.6% 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}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.007199999876320362:\\ \;\;\;\;\sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot 6.2831854820251465\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1} \cdot \mathsf{fma}\left(2, u2 \cdot \pi, \left(-41.34170150756836 \cdot \left(u2 \cdot u2\right)\right) \cdot u2\right)\\ \end{array} \]
                                                                                                      (FPCore (cosTheta_i u1 u2)
                                                                                                        :precision binary32
                                                                                                        :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                           (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                        (if (<= (* (* 2.0 PI) u2) 0.007199999876320362)
                                                                                                        (* (sqrt (fabs (log1p (- u1)))) (* u2 6.2831854820251465))
                                                                                                        (*
                                                                                                         (sqrt u1)
                                                                                                         (fma 2.0 (* u2 PI) (* (* -41.34170150756836 (* u2 u2)) u2)))))
                                                                                                      float code(float cosTheta_i, float u1, float u2) {
                                                                                                      	float tmp;
                                                                                                      	if (((2.0f * ((float) M_PI)) * u2) <= 0.007199999876320362f) {
                                                                                                      		tmp = sqrtf(fabsf(log1pf(-u1))) * (u2 * 6.2831854820251465f);
                                                                                                      	} else {
                                                                                                      		tmp = sqrtf(u1) * fmaf(2.0f, (u2 * ((float) M_PI)), ((-41.34170150756836f * (u2 * u2)) * u2));
                                                                                                      	}
                                                                                                      	return tmp;
                                                                                                      }
                                                                                                      
                                                                                                      function code(cosTheta_i, u1, u2)
                                                                                                      	tmp = Float32(0.0)
                                                                                                      	if (Float32(Float32(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.007199999876320362))
                                                                                                      		tmp = Float32(sqrt(abs(log1p(Float32(-u1)))) * Float32(u2 * Float32(6.2831854820251465)));
                                                                                                      	else
                                                                                                      		tmp = Float32(sqrt(u1) * fma(Float32(2.0), Float32(u2 * Float32(pi)), Float32(Float32(Float32(-41.34170150756836) * Float32(u2 * u2)) * u2)));
                                                                                                      	end
                                                                                                      	return tmp
                                                                                                      end
                                                                                                      
                                                                                                      \begin{array}{l}
                                                                                                      \mathbf{if}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.007199999876320362:\\
                                                                                                      \;\;\;\;\sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot 6.2831854820251465\right)\\
                                                                                                      
                                                                                                      \mathbf{else}:\\
                                                                                                      \;\;\;\;\sqrt{u1} \cdot \mathsf{fma}\left(2, u2 \cdot \pi, \left(-41.34170150756836 \cdot \left(u2 \cdot u2\right)\right) \cdot u2\right)\\
                                                                                                      
                                                                                                      
                                                                                                      \end{array}
                                                                                                      
                                                                                                      Derivation
                                                                                                      1. Split input into 2 regimes
                                                                                                      2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.00719999988

                                                                                                        1. Initial program 57.4%

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

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

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

                                                                                                                \[\leadsto \sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot \left(\pi + \pi\right)\right) \]
                                                                                                              2. Evaluated real constant81.3%

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

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

                                                                                                              1. Initial program 57.4%

                                                                                                                \[\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 \sqrt{u1} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                              3. Step-by-step derivation
                                                                                                                1. Applied rewrites76.8%

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

                                                                                                                  \[\leadsto \sqrt{u1} \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 rewrites70.8%

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

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

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

                                                                                                                Alternative 16: 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.007199999876320362:\\ \;\;\;\;\sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot 6.2831854820251465\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 (<= (* (* 2.0 PI) u2) 0.007199999876320362)
                                                                                                                  (* (sqrt (fabs (log1p (- u1)))) (* u2 6.2831854820251465))
                                                                                                                  (* (sqrt u1) (* u2 (fma (* -41.34170150756836 u2) u2 (+ PI PI))))))
                                                                                                                float code(float cosTheta_i, float u1, float u2) {
                                                                                                                	float tmp;
                                                                                                                	if (((2.0f * ((float) M_PI)) * u2) <= 0.007199999876320362f) {
                                                                                                                		tmp = sqrtf(fabsf(log1pf(-u1))) * (u2 * 6.2831854820251465f);
                                                                                                                	} 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(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.007199999876320362))
                                                                                                                		tmp = Float32(sqrt(abs(log1p(Float32(-u1)))) * Float32(u2 * Float32(6.2831854820251465)));
                                                                                                                	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}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.007199999876320362:\\
                                                                                                                \;\;\;\;\sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot 6.2831854820251465\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 2 regimes
                                                                                                                2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.00719999988

                                                                                                                  1. Initial program 57.4%

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

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

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

                                                                                                                          \[\leadsto \sqrt{\left|\mathsf{log1p}\left(-u1\right)\right|} \cdot \left(u2 \cdot \left(\pi + \pi\right)\right) \]
                                                                                                                        2. Evaluated real constant81.3%

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

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

                                                                                                                        1. Initial program 57.4%

                                                                                                                          \[\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 \sqrt{u1} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                        3. Step-by-step derivation
                                                                                                                          1. Applied rewrites76.8%

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

                                                                                                                            \[\leadsto \sqrt{u1} \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 rewrites70.8%

                                                                                                                              \[\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.8%

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

                                                                                                                                \[\leadsto \sqrt{u1} \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 17: 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.007199999876320362:\\ \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{-\mathsf{log1p}\left(-u1\right)}\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 (<= (* (* 2.0 PI) u2) 0.007199999876320362)
                                                                                                                              (* u2 (* 6.2831854820251465 (sqrt (- (log1p (- u1))))))
                                                                                                                              (* (sqrt u1) (* u2 (fma (* -41.34170150756836 u2) u2 (+ PI PI))))))
                                                                                                                            float code(float cosTheta_i, float u1, float u2) {
                                                                                                                            	float tmp;
                                                                                                                            	if (((2.0f * ((float) M_PI)) * u2) <= 0.007199999876320362f) {
                                                                                                                            		tmp = u2 * (6.2831854820251465f * sqrtf(-log1pf(-u1)));
                                                                                                                            	} 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(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.007199999876320362))
                                                                                                                            		tmp = Float32(u2 * Float32(Float32(6.2831854820251465) * sqrt(Float32(-log1p(Float32(-u1))))));
                                                                                                                            	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}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.007199999876320362:\\
                                                                                                                            \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{-\mathsf{log1p}\left(-u1\right)}\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 2 regimes
                                                                                                                            2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.00719999988

                                                                                                                              1. Initial program 57.4%

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

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

                                                                                                                                \[\leadsto u2 \cdot \left(\frac{13176795}{2097152} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + {u2}^{2} \cdot \left(\frac{-762619864465648886625}{18446744073709551616} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{26482421150709471190661161091833125}{324518553658426726783156020576256} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right)\right)\right) \]
                                                                                                                              4. Step-by-step derivation
                                                                                                                                1. Applied rewrites54.4%

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

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

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

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

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

                                                                                                                                    1. Initial program 57.4%

                                                                                                                                      \[\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 \sqrt{u1} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                    3. Step-by-step derivation
                                                                                                                                      1. Applied rewrites76.8%

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

                                                                                                                                        \[\leadsto \sqrt{u1} \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 rewrites70.8%

                                                                                                                                          \[\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.8%

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

                                                                                                                                            \[\leadsto \sqrt{u1} \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 18: 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.007199999876320362:\\ \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{-\mathsf{log1p}\left(-u1\right)}\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 (<= (* (* 2.0 PI) u2) 0.007199999876320362)
                                                                                                                                          (* 6.2831854820251465 (* u2 (sqrt (- (log1p (- u1))))))
                                                                                                                                          (* (sqrt u1) (* u2 (fma (* -41.34170150756836 u2) u2 (+ PI PI))))))
                                                                                                                                        float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                        	float tmp;
                                                                                                                                        	if (((2.0f * ((float) M_PI)) * u2) <= 0.007199999876320362f) {
                                                                                                                                        		tmp = 6.2831854820251465f * (u2 * sqrtf(-log1pf(-u1)));
                                                                                                                                        	} 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(Float32(2.0) * Float32(pi)) * u2) <= Float32(0.007199999876320362))
                                                                                                                                        		tmp = Float32(Float32(6.2831854820251465) * Float32(u2 * sqrt(Float32(-log1p(Float32(-u1))))));
                                                                                                                                        	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}\;\left(2 \cdot \pi\right) \cdot u2 \leq 0.007199999876320362:\\
                                                                                                                                        \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{-\mathsf{log1p}\left(-u1\right)}\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 2 regimes
                                                                                                                                        2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.00719999988

                                                                                                                                          1. Initial program 57.4%

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

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

                                                                                                                                              \[\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.00719999988 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

                                                                                                                                              1. Initial program 57.4%

                                                                                                                                                \[\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 \sqrt{u1} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                              3. Step-by-step derivation
                                                                                                                                                1. Applied rewrites76.8%

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

                                                                                                                                                  \[\leadsto \sqrt{u1} \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 rewrites70.8%

                                                                                                                                                    \[\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.8%

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

                                                                                                                                                      \[\leadsto \sqrt{u1} \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 19: 81.0% 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.000375000003259629:\\ \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \pi + \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left|t\_0\right|} \cdot \left(u2 \cdot 6.2831854820251465\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.000375000003259629)
                                                                                                                                                      (* (sqrt u1) (* u2 (fma (* -41.34170150756836 u2) u2 (+ PI PI))))
                                                                                                                                                      (* (sqrt (fabs t_0)) (* u2 6.2831854820251465)))))
                                                                                                                                                  float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                  	float t_0 = logf((1.0f - u1));
                                                                                                                                                  	float tmp;
                                                                                                                                                  	if (-t_0 <= 0.000375000003259629f) {
                                                                                                                                                  		tmp = sqrtf(u1) * (u2 * fmaf((-41.34170150756836f * u2), u2, (((float) M_PI) + ((float) M_PI))));
                                                                                                                                                  	} else {
                                                                                                                                                  		tmp = sqrtf(fabsf(t_0)) * (u2 * 6.2831854820251465f);
                                                                                                                                                  	}
                                                                                                                                                  	return tmp;
                                                                                                                                                  }
                                                                                                                                                  
                                                                                                                                                  function code(cosTheta_i, u1, u2)
                                                                                                                                                  	t_0 = log(Float32(Float32(1.0) - u1))
                                                                                                                                                  	tmp = Float32(0.0)
                                                                                                                                                  	if (Float32(-t_0) <= Float32(0.000375000003259629))
                                                                                                                                                  		tmp = Float32(sqrt(u1) * Float32(u2 * fma(Float32(Float32(-41.34170150756836) * u2), u2, Float32(Float32(pi) + Float32(pi)))));
                                                                                                                                                  	else
                                                                                                                                                  		tmp = Float32(sqrt(abs(t_0)) * Float32(u2 * Float32(6.2831854820251465)));
                                                                                                                                                  	end
                                                                                                                                                  	return tmp
                                                                                                                                                  end
                                                                                                                                                  
                                                                                                                                                  \begin{array}{l}
                                                                                                                                                  t_0 := \log \left(1 - u1\right)\\
                                                                                                                                                  \mathbf{if}\;-t\_0 \leq 0.000375000003259629:\\
                                                                                                                                                  \;\;\;\;\sqrt{u1} \cdot \left(u2 \cdot \mathsf{fma}\left(-41.34170150756836 \cdot u2, u2, \pi + \pi\right)\right)\\
                                                                                                                                                  
                                                                                                                                                  \mathbf{else}:\\
                                                                                                                                                  \;\;\;\;\sqrt{\left|t\_0\right|} \cdot \left(u2 \cdot 6.2831854820251465\right)\\
                                                                                                                                                  
                                                                                                                                                  
                                                                                                                                                  \end{array}
                                                                                                                                                  
                                                                                                                                                  Derivation
                                                                                                                                                  1. Split input into 2 regimes
                                                                                                                                                  2. if (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1))) < 3.75000003e-4

                                                                                                                                                    1. Initial program 57.4%

                                                                                                                                                      \[\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 \sqrt{u1} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                    3. Step-by-step derivation
                                                                                                                                                      1. Applied rewrites76.8%

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

                                                                                                                                                        \[\leadsto \sqrt{u1} \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 rewrites70.8%

                                                                                                                                                          \[\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.8%

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

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

                                                                                                                                                          if 3.75000003e-4 < (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))

                                                                                                                                                          1. Initial program 57.4%

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

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

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

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

                                                                                                                                                            Alternative 20: 80.5% 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:\\ \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left|t\_0\right|} \cdot \left(u2 \cdot 6.2831854820251465\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)
                                                                                                                                                                (* u2 (* 6.2831854820251465 (sqrt (* u1 (+ 1.0 (* 0.5 u1))))))
                                                                                                                                                                (* (sqrt (fabs t_0)) (* u2 6.2831854820251465)))))
                                                                                                                                                            float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                            	float t_0 = logf((1.0f - u1));
                                                                                                                                                            	float tmp;
                                                                                                                                                            	if (-t_0 <= 0.0024999999441206455f) {
                                                                                                                                                            		tmp = u2 * (6.2831854820251465f * sqrtf((u1 * (1.0f + (0.5f * u1)))));
                                                                                                                                                            	} else {
                                                                                                                                                            		tmp = sqrtf(fabsf(t_0)) * (u2 * 6.2831854820251465f);
                                                                                                                                                            	}
                                                                                                                                                            	return tmp;
                                                                                                                                                            }
                                                                                                                                                            
                                                                                                                                                            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
                                                                                                                                                                real(4) :: t_0
                                                                                                                                                                real(4) :: tmp
                                                                                                                                                                t_0 = log((1.0e0 - u1))
                                                                                                                                                                if (-t_0 <= 0.0024999999441206455e0) then
                                                                                                                                                                    tmp = u2 * (6.2831854820251465e0 * sqrt((u1 * (1.0e0 + (0.5e0 * u1)))))
                                                                                                                                                                else
                                                                                                                                                                    tmp = sqrt(abs(t_0)) * (u2 * 6.2831854820251465e0)
                                                                                                                                                                end if
                                                                                                                                                                code = tmp
                                                                                                                                                            end function
                                                                                                                                                            
                                                                                                                                                            function code(cosTheta_i, u1, u2)
                                                                                                                                                            	t_0 = log(Float32(Float32(1.0) - u1))
                                                                                                                                                            	tmp = Float32(0.0)
                                                                                                                                                            	if (Float32(-t_0) <= Float32(0.0024999999441206455))
                                                                                                                                                            		tmp = Float32(u2 * Float32(Float32(6.2831854820251465) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1))))));
                                                                                                                                                            	else
                                                                                                                                                            		tmp = Float32(sqrt(abs(t_0)) * Float32(u2 * Float32(6.2831854820251465)));
                                                                                                                                                            	end
                                                                                                                                                            	return tmp
                                                                                                                                                            end
                                                                                                                                                            
                                                                                                                                                            function tmp_2 = code(cosTheta_i, u1, u2)
                                                                                                                                                            	t_0 = log((single(1.0) - u1));
                                                                                                                                                            	tmp = single(0.0);
                                                                                                                                                            	if (-t_0 <= single(0.0024999999441206455))
                                                                                                                                                            		tmp = u2 * (single(6.2831854820251465) * sqrt((u1 * (single(1.0) + (single(0.5) * u1)))));
                                                                                                                                                            	else
                                                                                                                                                            		tmp = sqrt(abs(t_0)) * (u2 * single(6.2831854820251465));
                                                                                                                                                            	end
                                                                                                                                                            	tmp_2 = tmp;
                                                                                                                                                            end
                                                                                                                                                            
                                                                                                                                                            \begin{array}{l}
                                                                                                                                                            t_0 := \log \left(1 - u1\right)\\
                                                                                                                                                            \mathbf{if}\;-t\_0 \leq 0.0024999999441206455:\\
                                                                                                                                                            \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)}\right)\\
                                                                                                                                                            
                                                                                                                                                            \mathbf{else}:\\
                                                                                                                                                            \;\;\;\;\sqrt{\left|t\_0\right|} \cdot \left(u2 \cdot 6.2831854820251465\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 57.4%

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

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

                                                                                                                                                                \[\leadsto u2 \cdot \left(\frac{13176795}{2097152} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + {u2}^{2} \cdot \left(\frac{-762619864465648886625}{18446744073709551616} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{26482421150709471190661161091833125}{324518553658426726783156020576256} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right)\right)\right) \]
                                                                                                                                                              4. Step-by-step derivation
                                                                                                                                                                1. Applied rewrites54.4%

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

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

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

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

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

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

                                                                                                                                                                    1. Initial program 57.4%

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

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

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

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

                                                                                                                                                                      Alternative 21: 80.5% accurate, 2.2× speedup?

                                                                                                                                                                      \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                                      \[\begin{array}{l} \mathbf{if}\;1 - u1 \leq 0.9975000023841858:\\ \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{-\log \left(1 - u1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\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)
                                                                                                                                                                        (* u2 (* 6.2831854820251465 (sqrt (- (log (- 1.0 u1))))))
                                                                                                                                                                        (* u2 (* 6.2831854820251465 (sqrt (* u1 (+ 1.0 (* 0.5 u1))))))))
                                                                                                                                                                      float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                      	float tmp;
                                                                                                                                                                      	if ((1.0f - u1) <= 0.9975000023841858f) {
                                                                                                                                                                      		tmp = u2 * (6.2831854820251465f * sqrtf(-logf((1.0f - u1))));
                                                                                                                                                                      	} else {
                                                                                                                                                                      		tmp = u2 * (6.2831854820251465f * sqrtf((u1 * (1.0f + (0.5f * u1)))));
                                                                                                                                                                      	}
                                                                                                                                                                      	return tmp;
                                                                                                                                                                      }
                                                                                                                                                                      
                                                                                                                                                                      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
                                                                                                                                                                          real(4) :: tmp
                                                                                                                                                                          if ((1.0e0 - u1) <= 0.9975000023841858e0) then
                                                                                                                                                                              tmp = u2 * (6.2831854820251465e0 * sqrt(-log((1.0e0 - u1))))
                                                                                                                                                                          else
                                                                                                                                                                              tmp = u2 * (6.2831854820251465e0 * sqrt((u1 * (1.0e0 + (0.5e0 * u1)))))
                                                                                                                                                                          end if
                                                                                                                                                                          code = tmp
                                                                                                                                                                      end function
                                                                                                                                                                      
                                                                                                                                                                      function code(cosTheta_i, u1, u2)
                                                                                                                                                                      	tmp = Float32(0.0)
                                                                                                                                                                      	if (Float32(Float32(1.0) - u1) <= Float32(0.9975000023841858))
                                                                                                                                                                      		tmp = Float32(u2 * Float32(Float32(6.2831854820251465) * sqrt(Float32(-log(Float32(Float32(1.0) - u1))))));
                                                                                                                                                                      	else
                                                                                                                                                                      		tmp = Float32(u2 * Float32(Float32(6.2831854820251465) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1))))));
                                                                                                                                                                      	end
                                                                                                                                                                      	return tmp
                                                                                                                                                                      end
                                                                                                                                                                      
                                                                                                                                                                      function tmp_2 = code(cosTheta_i, u1, u2)
                                                                                                                                                                      	tmp = single(0.0);
                                                                                                                                                                      	if ((single(1.0) - u1) <= single(0.9975000023841858))
                                                                                                                                                                      		tmp = u2 * (single(6.2831854820251465) * sqrt(-log((single(1.0) - u1))));
                                                                                                                                                                      	else
                                                                                                                                                                      		tmp = u2 * (single(6.2831854820251465) * sqrt((u1 * (single(1.0) + (single(0.5) * u1)))));
                                                                                                                                                                      	end
                                                                                                                                                                      	tmp_2 = tmp;
                                                                                                                                                                      end
                                                                                                                                                                      
                                                                                                                                                                      \begin{array}{l}
                                                                                                                                                                      \mathbf{if}\;1 - u1 \leq 0.9975000023841858:\\
                                                                                                                                                                      \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{-\log \left(1 - u1\right)}\right)\\
                                                                                                                                                                      
                                                                                                                                                                      \mathbf{else}:\\
                                                                                                                                                                      \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)}\right)\\
                                                                                                                                                                      
                                                                                                                                                                      
                                                                                                                                                                      \end{array}
                                                                                                                                                                      
                                                                                                                                                                      Derivation
                                                                                                                                                                      1. Split input into 2 regimes
                                                                                                                                                                      2. if (-.f32 #s(literal 1 binary32) u1) < 0.997500002

                                                                                                                                                                        1. Initial program 57.4%

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

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

                                                                                                                                                                          \[\leadsto u2 \cdot \left(\frac{13176795}{2097152} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + {u2}^{2} \cdot \left(\frac{-762619864465648886625}{18446744073709551616} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{26482421150709471190661161091833125}{324518553658426726783156020576256} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right)\right)\right) \]
                                                                                                                                                                        4. Step-by-step derivation
                                                                                                                                                                          1. Applied rewrites54.4%

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

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

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

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

                                                                                                                                                                            1. Initial program 57.4%

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

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

                                                                                                                                                                              \[\leadsto u2 \cdot \left(\frac{13176795}{2097152} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + {u2}^{2} \cdot \left(\frac{-762619864465648886625}{18446744073709551616} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{26482421150709471190661161091833125}{324518553658426726783156020576256} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right)\right)\right) \]
                                                                                                                                                                            4. Step-by-step derivation
                                                                                                                                                                              1. Applied rewrites54.4%

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

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

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

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

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

                                                                                                                                                                                Alternative 22: 80.5% accurate, 2.2× speedup?

                                                                                                                                                                                \[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
                                                                                                                                                                                \[\begin{array}{l} \mathbf{if}\;1 - u1 \leq 0.9975000023841858:\\ \;\;\;\;6.2831854820251465 \cdot \left(u2 \cdot \sqrt{-\log \left(1 - u1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\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))))))
                                                                                                                                                                                  (* u2 (* 6.2831854820251465 (sqrt (* u1 (+ 1.0 (* 0.5 u1))))))))
                                                                                                                                                                                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 {
                                                                                                                                                                                		tmp = u2 * (6.2831854820251465f * sqrtf((u1 * (1.0f + (0.5f * u1)))));
                                                                                                                                                                                	}
                                                                                                                                                                                	return tmp;
                                                                                                                                                                                }
                                                                                                                                                                                
                                                                                                                                                                                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
                                                                                                                                                                                    real(4) :: tmp
                                                                                                                                                                                    if ((1.0e0 - u1) <= 0.9975000023841858e0) then
                                                                                                                                                                                        tmp = 6.2831854820251465e0 * (u2 * sqrt(-log((1.0e0 - u1))))
                                                                                                                                                                                    else
                                                                                                                                                                                        tmp = u2 * (6.2831854820251465e0 * sqrt((u1 * (1.0e0 + (0.5e0 * u1)))))
                                                                                                                                                                                    end if
                                                                                                                                                                                    code = tmp
                                                                                                                                                                                end function
                                                                                                                                                                                
                                                                                                                                                                                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))))));
                                                                                                                                                                                	else
                                                                                                                                                                                		tmp = Float32(u2 * Float32(Float32(6.2831854820251465) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1))))));
                                                                                                                                                                                	end
                                                                                                                                                                                	return tmp
                                                                                                                                                                                end
                                                                                                                                                                                
                                                                                                                                                                                function tmp_2 = code(cosTheta_i, u1, u2)
                                                                                                                                                                                	tmp = single(0.0);
                                                                                                                                                                                	if ((single(1.0) - u1) <= single(0.9975000023841858))
                                                                                                                                                                                		tmp = single(6.2831854820251465) * (u2 * sqrt(-log((single(1.0) - u1))));
                                                                                                                                                                                	else
                                                                                                                                                                                		tmp = u2 * (single(6.2831854820251465) * sqrt((u1 * (single(1.0) + (single(0.5) * u1)))));
                                                                                                                                                                                	end
                                                                                                                                                                                	tmp_2 = 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{else}:\\
                                                                                                                                                                                \;\;\;\;u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)}\right)\\
                                                                                                                                                                                
                                                                                                                                                                                
                                                                                                                                                                                \end{array}
                                                                                                                                                                                
                                                                                                                                                                                Derivation
                                                                                                                                                                                1. Split input into 2 regimes
                                                                                                                                                                                2. if (-.f32 #s(literal 1 binary32) u1) < 0.997500002

                                                                                                                                                                                  1. Initial program 57.4%

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

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

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

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

                                                                                                                                                                                    1. Initial program 57.4%

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

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

                                                                                                                                                                                      \[\leadsto u2 \cdot \left(\frac{13176795}{2097152} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + {u2}^{2} \cdot \left(\frac{-762619864465648886625}{18446744073709551616} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{26482421150709471190661161091833125}{324518553658426726783156020576256} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right)\right)\right) \]
                                                                                                                                                                                    4. Step-by-step derivation
                                                                                                                                                                                      1. Applied rewrites54.4%

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

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

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

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

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

                                                                                                                                                                                        Alternative 23: 74.1% accurate, 3.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 \cdot \left(1 + 0.5 \cdot 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)))
                                                                                                                                                                                          (* u2 (* 6.2831854820251465 (sqrt (* u1 (+ 1.0 (* 0.5 u1)))))))
                                                                                                                                                                                        float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                                        	return u2 * (6.2831854820251465f * sqrtf((u1 * (1.0f + (0.5f * 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 * (1.0e0 + (0.5e0 * u1)))))
                                                                                                                                                                                        end function
                                                                                                                                                                                        
                                                                                                                                                                                        function code(cosTheta_i, u1, u2)
                                                                                                                                                                                        	return Float32(u2 * Float32(Float32(6.2831854820251465) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) * u1))))))
                                                                                                                                                                                        end
                                                                                                                                                                                        
                                                                                                                                                                                        function tmp = code(cosTheta_i, u1, u2)
                                                                                                                                                                                        	tmp = u2 * (single(6.2831854820251465) * sqrt((u1 * (single(1.0) + (single(0.5) * u1)))));
                                                                                                                                                                                        end
                                                                                                                                                                                        
                                                                                                                                                                                        u2 \cdot \left(6.2831854820251465 \cdot \sqrt{u1 \cdot \left(1 + 0.5 \cdot u1\right)}\right)
                                                                                                                                                                                        
                                                                                                                                                                                        Derivation
                                                                                                                                                                                        1. Initial program 57.4%

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

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

                                                                                                                                                                                          \[\leadsto u2 \cdot \left(\frac{13176795}{2097152} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + {u2}^{2} \cdot \left(\frac{-762619864465648886625}{18446744073709551616} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{26482421150709471190661161091833125}{324518553658426726783156020576256} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right)\right)\right) \]
                                                                                                                                                                                        4. Step-by-step derivation
                                                                                                                                                                                          1. Applied rewrites54.4%

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

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

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

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

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

                                                                                                                                                                                              Alternative 24: 74.1% 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)\]
                                                                                                                                                                                              \[\left(6.2831854820251465 \cdot u2\right) \cdot \sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \]
                                                                                                                                                                                              (FPCore (cosTheta_i u1 u2)
                                                                                                                                                                                                :precision binary32
                                                                                                                                                                                                :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0))
                                                                                                                                                                                                        (and (<= 2.328306437e-10 u1) (<= u1 1.0)))
                                                                                                                                                                                                   (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
                                                                                                                                                                                                (* (* 6.2831854820251465 u2) (sqrt (* (fma 0.5 u1 1.0) u1))))
                                                                                                                                                                                              float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                                              	return (6.2831854820251465f * u2) * sqrtf((fmaf(0.5f, u1, 1.0f) * u1));
                                                                                                                                                                                              }
                                                                                                                                                                                              
                                                                                                                                                                                              function code(cosTheta_i, u1, u2)
                                                                                                                                                                                              	return Float32(Float32(Float32(6.2831854820251465) * u2) * sqrt(Float32(fma(Float32(0.5), u1, Float32(1.0)) * u1)))
                                                                                                                                                                                              end
                                                                                                                                                                                              
                                                                                                                                                                                              \left(6.2831854820251465 \cdot u2\right) \cdot \sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1}
                                                                                                                                                                                              
                                                                                                                                                                                              Derivation
                                                                                                                                                                                              1. Initial program 57.4%

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

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

                                                                                                                                                                                                  \[\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 rewrites74.1%

                                                                                                                                                                                                    \[\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 rewrites74.1%

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

                                                                                                                                                                                                    Alternative 25: 74.1% 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 57.4%

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

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

                                                                                                                                                                                                        \[\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 rewrites74.1%

                                                                                                                                                                                                          \[\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 rewrites74.1%

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

                                                                                                                                                                                                          Alternative 26: 66.4% 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)\]
                                                                                                                                                                                                          \[2 \cdot \frac{\left(u1 \cdot u2\right) \cdot \pi}{\sqrt{\left|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)))
                                                                                                                                                                                                            (* 2.0 (/ (* (* u1 u2) PI) (sqrt (fabs u1)))))
                                                                                                                                                                                                          float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                                                          	return 2.0f * (((u1 * u2) * ((float) M_PI)) / sqrtf(fabsf(u1)));
                                                                                                                                                                                                          }
                                                                                                                                                                                                          
                                                                                                                                                                                                          function code(cosTheta_i, u1, u2)
                                                                                                                                                                                                          	return Float32(Float32(2.0) * Float32(Float32(Float32(u1 * u2) * Float32(pi)) / sqrt(abs(u1))))
                                                                                                                                                                                                          end
                                                                                                                                                                                                          
                                                                                                                                                                                                          function tmp = code(cosTheta_i, u1, u2)
                                                                                                                                                                                                          	tmp = single(2.0) * (((u1 * u2) * single(pi)) / sqrt(abs(u1)));
                                                                                                                                                                                                          end
                                                                                                                                                                                                          
                                                                                                                                                                                                          2 \cdot \frac{\left(u1 \cdot u2\right) \cdot \pi}{\sqrt{\left|u1\right|}}
                                                                                                                                                                                                          
                                                                                                                                                                                                          Derivation
                                                                                                                                                                                                          1. Initial program 57.4%

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

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

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

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

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

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

                                                                                                                                                                                                                  Alternative 27: 66.4% 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)\]
                                                                                                                                                                                                                  \[\sqrt{u1} \cdot \left(u2 \cdot 6.2831854820251465\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 u1) (* u2 6.2831854820251465)))
                                                                                                                                                                                                                  float code(float cosTheta_i, float u1, float u2) {
                                                                                                                                                                                                                  	return sqrtf(u1) * (u2 * 6.2831854820251465f);
                                                                                                                                                                                                                  }
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  real(4) function code(costheta_i, u1, u2)
                                                                                                                                                                                                                  use fmin_fmax_functions
                                                                                                                                                                                                                      real(4), intent (in) :: costheta_i
                                                                                                                                                                                                                      real(4), intent (in) :: u1
                                                                                                                                                                                                                      real(4), intent (in) :: u2
                                                                                                                                                                                                                      code = sqrt(u1) * (u2 * 6.2831854820251465e0)
                                                                                                                                                                                                                  end function
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  function code(cosTheta_i, u1, u2)
                                                                                                                                                                                                                  	return Float32(sqrt(u1) * Float32(u2 * Float32(6.2831854820251465)))
                                                                                                                                                                                                                  end
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  function tmp = code(cosTheta_i, u1, u2)
                                                                                                                                                                                                                  	tmp = sqrt(u1) * (u2 * single(6.2831854820251465));
                                                                                                                                                                                                                  end
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  \sqrt{u1} \cdot \left(u2 \cdot 6.2831854820251465\right)
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  Derivation
                                                                                                                                                                                                                  1. Initial program 57.4%

                                                                                                                                                                                                                    \[\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 \sqrt{u1} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
                                                                                                                                                                                                                  3. Step-by-step derivation
                                                                                                                                                                                                                    1. Applied rewrites76.8%

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

                                                                                                                                                                                                                      \[\leadsto \sqrt{u1} \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 rewrites70.8%

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

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

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

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

                                                                                                                                                                                                                        Alternative 28: 66.4% 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 57.4%

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

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

                                                                                                                                                                                                                          \[\leadsto u2 \cdot \left(\frac{13176795}{2097152} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + {u2}^{2} \cdot \left(\frac{-762619864465648886625}{18446744073709551616} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)} + \frac{26482421150709471190661161091833125}{324518553658426726783156020576256} \cdot \left({u2}^{2} \cdot \sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right)\right)\right) \]
                                                                                                                                                                                                                        4. Step-by-step derivation
                                                                                                                                                                                                                          1. Applied rewrites54.4%

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

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

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

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

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

                                                                                                                                                                                                                              Alternative 29: 66.4% 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 57.4%

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

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

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

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

                                                                                                                                                                                                                                  Reproduce

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