Beckmann Sample, near normal, slope_y

Percentage Accurate: 57.3% → 98.3%
Time: 15.4s
Alternatives: 21
Speedup: 2.9×

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)\]
\[\begin{array}{l} \\ \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (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
\begin{array}{l}

\\
\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right)
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 21 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.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (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
\begin{array}{l}

\\
\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right)
\end{array}

Alternative 1: 98.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (- (log1p (- u1)))) (sin (* 2.0 (* PI u2)))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-log1pf(-u1)) * sinf((2.0f * (((float) M_PI) * u2)));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * sin(Float32(Float32(2.0) * Float32(Float32(pi) * u2))))
end
\begin{array}{l}

\\
\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)
\end{array}
Derivation
  1. Initial program 59.1%

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

      \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
    2. sqrt-lowering-sqrt.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
    3. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
    4. sub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
    5. log1p-defineN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
    6. log1p-lowering-log1p.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
    7. neg-lowering-neg.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
    8. sin-lowering-sin.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. associate-*l*N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
    10. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
    11. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
    12. PI-lowering-PI.f3298.3%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 97.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ t_1 := 1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\\ \mathbf{if}\;t\_0 \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot {\left(t\_1 \cdot \left(\left(u1 \cdot u1\right) \cdot t\_1\right)\right)}^{0.25}\\ \end{array} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (let* ((t_0 (* u2 (* 2.0 PI)))
        (t_1 (+ 1.0 (* u1 (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25))))))))
   (if (<= t_0 0.09000000357627869)
     (*
      (sqrt (- (log1p (- u1))))
      (* u2 (* PI (+ 2.0 (* (* -1.3333333333333333 (* u2 u2)) (* PI PI))))))
     (* (sin t_0) (pow (* t_1 (* (* u1 u1) t_1)) 0.25)))))
float code(float cosTheta_i, float u1, float u2) {
	float t_0 = u2 * (2.0f * ((float) M_PI));
	float t_1 = 1.0f + (u1 * (0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f)))));
	float tmp;
	if (t_0 <= 0.09000000357627869f) {
		tmp = sqrtf(-log1pf(-u1)) * (u2 * (((float) M_PI) * (2.0f + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * ((float) M_PI))))));
	} else {
		tmp = sinf(t_0) * powf((t_1 * ((u1 * u1) * t_1)), 0.25f);
	}
	return tmp;
}
function code(cosTheta_i, u1, u2)
	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
	t_1 = Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25)))))))
	tmp = Float32(0.0)
	if (t_0 <= Float32(0.09000000357627869))
		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * Float32(Float32(pi) * Float32(Float32(2.0) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(pi)))))));
	else
		tmp = Float32(sin(t_0) * (Float32(t_1 * Float32(Float32(u1 * u1) * t_1)) ^ Float32(0.25)));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
t_1 := 1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\\
\mathbf{if}\;t\_0 \leq 0.09000000357627869:\\
\;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\sin t\_0 \cdot {\left(t\_1 \cdot \left(\left(u1 \cdot u1\right) \cdot t\_1\right)\right)}^{0.25}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0900000036

    1. Initial program 59.6%

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
      2. sqrt-lowering-sqrt.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
      3. neg-lowering-neg.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
      4. sub-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
      5. log1p-defineN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
      6. log1p-lowering-log1p.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
      7. neg-lowering-neg.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
      8. sin-lowering-sin.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
      9. associate-*l*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
      10. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
      11. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
      12. PI-lowering-PI.f3298.4%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
    3. Simplified98.4%

      \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \color{blue}{\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)}\right)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \color{blue}{\frac{-4}{3}}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \color{blue}{\left({\mathsf{PI}\left(\right)}^{3} \cdot \frac{-4}{3}\right)}\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right)\right) \]
      5. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)}\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot \frac{-4}{3}\right) \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}\right)\right)\right) \]
      8. unpow3N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
      9. associate-*r*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      10. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
      11. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
      12. PI-lowering-PI.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\color{blue}{2} + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
      13. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \color{blue}{\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right)\right)\right) \]
    7. Simplified98.3%

      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)} \]

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

    1. Initial program 57.3%

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
      2. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
      3. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      6. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      8. *-lowering-*.f3295.5%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    5. Simplified95.5%

      \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    6. Step-by-step derivation
      1. pow1/2N/A

        \[\leadsto \mathsf{*.f32}\left(\left({\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)}^{\frac{1}{2}}\right), \mathsf{sin.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)}\right)\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f32}\left(\left({\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)}^{\left(\frac{1}{4} + \frac{1}{4}\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), \color{blue}{u2}\right)\right)\right) \]
      3. pow-prod-upN/A

        \[\leadsto \mathsf{*.f32}\left(\left({\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)}^{\frac{1}{4}} \cdot {\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)}^{\frac{1}{4}}\right), \mathsf{sin.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)}\right)\right) \]
      4. pow-prod-downN/A

        \[\leadsto \mathsf{*.f32}\left(\left({\left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot \left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)}^{\frac{1}{4}}\right), \mathsf{sin.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)}\right)\right) \]
      5. pow-lowering-pow.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot \left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)}\right)\right) \]
    7. Applied egg-rr95.6%

      \[\leadsto \color{blue}{{\left(\left(u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)\right) \cdot \left(u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)\right)\right)}^{0.25}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\left(\left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right) \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\left(\left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot \left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
      3. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right), \left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
      4. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right), \left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right), \left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      6. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right), \left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      7. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right), \left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      8. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right), \left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      9. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right), \left(\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right), \left(\left(\left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot u1\right) \cdot u1\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right), \left(\left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot \left(u1 \cdot u1\right)\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
      12. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(\left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right), \left(u1 \cdot u1\right)\right)\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
    9. Applied egg-rr95.7%

      \[\leadsto {\color{blue}{\left(\left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right) \cdot \left(\left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right) \cdot \left(u1 \cdot u1\right)\right)\right)}}^{0.25} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot {\left(\left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right) \cdot \left(\left(u1 \cdot u1\right) \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)\right)\right)}^{0.25}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 97.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{\frac{u1 \cdot \left(1 - \left(u1 \cdot u1\right) \cdot \left(0.25 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.3611111111111111\right)\right)\right)}{1 - u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)}}\\ \end{array} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (let* ((t_0 (* u2 (* 2.0 PI))))
   (if (<= t_0 0.09000000357627869)
     (*
      (sqrt (- (log1p (- u1))))
      (* u2 (* PI (+ 2.0 (* (* -1.3333333333333333 (* u2 u2)) (* PI PI))))))
     (*
      (sin t_0)
      (sqrt
       (/
        (*
         u1
         (-
          1.0
          (*
           (* u1 u1)
           (+ 0.25 (* u1 (+ 0.3333333333333333 (* u1 0.3611111111111111)))))))
        (- 1.0 (* u1 (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25))))))))))))
float code(float cosTheta_i, float u1, float u2) {
	float t_0 = u2 * (2.0f * ((float) M_PI));
	float tmp;
	if (t_0 <= 0.09000000357627869f) {
		tmp = sqrtf(-log1pf(-u1)) * (u2 * (((float) M_PI) * (2.0f + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * ((float) M_PI))))));
	} else {
		tmp = sinf(t_0) * sqrtf(((u1 * (1.0f - ((u1 * u1) * (0.25f + (u1 * (0.3333333333333333f + (u1 * 0.3611111111111111f))))))) / (1.0f - (u1 * (0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f))))))));
	}
	return tmp;
}
function code(cosTheta_i, u1, u2)
	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
	tmp = Float32(0.0)
	if (t_0 <= Float32(0.09000000357627869))
		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * Float32(Float32(pi) * Float32(Float32(2.0) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(pi)))))));
	else
		tmp = Float32(sin(t_0) * sqrt(Float32(Float32(u1 * Float32(Float32(1.0) - Float32(Float32(u1 * u1) * Float32(Float32(0.25) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.3611111111111111)))))))) / Float32(Float32(1.0) - Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25))))))))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
\mathbf{if}\;t\_0 \leq 0.09000000357627869:\\
\;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\sin t\_0 \cdot \sqrt{\frac{u1 \cdot \left(1 - \left(u1 \cdot u1\right) \cdot \left(0.25 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.3611111111111111\right)\right)\right)}{1 - u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0900000036

    1. Initial program 59.6%

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
      2. sqrt-lowering-sqrt.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
      3. neg-lowering-neg.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
      4. sub-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
      5. log1p-defineN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
      6. log1p-lowering-log1p.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
      7. neg-lowering-neg.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
      8. sin-lowering-sin.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
      9. associate-*l*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
      10. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
      11. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
      12. PI-lowering-PI.f3298.4%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
    3. Simplified98.4%

      \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \color{blue}{\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)}\right)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \color{blue}{\frac{-4}{3}}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \color{blue}{\left({\mathsf{PI}\left(\right)}^{3} \cdot \frac{-4}{3}\right)}\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right)\right) \]
      5. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)}\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot \frac{-4}{3}\right) \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}\right)\right)\right) \]
      8. unpow3N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
      9. associate-*r*N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
      10. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
      11. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
      12. PI-lowering-PI.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\color{blue}{2} + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
      13. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \color{blue}{\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right)\right)\right) \]
    7. Simplified98.3%

      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)} \]

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

    1. Initial program 57.3%

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
      2. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
      3. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      6. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      8. *-lowering-*.f3295.5%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    5. Simplified95.5%

      \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
      2. flip-+N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\frac{1 \cdot 1 - \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)}{1 - u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)} \cdot u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      3. associate-*l/N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\frac{\left(1 \cdot 1 - \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1}{1 - u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)}\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
      4. /-lowering-/.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\left(\left(1 \cdot 1 - \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right), \left(1 - u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
    7. Applied egg-rr95.7%

      \[\leadsto \sqrt{\color{blue}{\frac{\left(1 - \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(\left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(u1 \cdot u1\right)\right)\right) \cdot u1}{1 - u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    8. Taylor expanded in u1 around 0

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \color{blue}{\left({u1}^{2} \cdot \left(\frac{1}{4} + u1 \cdot \left(\frac{1}{3} + \frac{13}{36} \cdot u1\right)\right)\right)}\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    9. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\left({u1}^{2}\right), \left(\frac{1}{4} + u1 \cdot \left(\frac{1}{3} + \frac{13}{36} \cdot u1\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\left(u1 \cdot u1\right), \left(\frac{1}{4} + u1 \cdot \left(\frac{1}{3} + \frac{13}{36} \cdot u1\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      3. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \left(\frac{1}{4} + u1 \cdot \left(\frac{1}{3} + \frac{13}{36} \cdot u1\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \mathsf{+.f32}\left(\frac{1}{4}, \left(u1 \cdot \left(\frac{1}{3} + \frac{13}{36} \cdot u1\right)\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{13}{36} \cdot u1\right)\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      6. +-lowering-+.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{13}{36} \cdot u1\right)\right)\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{13}{36}\right)\right)\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      8. *-lowering-*.f3295.7%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \mathsf{+.f32}\left(\frac{1}{4}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{13}{36}\right)\right)\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    10. Simplified95.7%

      \[\leadsto \sqrt{\frac{\left(1 - \color{blue}{\left(u1 \cdot u1\right) \cdot \left(0.25 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.3611111111111111\right)\right)}\right) \cdot u1}{1 - u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\frac{u1 \cdot \left(1 - \left(u1 \cdot u1\right) \cdot \left(0.25 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.3611111111111111\right)\right)\right)}{1 - u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 94.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\\ \sqrt{\frac{u1 \cdot \left(1 - t\_0 \cdot \left(\left(0.5 + u1 \cdot 0.3333333333333333\right) \cdot \left(u1 \cdot u1\right)\right)\right)}{1 - u1 \cdot t\_0}} \cdot \sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \end{array} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (let* ((t_0 (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25))))))
   (*
    (sqrt
     (/
      (* u1 (- 1.0 (* t_0 (* (+ 0.5 (* u1 0.3333333333333333)) (* u1 u1)))))
      (- 1.0 (* u1 t_0))))
    (sin (* u2 (* 2.0 PI))))))
float code(float cosTheta_i, float u1, float u2) {
	float t_0 = 0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f)));
	return sqrtf(((u1 * (1.0f - (t_0 * ((0.5f + (u1 * 0.3333333333333333f)) * (u1 * u1))))) / (1.0f - (u1 * t_0)))) * sinf((u2 * (2.0f * ((float) M_PI))));
}
function code(cosTheta_i, u1, u2)
	t_0 = Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25)))))
	return Float32(sqrt(Float32(Float32(u1 * Float32(Float32(1.0) - Float32(t_0 * Float32(Float32(Float32(0.5) + Float32(u1 * Float32(0.3333333333333333))) * Float32(u1 * u1))))) / Float32(Float32(1.0) - Float32(u1 * t_0)))) * sin(Float32(u2 * Float32(Float32(2.0) * Float32(pi)))))
end
function tmp = code(cosTheta_i, u1, u2)
	t_0 = single(0.5) + (u1 * (single(0.3333333333333333) + (u1 * single(0.25))));
	tmp = sqrt(((u1 * (single(1.0) - (t_0 * ((single(0.5) + (u1 * single(0.3333333333333333))) * (u1 * u1))))) / (single(1.0) - (u1 * t_0)))) * sin((u2 * (single(2.0) * single(pi))));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\\
\sqrt{\frac{u1 \cdot \left(1 - t\_0 \cdot \left(\left(0.5 + u1 \cdot 0.3333333333333333\right) \cdot \left(u1 \cdot u1\right)\right)\right)}{1 - u1 \cdot t\_0}} \cdot \sin \left(u2 \cdot \left(2 \cdot \pi\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 59.1%

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
    2. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    4. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    6. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    8. *-lowering-*.f3294.0%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
  5. Simplified94.0%

    \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
    2. flip-+N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\frac{1 \cdot 1 - \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)}{1 - u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)} \cdot u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
    3. associate-*l/N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\frac{\left(1 \cdot 1 - \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1}{1 - u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)}\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\left(\left(1 \cdot 1 - \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right) \cdot u1\right), \left(1 - u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
  7. Applied egg-rr94.1%

    \[\leadsto \sqrt{\color{blue}{\frac{\left(1 - \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(\left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(u1 \cdot u1\right)\right)\right) \cdot u1}{1 - u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)}}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  8. Taylor expanded in u1 around 0

    \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \color{blue}{\frac{1}{3}}\right)\right), \mathsf{*.f32}\left(u1, u1\right)\right)\right)\right), u1\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
  9. Step-by-step derivation
    1. Simplified94.7%

      \[\leadsto \sqrt{\frac{\left(1 - \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(\left(0.5 + u1 \cdot \color{blue}{0.3333333333333333}\right) \cdot \left(u1 \cdot u1\right)\right)\right) \cdot u1}{1 - u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    2. Final simplification94.7%

      \[\leadsto \sqrt{\frac{u1 \cdot \left(1 - \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(\left(0.5 + u1 \cdot 0.3333333333333333\right) \cdot \left(u1 \cdot u1\right)\right)\right)}{1 - u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)}} \cdot \sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \]
    3. Add Preprocessing

    Alternative 5: 97.3% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{u1 + \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(u1 \cdot u1\right)}\\ \end{array} \end{array} \]
    (FPCore (cosTheta_i u1 u2)
     :precision binary32
     (let* ((t_0 (* u2 (* 2.0 PI))))
       (if (<= t_0 0.09000000357627869)
         (*
          (sqrt (- (log1p (- u1))))
          (* u2 (* PI (+ 2.0 (* (* -1.3333333333333333 (* u2 u2)) (* PI PI))))))
         (*
          (sin t_0)
          (sqrt
           (+
            u1
            (* (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25)))) (* u1 u1))))))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = u2 * (2.0f * ((float) M_PI));
    	float tmp;
    	if (t_0 <= 0.09000000357627869f) {
    		tmp = sqrtf(-log1pf(-u1)) * (u2 * (((float) M_PI) * (2.0f + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * ((float) M_PI))))));
    	} else {
    		tmp = sinf(t_0) * sqrtf((u1 + ((0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f)))) * (u1 * u1))));
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.09000000357627869))
    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * Float32(Float32(pi) * Float32(Float32(2.0) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(pi)))))));
    	else
    		tmp = Float32(sin(t_0) * sqrt(Float32(u1 + Float32(Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25))))) * Float32(u1 * u1)))));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.09000000357627869:\\
    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin t\_0 \cdot \sqrt{u1 + \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(u1 \cdot u1\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0900000036

      1. Initial program 59.6%

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

          \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        2. sqrt-lowering-sqrt.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        3. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        5. log1p-defineN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        6. log1p-lowering-log1p.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        7. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        8. sin-lowering-sin.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
        9. associate-*l*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        10. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
        12. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
      3. Simplified98.4%

        \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
      4. Add Preprocessing
      5. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      6. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \color{blue}{\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)}\right)\right)\right) \]
        2. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \color{blue}{\frac{-4}{3}}\right)\right)\right) \]
        3. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \color{blue}{\left({\mathsf{PI}\left(\right)}^{3} \cdot \frac{-4}{3}\right)}\right)\right)\right) \]
        4. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right)\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)}\right)\right) \]
        6. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot \frac{-4}{3}\right) \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right) \]
        7. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}\right)\right)\right) \]
        8. unpow3N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
        9. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
        10. distribute-rgt-outN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
        12. PI-lowering-PI.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\color{blue}{2} + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
        13. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \color{blue}{\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right)\right) \]
        14. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right)\right)\right) \]
      7. Simplified98.3%

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)} \]

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

      1. Initial program 57.3%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        6. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        7. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        8. *-lowering-*.f3295.5%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. Simplified95.5%

        \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
      6. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right) + 1\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        2. distribute-rgt-inN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot u1 + 1 \cdot u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        3. *-lft-identityN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot u1 + u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        4. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\left(\left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right) \cdot u1\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        5. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\left(\left(\left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right) \cdot u1\right) \cdot u1\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        6. associate-*l*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\left(\left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right) \cdot \left(u1 \cdot u1\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        7. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right), \left(u1 \cdot u1\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        8. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right), \left(u1 \cdot u1\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        9. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + u1 \cdot \frac{1}{4}\right)\right)\right), \left(u1 \cdot u1\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        10. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right), \left(u1 \cdot u1\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right), \left(u1 \cdot u1\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        12. *-lowering-*.f3295.7%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right), \mathsf{*.f32}\left(u1, u1\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      7. Applied egg-rr95.7%

        \[\leadsto \sqrt{\color{blue}{\left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(u1 \cdot u1\right) + u1}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification97.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{u1 + \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right) \cdot \left(u1 \cdot u1\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 6: 97.3% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)}\\ \end{array} \end{array} \]
    (FPCore (cosTheta_i u1 u2)
     :precision binary32
     (let* ((t_0 (* u2 (* 2.0 PI))))
       (if (<= t_0 0.09000000357627869)
         (*
          (sqrt (- (log1p (- u1))))
          (* u2 (* PI (+ 2.0 (* (* -1.3333333333333333 (* u2 u2)) (* PI PI))))))
         (*
          (sin t_0)
          (sqrt
           (*
            u1
            (+ 1.0 (* u1 (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25))))))))))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = u2 * (2.0f * ((float) M_PI));
    	float tmp;
    	if (t_0 <= 0.09000000357627869f) {
    		tmp = sqrtf(-log1pf(-u1)) * (u2 * (((float) M_PI) * (2.0f + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * ((float) M_PI))))));
    	} else {
    		tmp = sinf(t_0) * sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f))))))));
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.09000000357627869))
    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * Float32(Float32(pi) * Float32(Float32(2.0) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(pi)))))));
    	else
    		tmp = Float32(sin(t_0) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25))))))))));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.09000000357627869:\\
    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin t\_0 \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0900000036

      1. Initial program 59.6%

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

          \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        2. sqrt-lowering-sqrt.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        3. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        5. log1p-defineN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        6. log1p-lowering-log1p.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        7. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        8. sin-lowering-sin.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
        9. associate-*l*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        10. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
        12. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
      3. Simplified98.4%

        \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
      4. Add Preprocessing
      5. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      6. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \color{blue}{\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)}\right)\right)\right) \]
        2. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \color{blue}{\frac{-4}{3}}\right)\right)\right) \]
        3. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \color{blue}{\left({\mathsf{PI}\left(\right)}^{3} \cdot \frac{-4}{3}\right)}\right)\right)\right) \]
        4. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right)\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)}\right)\right) \]
        6. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot \frac{-4}{3}\right) \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right) \]
        7. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}\right)\right)\right) \]
        8. unpow3N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
        9. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
        10. distribute-rgt-outN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
        12. PI-lowering-PI.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\color{blue}{2} + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
        13. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \color{blue}{\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right)\right) \]
        14. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right)\right)\right) \]
      7. Simplified98.3%

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)} \]

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

      1. Initial program 57.3%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        6. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        7. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        8. *-lowering-*.f3295.5%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. Simplified95.5%

        \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification97.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 7: 97.0% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}\\ \end{array} \end{array} \]
    (FPCore (cosTheta_i u1 u2)
     :precision binary32
     (let* ((t_0 (* u2 (* 2.0 PI))))
       (if (<= t_0 0.09000000357627869)
         (*
          (sqrt (- (log1p (- u1))))
          (* u2 (* PI (+ 2.0 (* (* -1.3333333333333333 (* u2 u2)) (* PI PI))))))
         (*
          (sin t_0)
          (sqrt (* u1 (+ 1.0 (* u1 (+ 0.5 (* u1 0.3333333333333333))))))))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = u2 * (2.0f * ((float) M_PI));
    	float tmp;
    	if (t_0 <= 0.09000000357627869f) {
    		tmp = sqrtf(-log1pf(-u1)) * (u2 * (((float) M_PI) * (2.0f + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * ((float) M_PI))))));
    	} else {
    		tmp = sinf(t_0) * sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * 0.3333333333333333f))))));
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.09000000357627869))
    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(u2 * Float32(Float32(pi) * Float32(Float32(2.0) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(pi)))))));
    	else
    		tmp = Float32(sin(t_0) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(0.3333333333333333))))))));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.09000000357627869:\\
    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin t\_0 \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0900000036

      1. Initial program 59.6%

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

          \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        2. sqrt-lowering-sqrt.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        3. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        5. log1p-defineN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        6. log1p-lowering-log1p.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        7. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        8. sin-lowering-sin.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
        9. associate-*l*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        10. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
        12. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
      3. Simplified98.4%

        \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
      4. Add Preprocessing
      5. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      6. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \color{blue}{\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)}\right)\right)\right) \]
        2. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \color{blue}{\frac{-4}{3}}\right)\right)\right) \]
        3. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \color{blue}{\left({\mathsf{PI}\left(\right)}^{3} \cdot \frac{-4}{3}\right)}\right)\right)\right) \]
        4. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \left(u2 \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right)\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)}\right)\right) \]
        6. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left({u2}^{2} \cdot \frac{-4}{3}\right) \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}\right)\right)\right) \]
        7. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}\right)\right)\right) \]
        8. unpow3N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
        9. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(2 \cdot \mathsf{PI}\left(\right) + \left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
        10. distribute-rgt-outN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\left(2 + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
        12. PI-lowering-PI.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\color{blue}{2} + \left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
        13. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \color{blue}{\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right)\right) \]
        14. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right)\right)\right) \]
      7. Simplified98.3%

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)} \]

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

      1. Initial program 57.3%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        5. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \frac{1}{3}\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        6. *-lowering-*.f3293.9%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \frac{1}{3}\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. Simplified93.9%

        \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification97.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.09000000357627869:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(u2 \cdot \left(\pi \cdot \left(2 + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 8: 95.3% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.0005000000237487257:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}\\ \end{array} \end{array} \]
    (FPCore (cosTheta_i u1 u2)
     :precision binary32
     (let* ((t_0 (* u2 (* 2.0 PI))))
       (if (<= t_0 0.0005000000237487257)
         (* (sqrt (- (log1p (- u1)))) (* 2.0 (* PI u2)))
         (*
          (sin t_0)
          (sqrt (* u1 (+ 1.0 (* u1 (+ 0.5 (* u1 0.3333333333333333))))))))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = u2 * (2.0f * ((float) M_PI));
    	float tmp;
    	if (t_0 <= 0.0005000000237487257f) {
    		tmp = sqrtf(-log1pf(-u1)) * (2.0f * (((float) M_PI) * u2));
    	} else {
    		tmp = sinf(t_0) * sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * 0.3333333333333333f))))));
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.0005000000237487257))
    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(Float32(2.0) * Float32(Float32(pi) * u2)));
    	else
    		tmp = Float32(sin(t_0) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(0.3333333333333333))))))));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.0005000000237487257:\\
    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin t\_0 \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 5.00000024e-4

      1. Initial program 58.8%

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

          \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        2. sqrt-lowering-sqrt.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        3. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        5. log1p-defineN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        6. log1p-lowering-log1p.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        7. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        8. sin-lowering-sin.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
        9. associate-*l*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        10. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
        12. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
      3. Simplified98.4%

        \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
      4. Add Preprocessing
      5. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      6. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
        2. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
        3. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
      7. Simplified98.4%

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]

      if 5.00000024e-4 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

      1. Initial program 59.5%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        5. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \frac{1}{3}\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        6. *-lowering-*.f3293.1%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \frac{1}{3}\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. Simplified93.1%

        \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification96.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.0005000000237487257:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 9: 93.7% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.0005000000237487257:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{\left(u1 \cdot u1\right) \cdot \left(0.5 + \frac{1}{u1}\right)}\\ \end{array} \end{array} \]
    (FPCore (cosTheta_i u1 u2)
     :precision binary32
     (let* ((t_0 (* u2 (* 2.0 PI))))
       (if (<= t_0 0.0005000000237487257)
         (* (sqrt (- (log1p (- u1)))) (* 2.0 (* PI u2)))
         (* (sin t_0) (sqrt (* (* u1 u1) (+ 0.5 (/ 1.0 u1))))))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = u2 * (2.0f * ((float) M_PI));
    	float tmp;
    	if (t_0 <= 0.0005000000237487257f) {
    		tmp = sqrtf(-log1pf(-u1)) * (2.0f * (((float) M_PI) * u2));
    	} else {
    		tmp = sinf(t_0) * sqrtf(((u1 * u1) * (0.5f + (1.0f / u1))));
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.0005000000237487257))
    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(Float32(2.0) * Float32(Float32(pi) * u2)));
    	else
    		tmp = Float32(sin(t_0) * sqrt(Float32(Float32(u1 * u1) * Float32(Float32(0.5) + Float32(Float32(1.0) / u1)))));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.0005000000237487257:\\
    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin t\_0 \cdot \sqrt{\left(u1 \cdot u1\right) \cdot \left(0.5 + \frac{1}{u1}\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 5.00000024e-4

      1. Initial program 58.8%

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

          \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        2. sqrt-lowering-sqrt.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        3. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        5. log1p-defineN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        6. log1p-lowering-log1p.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        7. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        8. sin-lowering-sin.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
        9. associate-*l*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        10. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
        12. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
      3. Simplified98.4%

        \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
      4. Add Preprocessing
      5. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      6. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
        2. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
        3. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
      7. Simplified98.4%

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]

      if 5.00000024e-4 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

      1. Initial program 59.5%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \frac{1}{2} \cdot u1\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(\frac{1}{2} \cdot u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        3. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. *-lowering-*.f3289.6%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. Simplified89.6%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left({u1}^{2} \cdot \left(\frac{1}{2} + \frac{1}{u1}\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      7. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\left({u1}^{2}\right), \left(\frac{1}{2} + \frac{1}{u1}\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. unpow2N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\left(u1 \cdot u1\right), \left(\frac{1}{2} + \frac{1}{u1}\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \left(\frac{1}{2} + \frac{1}{u1}\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. +-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \left(\frac{1}{u1} + \frac{1}{2}\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        5. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \mathsf{+.f32}\left(\left(\frac{1}{u1}\right), \frac{1}{2}\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        6. /-lowering-/.f3289.7%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \mathsf{+.f32}\left(\mathsf{/.f32}\left(1, u1\right), \frac{1}{2}\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      8. Simplified89.7%

        \[\leadsto \sqrt{\color{blue}{\left(u1 \cdot u1\right) \cdot \left(\frac{1}{u1} + 0.5\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification94.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.0005000000237487257:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(u1 \cdot u1\right) \cdot \left(0.5 + \frac{1}{u1}\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 10: 93.7% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.0005000000237487257:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{u1 + u1 \cdot \left(u1 \cdot 0.5\right)}\\ \end{array} \end{array} \]
    (FPCore (cosTheta_i u1 u2)
     :precision binary32
     (let* ((t_0 (* u2 (* 2.0 PI))))
       (if (<= t_0 0.0005000000237487257)
         (* (sqrt (- (log1p (- u1)))) (* 2.0 (* PI u2)))
         (* (sin t_0) (sqrt (+ u1 (* u1 (* u1 0.5))))))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = u2 * (2.0f * ((float) M_PI));
    	float tmp;
    	if (t_0 <= 0.0005000000237487257f) {
    		tmp = sqrtf(-log1pf(-u1)) * (2.0f * (((float) M_PI) * u2));
    	} else {
    		tmp = sinf(t_0) * sqrtf((u1 + (u1 * (u1 * 0.5f))));
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.0005000000237487257))
    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(Float32(2.0) * Float32(Float32(pi) * u2)));
    	else
    		tmp = Float32(sin(t_0) * sqrt(Float32(u1 + Float32(u1 * Float32(u1 * Float32(0.5))))));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.0005000000237487257:\\
    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin t\_0 \cdot \sqrt{u1 + u1 \cdot \left(u1 \cdot 0.5\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 5.00000024e-4

      1. Initial program 58.8%

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

          \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        2. sqrt-lowering-sqrt.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        3. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        5. log1p-defineN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        6. log1p-lowering-log1p.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        7. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        8. sin-lowering-sin.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
        9. associate-*l*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        10. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
        12. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
      3. Simplified98.4%

        \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
      4. Add Preprocessing
      5. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      6. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
        2. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
        3. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
      7. Simplified98.4%

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]

      if 5.00000024e-4 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

      1. Initial program 59.5%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \frac{1}{2} \cdot u1\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(\frac{1}{2} \cdot u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        3. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. *-lowering-*.f3289.6%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. Simplified89.6%

        \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot 0.5\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
      6. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(u1 \cdot \frac{1}{2} + 1\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        2. distribute-rgt-inN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\left(u1 \cdot \frac{1}{2}\right) \cdot u1 + 1 \cdot u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        3. *-lft-identityN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\left(u1 \cdot \frac{1}{2}\right) \cdot u1 + u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        4. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\left(\left(u1 \cdot \frac{1}{2}\right) \cdot u1\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        5. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\left(u1 \cdot \left(u1 \cdot \frac{1}{2}\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        6. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(u1, \left(u1 \cdot \frac{1}{2}\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        7. *-lowering-*.f3289.7%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right), u1\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      7. Applied egg-rr89.7%

        \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(u1 \cdot 0.5\right) + u1}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification94.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.0005000000237487257:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{u1 + u1 \cdot \left(u1 \cdot 0.5\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 11: 93.7% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.0005000000237487257:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)}\\ \end{array} \end{array} \]
    (FPCore (cosTheta_i u1 u2)
     :precision binary32
     (let* ((t_0 (* u2 (* 2.0 PI))))
       (if (<= t_0 0.0005000000237487257)
         (* (sqrt (- (log1p (- u1)))) (* 2.0 (* PI u2)))
         (* (sin t_0) (sqrt (* u1 (+ 1.0 (* u1 0.5))))))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = u2 * (2.0f * ((float) M_PI));
    	float tmp;
    	if (t_0 <= 0.0005000000237487257f) {
    		tmp = sqrtf(-log1pf(-u1)) * (2.0f * (((float) M_PI) * u2));
    	} else {
    		tmp = sinf(t_0) * sqrtf((u1 * (1.0f + (u1 * 0.5f))));
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.0005000000237487257))
    		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(Float32(2.0) * Float32(Float32(pi) * u2)));
    	else
    		tmp = Float32(sin(t_0) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(0.5))))));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.0005000000237487257:\\
    \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin t\_0 \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 5.00000024e-4

      1. Initial program 58.8%

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

          \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        2. sqrt-lowering-sqrt.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
        3. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        5. log1p-defineN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        6. log1p-lowering-log1p.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        7. neg-lowering-neg.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
        8. sin-lowering-sin.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
        9. associate-*l*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        10. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
        12. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
      3. Simplified98.4%

        \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
      4. Add Preprocessing
      5. Taylor expanded in u2 around 0

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      6. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
        2. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
        3. PI-lowering-PI.f3298.4%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
      7. Simplified98.4%

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]

      if 5.00000024e-4 < (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2)

      1. Initial program 59.5%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \frac{1}{2} \cdot u1\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(\frac{1}{2} \cdot u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        3. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. *-lowering-*.f3289.6%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. Simplified89.6%

        \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot 0.5\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification94.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.0005000000237487257:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 12: 90.3% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.15000000596046448:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot {\left(u1 \cdot u1\right)}^{0.25}\\ \end{array} \end{array} \]
    (FPCore (cosTheta_i u1 u2)
     :precision binary32
     (let* ((t_0 (* u2 (* 2.0 PI))))
       (if (<= t_0 0.15000000596046448)
         (*
          (sqrt
           (* u1 (+ 1.0 (* u1 (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25))))))))
          (*
           u2
           (+ (* 2.0 PI) (* (* -1.3333333333333333 (* u2 u2)) (* PI (* PI PI))))))
         (* (sin t_0) (pow (* u1 u1) 0.25)))))
    float code(float cosTheta_i, float u1, float u2) {
    	float t_0 = u2 * (2.0f * ((float) M_PI));
    	float tmp;
    	if (t_0 <= 0.15000000596046448f) {
    		tmp = sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f)))))))) * (u2 * ((2.0f * ((float) M_PI)) + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * (((float) M_PI) * ((float) M_PI))))));
    	} else {
    		tmp = sinf(t_0) * powf((u1 * u1), 0.25f);
    	}
    	return tmp;
    }
    
    function code(cosTheta_i, u1, u2)
    	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.15000000596046448))
    		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25))))))))) * Float32(u2 * Float32(Float32(Float32(2.0) * Float32(pi)) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi)))))));
    	else
    		tmp = Float32(sin(t_0) * (Float32(u1 * u1) ^ Float32(0.25)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(cosTheta_i, u1, u2)
    	t_0 = u2 * (single(2.0) * single(pi));
    	tmp = single(0.0);
    	if (t_0 <= single(0.15000000596046448))
    		tmp = sqrt((u1 * (single(1.0) + (u1 * (single(0.5) + (u1 * (single(0.3333333333333333) + (u1 * single(0.25))))))))) * (u2 * ((single(2.0) * single(pi)) + ((single(-1.3333333333333333) * (u2 * u2)) * (single(pi) * (single(pi) * single(pi))))));
    	else
    		tmp = sin(t_0) * ((u1 * u1) ^ single(0.25));
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.15000000596046448:\\
    \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin t\_0 \cdot {\left(u1 \cdot u1\right)}^{0.25}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.150000006

      1. Initial program 60.0%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        6. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        7. *-commutativeN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        8. *-lowering-*.f3293.7%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      5. Simplified93.7%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      7. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right), \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
        3. associate-*r*N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{3}\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        4. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        5. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left({u2}^{2}\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        6. unpow2N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left(u2 \cdot u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        7. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        8. cube-multN/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        9. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        10. PI-lowering-PI.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        11. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        12. PI-lowering-PI.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        13. PI-lowering-PI.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        14. *-lowering-*.f32N/A

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
        15. PI-lowering-PI.f3293.3%

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
      8. Simplified93.3%

        \[\leadsto \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \color{blue}{\left(u2 \cdot \left(\left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right) + 2 \cdot \pi\right)\right)} \]

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

      1. Initial program 55.2%

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{u1}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
      4. Step-by-step derivation
        1. Simplified78.7%

          \[\leadsto \sqrt{\color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
        2. Step-by-step derivation
          1. pow1/2N/A

            \[\leadsto \mathsf{*.f32}\left(\left({u1}^{\frac{1}{2}}\right), \mathsf{sin.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)}\right)\right) \]
          2. metadata-evalN/A

            \[\leadsto \mathsf{*.f32}\left(\left({u1}^{\left(\frac{1}{4} + \frac{1}{4}\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), \color{blue}{u2}\right)\right)\right) \]
          3. pow-prod-upN/A

            \[\leadsto \mathsf{*.f32}\left(\left({u1}^{\frac{1}{4}} \cdot {u1}^{\frac{1}{4}}\right), \mathsf{sin.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)}\right)\right) \]
          4. pow-prod-downN/A

            \[\leadsto \mathsf{*.f32}\left(\left({\left(u1 \cdot u1\right)}^{\frac{1}{4}}\right), \mathsf{sin.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)}\right)\right) \]
          5. pow-lowering-pow.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\left(u1 \cdot u1\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)}\right)\right) \]
          6. *-lowering-*.f3278.8%

            \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(u1, u1\right), \frac{1}{4}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
        3. Applied egg-rr78.8%

          \[\leadsto \color{blue}{{\left(u1 \cdot u1\right)}^{0.25}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
      5. Recombined 2 regimes into one program.
      6. Final simplification90.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.15000000596046448:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot {\left(u1 \cdot u1\right)}^{0.25}\\ \end{array} \]
      7. Add Preprocessing

      Alternative 13: 90.3% accurate, 1.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.15000000596046448:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t\_0 \cdot \sqrt{u1}\\ \end{array} \end{array} \]
      (FPCore (cosTheta_i u1 u2)
       :precision binary32
       (let* ((t_0 (* u2 (* 2.0 PI))))
         (if (<= t_0 0.15000000596046448)
           (*
            (sqrt
             (* u1 (+ 1.0 (* u1 (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25))))))))
            (*
             u2
             (+ (* 2.0 PI) (* (* -1.3333333333333333 (* u2 u2)) (* PI (* PI PI))))))
           (* (sin t_0) (sqrt u1)))))
      float code(float cosTheta_i, float u1, float u2) {
      	float t_0 = u2 * (2.0f * ((float) M_PI));
      	float tmp;
      	if (t_0 <= 0.15000000596046448f) {
      		tmp = sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f)))))))) * (u2 * ((2.0f * ((float) M_PI)) + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * (((float) M_PI) * ((float) M_PI))))));
      	} else {
      		tmp = sinf(t_0) * sqrtf(u1);
      	}
      	return tmp;
      }
      
      function code(cosTheta_i, u1, u2)
      	t_0 = Float32(u2 * Float32(Float32(2.0) * Float32(pi)))
      	tmp = Float32(0.0)
      	if (t_0 <= Float32(0.15000000596046448))
      		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25))))))))) * Float32(u2 * Float32(Float32(Float32(2.0) * Float32(pi)) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi)))))));
      	else
      		tmp = Float32(sin(t_0) * sqrt(u1));
      	end
      	return tmp
      end
      
      function tmp_2 = code(cosTheta_i, u1, u2)
      	t_0 = u2 * (single(2.0) * single(pi));
      	tmp = single(0.0);
      	if (t_0 <= single(0.15000000596046448))
      		tmp = sqrt((u1 * (single(1.0) + (u1 * (single(0.5) + (u1 * (single(0.3333333333333333) + (u1 * single(0.25))))))))) * (u2 * ((single(2.0) * single(pi)) + ((single(-1.3333333333333333) * (u2 * u2)) * (single(pi) * (single(pi) * single(pi))))));
      	else
      		tmp = sin(t_0) * sqrt(u1);
      	end
      	tmp_2 = tmp;
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := u2 \cdot \left(2 \cdot \pi\right)\\
      \mathbf{if}\;t\_0 \leq 0.15000000596046448:\\
      \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\sin t\_0 \cdot \sqrt{u1}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.150000006

        1. Initial program 60.0%

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

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. Step-by-step derivation
          1. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
          2. +-lowering-+.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
          3. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          4. +-lowering-+.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          5. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          6. +-lowering-+.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          7. *-commutativeN/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          8. *-lowering-*.f3293.7%

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        5. Simplified93.7%

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

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
        7. Step-by-step derivation
          1. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
          2. +-lowering-+.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right), \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
          3. associate-*r*N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{3}\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          4. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          5. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left({u2}^{2}\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          6. unpow2N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left(u2 \cdot u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          7. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          8. cube-multN/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          9. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          10. PI-lowering-PI.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          11. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          12. PI-lowering-PI.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          13. PI-lowering-PI.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          14. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
          15. PI-lowering-PI.f3293.3%

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
        8. Simplified93.3%

          \[\leadsto \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \color{blue}{\left(u2 \cdot \left(\left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right) + 2 \cdot \pi\right)\right)} \]

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

        1. Initial program 55.2%

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

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{u1}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. Step-by-step derivation
          1. Simplified78.7%

            \[\leadsto \sqrt{\color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
        5. Recombined 2 regimes into one program.
        6. Final simplification90.5%

          \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.15000000596046448:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{u1}\\ \end{array} \]
        7. Add Preprocessing

        Alternative 14: 85.0% accurate, 2.3× speedup?

        \[\begin{array}{l} \\ \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \end{array} \]
        (FPCore (cosTheta_i u1 u2)
         :precision binary32
         (*
          (sqrt
           (* u1 (+ 1.0 (* u1 (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25))))))))
          (*
           u2
           (+ (* 2.0 PI) (* (* -1.3333333333333333 (* u2 u2)) (* PI (* PI PI)))))))
        float code(float cosTheta_i, float u1, float u2) {
        	return sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f)))))))) * (u2 * ((2.0f * ((float) M_PI)) + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * (((float) M_PI) * ((float) M_PI))))));
        }
        
        function code(cosTheta_i, u1, u2)
        	return Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25))))))))) * Float32(u2 * Float32(Float32(Float32(2.0) * Float32(pi)) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi)))))))
        end
        
        function tmp = code(cosTheta_i, u1, u2)
        	tmp = sqrt((u1 * (single(1.0) + (u1 * (single(0.5) + (u1 * (single(0.3333333333333333) + (u1 * single(0.25))))))))) * (u2 * ((single(2.0) * single(pi)) + ((single(-1.3333333333333333) * (u2 * u2)) * (single(pi) * (single(pi) * single(pi))))));
        end
        
        \begin{array}{l}
        
        \\
        \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)
        \end{array}
        
        Derivation
        1. Initial program 59.1%

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

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        4. Step-by-step derivation
          1. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
          2. +-lowering-+.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
          3. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          4. +-lowering-+.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          5. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          6. +-lowering-+.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          7. *-commutativeN/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          8. *-lowering-*.f3294.0%

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
        5. Simplified94.0%

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

          \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
        7. Step-by-step derivation
          1. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
          2. +-lowering-+.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right), \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
          3. associate-*r*N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{3}\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          4. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          5. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left({u2}^{2}\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          6. unpow2N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left(u2 \cdot u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          7. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          8. cube-multN/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          9. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          10. PI-lowering-PI.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          11. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          12. PI-lowering-PI.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          13. PI-lowering-PI.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
          14. *-lowering-*.f32N/A

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
          15. PI-lowering-PI.f3285.1%

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
        8. Simplified85.1%

          \[\leadsto \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \color{blue}{\left(u2 \cdot \left(\left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right) + 2 \cdot \pi\right)\right)} \]
        9. Final simplification85.1%

          \[\leadsto \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \]
        10. Add Preprocessing

        Alternative 15: 81.3% accurate, 2.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.017999999225139618:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \cdot \sqrt{u1}\\ \end{array} \end{array} \]
        (FPCore (cosTheta_i u1 u2)
         :precision binary32
         (if (<= (* u2 (* 2.0 PI)) 0.017999999225139618)
           (*
            (sqrt
             (* u1 (+ 1.0 (* u1 (+ 0.5 (* u1 (+ 0.3333333333333333 (* u1 0.25))))))))
            (* 2.0 (* PI u2)))
           (*
            (*
             u2
             (+ (* 2.0 PI) (* (* -1.3333333333333333 (* u2 u2)) (* PI (* PI PI)))))
            (sqrt u1))))
        float code(float cosTheta_i, float u1, float u2) {
        	float tmp;
        	if ((u2 * (2.0f * ((float) M_PI))) <= 0.017999999225139618f) {
        		tmp = sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * (0.3333333333333333f + (u1 * 0.25f)))))))) * (2.0f * (((float) M_PI) * u2));
        	} else {
        		tmp = (u2 * ((2.0f * ((float) M_PI)) + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * (((float) M_PI) * ((float) M_PI)))))) * sqrtf(u1);
        	}
        	return tmp;
        }
        
        function code(cosTheta_i, u1, u2)
        	tmp = Float32(0.0)
        	if (Float32(u2 * Float32(Float32(2.0) * Float32(pi))) <= Float32(0.017999999225139618))
        		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(Float32(0.3333333333333333) + Float32(u1 * Float32(0.25))))))))) * Float32(Float32(2.0) * Float32(Float32(pi) * u2)));
        	else
        		tmp = Float32(Float32(u2 * Float32(Float32(Float32(2.0) * Float32(pi)) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi)))))) * sqrt(u1));
        	end
        	return tmp
        end
        
        function tmp_2 = code(cosTheta_i, u1, u2)
        	tmp = single(0.0);
        	if ((u2 * (single(2.0) * single(pi))) <= single(0.017999999225139618))
        		tmp = sqrt((u1 * (single(1.0) + (u1 * (single(0.5) + (u1 * (single(0.3333333333333333) + (u1 * single(0.25))))))))) * (single(2.0) * (single(pi) * u2));
        	else
        		tmp = (u2 * ((single(2.0) * single(pi)) + ((single(-1.3333333333333333) * (u2 * u2)) * (single(pi) * (single(pi) * single(pi)))))) * sqrt(u1);
        	end
        	tmp_2 = tmp;
        end
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.017999999225139618:\\
        \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \cdot \sqrt{u1}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.0179999992

          1. Initial program 58.6%

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

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          4. Step-by-step derivation
            1. *-lowering-*.f32N/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
            2. +-lowering-+.f32N/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
            3. *-lowering-*.f32N/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            4. +-lowering-+.f32N/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            5. *-lowering-*.f32N/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            6. +-lowering-+.f32N/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(\frac{1}{4} \cdot u1\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            7. *-commutativeN/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \left(u1 \cdot \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            8. *-lowering-*.f3293.6%

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          5. Simplified93.6%

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

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
          7. Step-by-step derivation
            1. *-lowering-*.f32N/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
            2. *-lowering-*.f32N/A

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
            3. PI-lowering-PI.f3291.6%

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{3}, \mathsf{*.f32}\left(u1, \frac{1}{4}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
          8. Simplified91.6%

            \[\leadsto \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]

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

          1. Initial program 60.2%

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

            \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{u1}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
          4. Step-by-step derivation
            1. Simplified76.3%

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

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
            3. Step-by-step derivation
              1. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
              2. +-lowering-+.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right), \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
              3. associate-*r*N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{3}\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              4. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              5. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left({u2}^{2}\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              6. unpow2N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left(u2 \cdot u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              7. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              8. cube-multN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              9. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              10. PI-lowering-PI.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              11. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              12. PI-lowering-PI.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              13. PI-lowering-PI.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              14. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
              15. PI-lowering-PI.f3256.1%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
            4. Simplified56.1%

              \[\leadsto \sqrt{u1} \cdot \color{blue}{\left(u2 \cdot \left(\left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right) + 2 \cdot \pi\right)\right)} \]
          5. Recombined 2 regimes into one program.
          6. Final simplification81.0%

            \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.017999999225139618:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot \left(0.3333333333333333 + u1 \cdot 0.25\right)\right)\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \cdot \sqrt{u1}\\ \end{array} \]
          7. Add Preprocessing

          Alternative 16: 80.2% accurate, 2.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.009999999776482582:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \cdot \sqrt{u1}\\ \end{array} \end{array} \]
          (FPCore (cosTheta_i u1 u2)
           :precision binary32
           (if (<= (* u2 (* 2.0 PI)) 0.009999999776482582)
             (*
              (sqrt (* u1 (+ 1.0 (* u1 (+ 0.5 (* u1 0.3333333333333333))))))
              (* 2.0 (* PI u2)))
             (*
              (*
               u2
               (+ (* 2.0 PI) (* (* -1.3333333333333333 (* u2 u2)) (* PI (* PI PI)))))
              (sqrt u1))))
          float code(float cosTheta_i, float u1, float u2) {
          	float tmp;
          	if ((u2 * (2.0f * ((float) M_PI))) <= 0.009999999776482582f) {
          		tmp = sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * 0.3333333333333333f)))))) * (2.0f * (((float) M_PI) * u2));
          	} else {
          		tmp = (u2 * ((2.0f * ((float) M_PI)) + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * (((float) M_PI) * ((float) M_PI)))))) * sqrtf(u1);
          	}
          	return tmp;
          }
          
          function code(cosTheta_i, u1, u2)
          	tmp = Float32(0.0)
          	if (Float32(u2 * Float32(Float32(2.0) * Float32(pi))) <= Float32(0.009999999776482582))
          		tmp = Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(0.3333333333333333))))))) * Float32(Float32(2.0) * Float32(Float32(pi) * u2)));
          	else
          		tmp = Float32(Float32(u2 * Float32(Float32(Float32(2.0) * Float32(pi)) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi)))))) * sqrt(u1));
          	end
          	return tmp
          end
          
          function tmp_2 = code(cosTheta_i, u1, u2)
          	tmp = single(0.0);
          	if ((u2 * (single(2.0) * single(pi))) <= single(0.009999999776482582))
          		tmp = sqrt((u1 * (single(1.0) + (u1 * (single(0.5) + (u1 * single(0.3333333333333333))))))) * (single(2.0) * (single(pi) * u2));
          	else
          		tmp = (u2 * ((single(2.0) * single(pi)) + ((single(-1.3333333333333333) * (u2 * u2)) * (single(pi) * (single(pi) * single(pi)))))) * sqrt(u1);
          	end
          	tmp_2 = tmp;
          end
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.009999999776482582:\\
          \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \cdot \sqrt{u1}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2) < 0.00999999978

            1. Initial program 58.5%

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

                \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
              2. sqrt-lowering-sqrt.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
              3. neg-lowering-neg.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
              4. sub-negN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
              5. log1p-defineN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
              6. log1p-lowering-log1p.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
              7. neg-lowering-neg.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
              8. sin-lowering-sin.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
              9. associate-*l*N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
              10. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
              11. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
              12. PI-lowering-PI.f3298.4%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
            3. Simplified98.4%

              \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
            4. Add Preprocessing
            5. Taylor expanded in u2 around 0

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
            6. Step-by-step derivation
              1. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
              2. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
              3. PI-lowering-PI.f3296.4%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
            7. Simplified96.4%

              \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]
            8. Taylor expanded in u1 around 0

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)}\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
            9. Step-by-step derivation
              1. distribute-lft-inN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(1 + \left(u1 \cdot \frac{1}{2} + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              2. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(1 + \left(\frac{1}{2} \cdot u1 + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              3. associate-+r+N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              4. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + u1 \cdot \left(u1 \cdot \frac{1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              5. associate-*r*N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + \left(u1 \cdot u1\right) \cdot \frac{1}{3}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              6. unpow2N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + {u1}^{2} \cdot \frac{1}{3}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              7. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + \frac{1}{3} \cdot {u1}^{2}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              8. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + \frac{1}{3} \cdot {u1}^{2}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              9. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + {u1}^{2} \cdot \frac{1}{3}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              10. unpow2N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + \left(u1 \cdot u1\right) \cdot \frac{1}{3}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              11. associate-*r*N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + u1 \cdot \left(u1 \cdot \frac{1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              12. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              13. associate-+r+N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \left(\frac{1}{2} \cdot u1 + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              14. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \left(u1 \cdot \frac{1}{2} + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              15. distribute-lft-inN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              16. +-lowering-+.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              17. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              18. +-lowering-+.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              19. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \frac{1}{3}\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              20. *-lowering-*.f3290.6%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \frac{1}{3}\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
            10. Simplified90.6%

              \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}} \cdot \left(2 \cdot \left(u2 \cdot \pi\right)\right) \]

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

            1. Initial program 60.5%

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

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{u1}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            4. Step-by-step derivation
              1. Simplified76.0%

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

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
              3. Step-by-step derivation
                1. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
                2. +-lowering-+.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right), \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
                3. associate-*r*N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{3}\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                4. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                5. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left({u2}^{2}\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                6. unpow2N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left(u2 \cdot u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                7. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                8. cube-multN/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                9. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                10. PI-lowering-PI.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                11. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                12. PI-lowering-PI.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                13. PI-lowering-PI.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                14. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
                15. PI-lowering-PI.f3257.1%

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
              4. Simplified57.1%

                \[\leadsto \sqrt{u1} \cdot \color{blue}{\left(u2 \cdot \left(\left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right) + 2 \cdot \pi\right)\right)} \]
            5. Recombined 2 regimes into one program.
            6. Final simplification80.0%

              \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.009999999776482582:\\ \;\;\;\;\sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \cdot \sqrt{u1}\\ \end{array} \]
            7. Add Preprocessing

            Alternative 17: 80.4% accurate, 2.5× speedup?

            \[\begin{array}{l} \\ \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right) \end{array} \]
            (FPCore (cosTheta_i u1 u2)
             :precision binary32
             (*
              (sqrt (* u1 (+ 1.0 (* u1 0.5))))
              (*
               u2
               (+ (* 2.0 PI) (* (* -1.3333333333333333 (* u2 u2)) (* PI (* PI PI)))))))
            float code(float cosTheta_i, float u1, float u2) {
            	return sqrtf((u1 * (1.0f + (u1 * 0.5f)))) * (u2 * ((2.0f * ((float) M_PI)) + ((-1.3333333333333333f * (u2 * u2)) * (((float) M_PI) * (((float) M_PI) * ((float) M_PI))))));
            }
            
            function code(cosTheta_i, u1, u2)
            	return Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(0.5))))) * Float32(u2 * Float32(Float32(Float32(2.0) * Float32(pi)) + Float32(Float32(Float32(-1.3333333333333333) * Float32(u2 * u2)) * Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi)))))))
            end
            
            function tmp = code(cosTheta_i, u1, u2)
            	tmp = sqrt((u1 * (single(1.0) + (u1 * single(0.5))))) * (u2 * ((single(2.0) * single(pi)) + ((single(-1.3333333333333333) * (u2 * u2)) * (single(pi) * (single(pi) * single(pi))))));
            end
            
            \begin{array}{l}
            
            \\
            \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)} \cdot \left(u2 \cdot \left(2 \cdot \pi + \left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)
            \end{array}
            
            Derivation
            1. Initial program 59.1%

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

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            4. Step-by-step derivation
              1. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \frac{1}{2} \cdot u1\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
              2. +-lowering-+.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(\frac{1}{2} \cdot u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
              3. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
              4. *-lowering-*.f3288.7%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            5. Simplified88.7%

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

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \color{blue}{\left(u2 \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
            7. Step-by-step derivation
              1. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
              2. +-lowering-+.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right), \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right)\right) \]
              3. associate-*r*N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{3}\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              4. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\left(\frac{-4}{3} \cdot {u2}^{2}\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              5. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left({u2}^{2}\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              6. unpow2N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \left(u2 \cdot u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              7. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left({\mathsf{PI}\left(\right)}^{3}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              8. cube-multN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              9. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              10. PI-lowering-PI.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              11. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              12. PI-lowering-PI.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              13. PI-lowering-PI.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
              14. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right)\right) \]
              15. PI-lowering-PI.f3280.8%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(u2, \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\frac{-4}{3}, \mathsf{*.f32}\left(u2, u2\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
            8. Simplified80.8%

              \[\leadsto \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)} \cdot \color{blue}{\left(u2 \cdot \left(\left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right) + 2 \cdot \pi\right)\right)} \]
            9. Final simplification80.8%

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

            Alternative 18: 76.8% accurate, 2.6× speedup?

            \[\begin{array}{l} \\ \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right) \end{array} \]
            (FPCore (cosTheta_i u1 u2)
             :precision binary32
             (*
              (sqrt (* u1 (+ 1.0 (* u1 (+ 0.5 (* u1 0.3333333333333333))))))
              (* 2.0 (* PI u2))))
            float code(float cosTheta_i, float u1, float u2) {
            	return sqrtf((u1 * (1.0f + (u1 * (0.5f + (u1 * 0.3333333333333333f)))))) * (2.0f * (((float) M_PI) * u2));
            }
            
            function code(cosTheta_i, u1, u2)
            	return Float32(sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(Float32(0.5) + Float32(u1 * Float32(0.3333333333333333))))))) * Float32(Float32(2.0) * Float32(Float32(pi) * u2)))
            end
            
            function tmp = code(cosTheta_i, u1, u2)
            	tmp = sqrt((u1 * (single(1.0) + (u1 * (single(0.5) + (u1 * single(0.3333333333333333))))))) * (single(2.0) * (single(pi) * u2));
            end
            
            \begin{array}{l}
            
            \\
            \sqrt{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)
            \end{array}
            
            Derivation
            1. Initial program 59.1%

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

                \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\mathsf{neg}\left(\log \left(1 - u1\right)\right)}\right), \color{blue}{\sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
              2. sqrt-lowering-sqrt.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(\mathsf{neg}\left(\log \left(1 - u1\right)\right)\right)\right), \sin \color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)}\right) \]
              3. neg-lowering-neg.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 - u1\right)\right)\right), \sin \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \]
              4. sub-negN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\log \left(1 + \left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
              5. log1p-defineN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
              6. log1p-lowering-log1p.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\left(\mathsf{neg}\left(u1\right)\right)\right)\right)\right), \sin \left(\left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
              7. neg-lowering-neg.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right) \]
              8. sin-lowering-sin.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
              9. associate-*l*N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
              10. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right) \]
              11. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right) \]
              12. PI-lowering-PI.f3298.3%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), u2\right)\right)\right)\right) \]
            3. Simplified98.3%

              \[\leadsto \color{blue}{\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
            4. Add Preprocessing
            5. Taylor expanded in u2 around 0

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
            6. Step-by-step derivation
              1. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
              2. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
              3. PI-lowering-PI.f3280.2%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{neg.f32}\left(\mathsf{log1p.f32}\left(\mathsf{neg.f32}\left(u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
            7. Simplified80.2%

              \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]
            8. Taylor expanded in u1 around 0

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)}\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
            9. Step-by-step derivation
              1. distribute-lft-inN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(1 + \left(u1 \cdot \frac{1}{2} + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              2. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(1 + \left(\frac{1}{2} \cdot u1 + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              3. associate-+r+N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              4. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + u1 \cdot \left(u1 \cdot \frac{1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              5. associate-*r*N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + \left(u1 \cdot u1\right) \cdot \frac{1}{3}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              6. unpow2N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + {u1}^{2} \cdot \frac{1}{3}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              7. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(u1 \cdot \left(\left(1 + \frac{1}{2} \cdot u1\right) + \frac{1}{3} \cdot {u1}^{2}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              8. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + \frac{1}{3} \cdot {u1}^{2}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              9. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + {u1}^{2} \cdot \frac{1}{3}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              10. unpow2N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + \left(u1 \cdot u1\right) \cdot \frac{1}{3}\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              11. associate-*r*N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + u1 \cdot \left(u1 \cdot \frac{1}{3}\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              12. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(\left(1 + \frac{1}{2} \cdot u1\right) + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              13. associate-+r+N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \left(\frac{1}{2} \cdot u1 + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              14. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \left(u1 \cdot \frac{1}{2} + u1 \cdot \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              15. distribute-lft-inN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              16. +-lowering-+.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              17. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              18. +-lowering-+.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(\frac{1}{3} \cdot u1\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              19. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \left(u1 \cdot \frac{1}{3}\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
              20. *-lowering-*.f3276.1%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(\frac{1}{2}, \mathsf{*.f32}\left(u1, \frac{1}{3}\right)\right)\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
            10. Simplified76.1%

              \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)\right)}} \cdot \left(2 \cdot \left(u2 \cdot \pi\right)\right) \]
            11. Final simplification76.1%

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

            Alternative 19: 74.3% accurate, 2.7× speedup?

            \[\begin{array}{l} \\ \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)} \end{array} \]
            (FPCore (cosTheta_i u1 u2)
             :precision binary32
             (* (* 2.0 (* PI u2)) (sqrt (* u1 (+ 1.0 (* u1 0.5))))))
            float code(float cosTheta_i, float u1, float u2) {
            	return (2.0f * (((float) M_PI) * u2)) * sqrtf((u1 * (1.0f + (u1 * 0.5f))));
            }
            
            function code(cosTheta_i, u1, u2)
            	return Float32(Float32(Float32(2.0) * Float32(Float32(pi) * u2)) * sqrt(Float32(u1 * Float32(Float32(1.0) + Float32(u1 * Float32(0.5))))))
            end
            
            function tmp = code(cosTheta_i, u1, u2)
            	tmp = (single(2.0) * (single(pi) * u2)) * sqrt((u1 * (single(1.0) + (u1 * single(0.5)))));
            end
            
            \begin{array}{l}
            
            \\
            \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)}
            \end{array}
            
            Derivation
            1. Initial program 59.1%

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

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{\left(u1 \cdot \left(1 + \frac{1}{2} \cdot u1\right)\right)}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            4. Step-by-step derivation
              1. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \left(1 + \frac{1}{2} \cdot u1\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right)}, u2\right)\right)\right) \]
              2. +-lowering-+.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(\frac{1}{2} \cdot u1\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \color{blue}{\mathsf{PI.f32}\left(\right)}\right), u2\right)\right)\right) \]
              3. *-commutativeN/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \left(u1 \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
              4. *-lowering-*.f3288.7%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            5. Simplified88.7%

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

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
            7. Step-by-step derivation
              1. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(2, \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
              2. *-lowering-*.f32N/A

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \]
              3. PI-lowering-PI.f3273.7%

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(u1, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(u1, \frac{1}{2}\right)\right)\right)\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right)\right) \]
            8. Simplified73.7%

              \[\leadsto \sqrt{u1 \cdot \left(1 + u1 \cdot 0.5\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]
            9. Final simplification73.7%

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

            Alternative 20: 66.6% accurate, 2.9× speedup?

            \[\begin{array}{l} \\ u2 \cdot \left(\pi \cdot \left(2 \cdot {u1}^{0.5}\right)\right) \end{array} \]
            (FPCore (cosTheta_i u1 u2)
             :precision binary32
             (* u2 (* PI (* 2.0 (pow u1 0.5)))))
            float code(float cosTheta_i, float u1, float u2) {
            	return u2 * (((float) M_PI) * (2.0f * powf(u1, 0.5f)));
            }
            
            function code(cosTheta_i, u1, u2)
            	return Float32(u2 * Float32(Float32(pi) * Float32(Float32(2.0) * (u1 ^ Float32(0.5)))))
            end
            
            function tmp = code(cosTheta_i, u1, u2)
            	tmp = u2 * (single(pi) * (single(2.0) * (u1 ^ single(0.5))));
            end
            
            \begin{array}{l}
            
            \\
            u2 \cdot \left(\pi \cdot \left(2 \cdot {u1}^{0.5}\right)\right)
            \end{array}
            
            Derivation
            1. Initial program 59.1%

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

              \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{u1}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
            4. Step-by-step derivation
              1. Simplified76.4%

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

                \[\leadsto \color{blue}{2 \cdot \left(\sqrt{u1} \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
              3. Step-by-step derivation
                1. associate-*r*N/A

                  \[\leadsto \left(2 \cdot \sqrt{u1}\right) \cdot \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)} \]
                2. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\left(2 \cdot \sqrt{u1}\right), \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \]
                3. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \left(\sqrt{u1}\right)\right), \left(\color{blue}{u2} \cdot \mathsf{PI}\left(\right)\right)\right) \]
                4. sqrt-lowering-sqrt.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{sqrt.f32}\left(u1\right)\right), \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
                5. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{sqrt.f32}\left(u1\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
                6. PI-lowering-PI.f3265.9%

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{sqrt.f32}\left(u1\right)\right), \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right) \]
              4. Simplified65.9%

                \[\leadsto \color{blue}{\left(2 \cdot \sqrt{u1}\right) \cdot \left(u2 \cdot \pi\right)} \]
              5. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \left(2 \cdot \sqrt{u1}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{u2}\right) \]
                2. associate-*r*N/A

                  \[\leadsto \left(\left(2 \cdot \sqrt{u1}\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{u2} \]
                3. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\left(\left(2 \cdot \sqrt{u1}\right) \cdot \mathsf{PI}\left(\right)\right), \color{blue}{u2}\right) \]
                4. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\left(2 \cdot \sqrt{u1}\right), \mathsf{PI}\left(\right)\right), u2\right) \]
                5. *-lowering-*.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \left(\sqrt{u1}\right)\right), \mathsf{PI}\left(\right)\right), u2\right) \]
                6. pow1/2N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \left({u1}^{\frac{1}{2}}\right)\right), \mathsf{PI}\left(\right)\right), u2\right) \]
                7. pow-lowering-pow.f32N/A

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{pow.f32}\left(u1, \frac{1}{2}\right)\right), \mathsf{PI}\left(\right)\right), u2\right) \]
                8. PI-lowering-PI.f3266.0%

                  \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{pow.f32}\left(u1, \frac{1}{2}\right)\right), \mathsf{PI.f32}\left(\right)\right), u2\right) \]
              6. Applied egg-rr66.0%

                \[\leadsto \color{blue}{\left(\left(2 \cdot {u1}^{0.5}\right) \cdot \pi\right) \cdot u2} \]
              7. Final simplification66.0%

                \[\leadsto u2 \cdot \left(\pi \cdot \left(2 \cdot {u1}^{0.5}\right)\right) \]
              8. Add Preprocessing

              Alternative 21: 66.6% accurate, 2.9× speedup?

              \[\begin{array}{l} \\ 2 \cdot \left(\pi \cdot \left(u2 \cdot \sqrt{u1}\right)\right) \end{array} \]
              (FPCore (cosTheta_i u1 u2) :precision binary32 (* 2.0 (* PI (* u2 (sqrt u1)))))
              float code(float cosTheta_i, float u1, float u2) {
              	return 2.0f * (((float) M_PI) * (u2 * sqrtf(u1)));
              }
              
              function code(cosTheta_i, u1, u2)
              	return Float32(Float32(2.0) * Float32(Float32(pi) * Float32(u2 * sqrt(u1))))
              end
              
              function tmp = code(cosTheta_i, u1, u2)
              	tmp = single(2.0) * (single(pi) * (u2 * sqrt(u1)));
              end
              
              \begin{array}{l}
              
              \\
              2 \cdot \left(\pi \cdot \left(u2 \cdot \sqrt{u1}\right)\right)
              \end{array}
              
              Derivation
              1. Initial program 59.1%

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

                \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\color{blue}{u1}\right), \mathsf{sin.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{PI.f32}\left(\right)\right), u2\right)\right)\right) \]
              4. Step-by-step derivation
                1. Simplified76.4%

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

                  \[\leadsto \color{blue}{2 \cdot \left(\sqrt{u1} \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                3. Step-by-step derivation
                  1. associate-*r*N/A

                    \[\leadsto \left(2 \cdot \sqrt{u1}\right) \cdot \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)} \]
                  2. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{*.f32}\left(\left(2 \cdot \sqrt{u1}\right), \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \]
                  3. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \left(\sqrt{u1}\right)\right), \left(\color{blue}{u2} \cdot \mathsf{PI}\left(\right)\right)\right) \]
                  4. sqrt-lowering-sqrt.f32N/A

                    \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{sqrt.f32}\left(u1\right)\right), \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
                  5. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{sqrt.f32}\left(u1\right)\right), \mathsf{*.f32}\left(u2, \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
                  6. PI-lowering-PI.f3265.9%

                    \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(2, \mathsf{sqrt.f32}\left(u1\right)\right), \mathsf{*.f32}\left(u2, \mathsf{PI.f32}\left(\right)\right)\right) \]
                4. Simplified65.9%

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

                  \[\leadsto \color{blue}{2 \cdot \left(\sqrt{u1} \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                6. Step-by-step derivation
                  1. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{*.f32}\left(2, \color{blue}{\left(\sqrt{u1} \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
                  2. associate-*r*N/A

                    \[\leadsto \mathsf{*.f32}\left(2, \left(\left(\sqrt{u1} \cdot u2\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
                  3. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\left(\sqrt{u1} \cdot u2\right), \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \]
                  4. *-lowering-*.f32N/A

                    \[\leadsto \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\left(\sqrt{u1}\right), u2\right), \mathsf{PI}\left(\right)\right)\right) \]
                  5. sqrt-lowering-sqrt.f32N/A

                    \[\leadsto \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), u2\right), \mathsf{PI}\left(\right)\right)\right) \]
                  6. PI-lowering-PI.f3266.0%

                    \[\leadsto \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(u1\right), u2\right), \mathsf{PI.f32}\left(\right)\right)\right) \]
                7. Simplified66.0%

                  \[\leadsto \color{blue}{2 \cdot \left(\left(\sqrt{u1} \cdot u2\right) \cdot \pi\right)} \]
                8. Final simplification66.0%

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

                Reproduce

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