Beckmann Sample, near normal, slope_y

Percentage Accurate: 58.0% → 98.4%
Time: 14.1s
Alternatives: 19
Speedup: 8.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 19 alternatives:

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

Initial Program: 58.0% 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.4% accurate, 1.0× speedup?

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

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

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    3. lower-neg.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(\color{blue}{-u1}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  4. Applied egg-rr98.4%

    \[\leadsto \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Step-by-step derivation
    1. lift-PI.f32N/A

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)}\right) \]
    4. count-2N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2 + \mathsf{PI}\left(\right) \cdot u2\right)} \]
    5. lift-*.f32N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot u2 + \color{blue}{\mathsf{PI}\left(\right) \cdot u2}\right) \]
    7. distribute-lft-outN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    8. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    9. lower-+.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\pi \cdot \color{blue}{\left(u2 + u2\right)}\right) \]
  6. Applied egg-rr98.4%

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

Alternative 2: 93.3% accurate, 1.5× speedup?

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

\\
\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), u1 \cdot \left(u1 \cdot u1\right), \mathsf{fma}\left(u1 \cdot u1, 0.5, u1\right)\right)} \cdot \sin \left(u2 \cdot \left(\pi \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    13. lower-fma.f3295.3

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified95.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right) \cdot \left(u1 \cdot \color{blue}{\left(u1 \cdot u1\right)}\right) + \left(\left(u1 \cdot u1\right) \cdot \frac{1}{2} + u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    11. cube-multN/A

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

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), {u1}^{3}, \left(u1 \cdot u1\right) \cdot \frac{1}{2} + u1\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    13. cube-multN/A

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \color{blue}{u1 \cdot \left(u1 \cdot u1\right)}, \left(u1 \cdot u1\right) \cdot \frac{1}{2} + u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    16. lower-fma.f3295.3

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), u1 \cdot \left(u1 \cdot u1\right), \color{blue}{\mathsf{fma}\left(u1 \cdot u1, 0.5, u1\right)}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  7. Applied egg-rr95.3%

    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), u1 \cdot \left(u1 \cdot u1\right), \mathsf{fma}\left(u1 \cdot u1, 0.5, u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  8. Final simplification95.3%

    \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), u1 \cdot \left(u1 \cdot u1\right), \mathsf{fma}\left(u1 \cdot u1, 0.5, u1\right)\right)} \cdot \sin \left(u2 \cdot \left(\pi \cdot 2\right)\right) \]
  9. Add Preprocessing

Alternative 3: 94.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;u2 \cdot \left(\pi \cdot 2\right) \leq 0.001500000013038516:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\pi \cdot \left(u2 + u2\right)\right) \cdot \sqrt{u1 \cdot \mathsf{fma}\left(u1, 0.5, 1\right)}\\ \end{array} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (if (<= (* u2 (* PI 2.0)) 0.001500000013038516)
   (* (sqrt (- (log1p (- u1)))) (* 2.0 (* PI u2)))
   (* (sin (* PI (+ u2 u2))) (sqrt (* u1 (fma u1 0.5 1.0))))))
float code(float cosTheta_i, float u1, float u2) {
	float tmp;
	if ((u2 * (((float) M_PI) * 2.0f)) <= 0.001500000013038516f) {
		tmp = sqrtf(-log1pf(-u1)) * (2.0f * (((float) M_PI) * u2));
	} else {
		tmp = sinf((((float) M_PI) * (u2 + u2))) * sqrtf((u1 * fmaf(u1, 0.5f, 1.0f)));
	}
	return tmp;
}
function code(cosTheta_i, u1, u2)
	tmp = Float32(0.0)
	if (Float32(u2 * Float32(Float32(pi) * Float32(2.0))) <= Float32(0.001500000013038516))
		tmp = Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(Float32(2.0) * Float32(Float32(pi) * u2)));
	else
		tmp = Float32(sin(Float32(Float32(pi) * Float32(u2 + u2))) * sqrt(Float32(u1 * fma(u1, Float32(0.5), Float32(1.0)))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;u2 \cdot \left(\pi \cdot 2\right) \leq 0.001500000013038516:\\
\;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\sin \left(\pi \cdot \left(u2 + u2\right)\right) \cdot \sqrt{u1 \cdot \mathsf{fma}\left(u1, 0.5, 1\right)}\\


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

    1. Initial program 50.1%

      \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

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

        \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      3. lower-neg.f3298.6

        \[\leadsto \sqrt{-\mathsf{log1p}\left(\color{blue}{-u1}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    4. Applied egg-rr98.6%

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

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

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

        \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \left(2 \cdot \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \]
      3. lower-PI.f3298.2

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

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

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

    1. Initial program 58.8%

      \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

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

        \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      3. lower-neg.f3297.9

        \[\leadsto \sqrt{-\mathsf{log1p}\left(\color{blue}{-u1}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    4. Applied egg-rr97.9%

      \[\leadsto \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    5. Step-by-step derivation
      1. lift-PI.f32N/A

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

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

        \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)}\right) \]
      4. count-2N/A

        \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2 + \mathsf{PI}\left(\right) \cdot u2\right)} \]
      5. lift-*.f32N/A

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

        \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot u2 + \color{blue}{\mathsf{PI}\left(\right) \cdot u2}\right) \]
      7. distribute-lft-outN/A

        \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
      8. lower-*.f32N/A

        \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
      9. lower-+.f3297.9

        \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\pi \cdot \color{blue}{\left(u2 + u2\right)}\right) \]
    6. Applied egg-rr97.9%

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \left(u1 \cdot \frac{-1}{2} + \color{blue}{-1}\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      5. lower-fma.f3288.9

        \[\leadsto \sqrt{-u1 \cdot \color{blue}{\mathsf{fma}\left(u1, -0.5, -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
    9. Simplified88.9%

      \[\leadsto \sqrt{-\color{blue}{u1 \cdot \mathsf{fma}\left(u1, -0.5, -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
    10. Step-by-step derivation
      1. lift-fma.f32N/A

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(-1\right)\right) + \left(\mathsf{neg}\left(u1 \cdot \frac{-1}{2}\right)\right)\right)} \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \sqrt{\left(\color{blue}{1} + \left(\mathsf{neg}\left(u1 \cdot \frac{-1}{2}\right)\right)\right) \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{\left(\color{blue}{-1 \cdot -1} + \left(\mathsf{neg}\left(u1 \cdot \frac{-1}{2}\right)\right)\right) \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      9. neg-mul-1N/A

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-1 \cdot -1 + \left(u1 \cdot \frac{-1}{2}\right) \cdot -1\right) \cdot u1}} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \sqrt{\left(\color{blue}{1} + \left(u1 \cdot \frac{-1}{2}\right) \cdot -1\right) \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      13. metadata-evalN/A

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

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(-1\right)\right) + \color{blue}{-1 \cdot \left(u1 \cdot \frac{-1}{2}\right)}\right) \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      15. neg-mul-1N/A

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(u1 \cdot \frac{-1}{2}\right)\right) + \left(\mathsf{neg}\left(-1\right)\right)\right)} \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      19. neg-mul-1N/A

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

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

        \[\leadsto \sqrt{\left(\color{blue}{u1 \cdot \left(\frac{-1}{2} \cdot -1\right)} + \left(\mathsf{neg}\left(-1\right)\right)\right) \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      22. metadata-evalN/A

        \[\leadsto \sqrt{\left(u1 \cdot \color{blue}{\frac{1}{2}} + \left(\mathsf{neg}\left(-1\right)\right)\right) \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      23. metadata-evalN/A

        \[\leadsto \sqrt{\left(u1 \cdot \frac{1}{2} + \color{blue}{1}\right) \cdot u1} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
      24. lower-fma.f3288.9

        \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(u1, 0.5, 1\right)} \cdot u1} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
    11. Applied egg-rr88.9%

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

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

Alternative 4: 93.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \sin \left(\pi \cdot \left(u2 + u2\right)\right) \cdot \sqrt{u1 \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), 1\right)} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (*
  (sin (* PI (+ u2 u2)))
  (sqrt (* u1 (fma u1 (fma u1 (fma u1 0.25 0.3333333333333333) 0.5) 1.0)))))
float code(float cosTheta_i, float u1, float u2) {
	return sinf((((float) M_PI) * (u2 + u2))) * sqrtf((u1 * fmaf(u1, fmaf(u1, fmaf(u1, 0.25f, 0.3333333333333333f), 0.5f), 1.0f)));
}
function code(cosTheta_i, u1, u2)
	return Float32(sin(Float32(Float32(pi) * Float32(u2 + u2))) * sqrt(Float32(u1 * fma(u1, fma(u1, fma(u1, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), Float32(1.0)))))
end
\begin{array}{l}

\\
\sin \left(\pi \cdot \left(u2 + u2\right)\right) \cdot \sqrt{u1 \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), 1\right)}
\end{array}
Derivation
  1. Initial program 53.4%

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    3. lower-neg.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(\color{blue}{-u1}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  4. Applied egg-rr98.4%

    \[\leadsto \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Step-by-step derivation
    1. lift-PI.f32N/A

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)}\right) \]
    4. count-2N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2 + \mathsf{PI}\left(\right) \cdot u2\right)} \]
    5. lift-*.f32N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot u2 + \color{blue}{\mathsf{PI}\left(\right) \cdot u2}\right) \]
    7. distribute-lft-outN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    8. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    9. lower-+.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\pi \cdot \color{blue}{\left(u2 + u2\right)}\right) \]
  6. Applied egg-rr98.4%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{u1 \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), 1\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
    8. lower-fma.f3295.3

      \[\leadsto \sqrt{u1 \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), 1\right)} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  9. Simplified95.3%

    \[\leadsto \sqrt{\color{blue}{u1 \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), 1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  10. Final simplification95.3%

    \[\leadsto \sin \left(\pi \cdot \left(u2 + u2\right)\right) \cdot \sqrt{u1 \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), 1\right)} \]
  11. Add Preprocessing

Alternative 5: 91.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \sin \left(\pi \cdot \left(u2 + u2\right)\right) \cdot \sqrt{\left(-u1\right) \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, -0.3333333333333333, -0.5\right), -1\right)} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (*
  (sin (* PI (+ u2 u2)))
  (sqrt (* (- u1) (fma u1 (fma u1 -0.3333333333333333 -0.5) -1.0)))))
float code(float cosTheta_i, float u1, float u2) {
	return sinf((((float) M_PI) * (u2 + u2))) * sqrtf((-u1 * fmaf(u1, fmaf(u1, -0.3333333333333333f, -0.5f), -1.0f)));
}
function code(cosTheta_i, u1, u2)
	return Float32(sin(Float32(Float32(pi) * Float32(u2 + u2))) * sqrt(Float32(Float32(-u1) * fma(u1, fma(u1, Float32(-0.3333333333333333), Float32(-0.5)), Float32(-1.0)))))
end
\begin{array}{l}

\\
\sin \left(\pi \cdot \left(u2 + u2\right)\right) \cdot \sqrt{\left(-u1\right) \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, -0.3333333333333333, -0.5\right), -1\right)}
\end{array}
Derivation
  1. Initial program 53.4%

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    3. lower-neg.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(\color{blue}{-u1}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  4. Applied egg-rr98.4%

    \[\leadsto \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Step-by-step derivation
    1. lift-PI.f32N/A

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)}\right) \]
    4. count-2N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2 + \mathsf{PI}\left(\right) \cdot u2\right)} \]
    5. lift-*.f32N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot u2 + \color{blue}{\mathsf{PI}\left(\right) \cdot u2}\right) \]
    7. distribute-lft-outN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    8. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    9. lower-+.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\pi \cdot \color{blue}{\left(u2 + u2\right)}\right) \]
  6. Applied egg-rr98.4%

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \color{blue}{\mathsf{fma}\left(u1, \frac{-1}{3} \cdot u1 - \frac{1}{2}, -1\right)}\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
    5. sub-negN/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{-1}{3}} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right), -1\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, u1 \cdot \frac{-1}{3} + \color{blue}{\frac{-1}{2}}, -1\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
    8. lower-fma.f3293.6

      \[\leadsto \sqrt{-u1 \cdot \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, -0.3333333333333333, -0.5\right)}, -1\right)} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  9. Simplified93.6%

    \[\leadsto \sqrt{-\color{blue}{u1 \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, -0.3333333333333333, -0.5\right), -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  10. Final simplification93.6%

    \[\leadsto \sin \left(\pi \cdot \left(u2 + u2\right)\right) \cdot \sqrt{\left(-u1\right) \cdot \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, -0.3333333333333333, -0.5\right), -1\right)} \]
  11. Add Preprocessing

Alternative 6: 90.7% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
t_0 := u2 \cdot \left(\pi \cdot 2\right)\\
\mathbf{if}\;t\_0 \leq 0.2800000011920929:\\
\;\;\;\;\frac{2 \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}}{\frac{\mathsf{fma}\left(u2 \cdot u2, \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot 0.3111111111111111, \pi \cdot 0.6666666666666666\right), \frac{1}{\pi}\right)}{u2}}\\

\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.280000001

    1. Initial program 51.9%

      \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

        \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      6. lower-fma.f32N/A

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      13. lower-fma.f3296.0

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    5. Simplified96.0%

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    6. Applied egg-rr95.9%

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

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

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot 2}{\color{blue}{\frac{{u2}^{2} \cdot \left(-1 \cdot \left({u2}^{2} \cdot \left(\frac{-4}{9} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{2}{15} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) - \frac{-2}{3} \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{\mathsf{PI}\left(\right)}}{u2}}} \]
    9. Simplified95.8%

      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot 2}{\color{blue}{\frac{\mathsf{fma}\left(u2 \cdot u2, \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot 0.3111111111111111, \pi \cdot 0.6666666666666666\right), \frac{1}{\pi}\right)}{u2}}} \]

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

    1. Initial program 60.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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

        \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      6. lower-fma.f32N/A

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      13. lower-fma.f3291.8

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    5. Simplified91.8%

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

      \[\leadsto \color{blue}{\sqrt{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    7. Step-by-step derivation
      1. lower-sqrt.f3273.5

        \[\leadsto \color{blue}{\sqrt{u1}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    8. Simplified73.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(\pi \cdot 2\right) \leq 0.2800000011920929:\\ \;\;\;\;\frac{2 \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}}{\frac{\mathsf{fma}\left(u2 \cdot u2, \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot 0.3111111111111111, \pi \cdot 0.6666666666666666\right), \frac{1}{\pi}\right)}{u2}}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(u2 \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{u1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 91.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \sin \left(u2 \cdot \left(\pi + \pi\right)\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (*
  (sqrt (fma (* u1 u1) (fma u1 0.3333333333333333 0.5) u1))
  (sin (* u2 (+ PI PI)))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(fmaf((u1 * u1), fmaf(u1, 0.3333333333333333f, 0.5f), u1)) * sinf((u2 * (((float) M_PI) + ((float) M_PI))));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(fma(Float32(u1 * u1), fma(u1, Float32(0.3333333333333333), Float32(0.5)), u1)) * sin(Float32(u2 * Float32(Float32(pi) + Float32(pi)))))
end
\begin{array}{l}

\\
\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \sin \left(u2 \cdot \left(\pi + \pi\right)\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{u1 \cdot \frac{1}{3}} + \frac{1}{2}, u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    11. lower-fma.f3293.6

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{\mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right)}, u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified93.6%

    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  6. Step-by-step derivation
    1. lift-PI.f32N/A

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \color{blue}{\left(u2 \cdot \left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)\right)} \]
    8. lower-+.f3293.6

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \sin \left(u2 \cdot \color{blue}{\left(\pi + \pi\right)}\right) \]
  7. Applied egg-rr93.6%

    \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \sin \color{blue}{\left(u2 \cdot \left(\pi + \pi\right)\right)} \]
  8. Add Preprocessing

Alternative 8: 86.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{2 \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}}{\frac{\mathsf{fma}\left(u2 \cdot u2, \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot 0.3111111111111111, \pi \cdot 0.6666666666666666\right), \frac{1}{\pi}\right)}{u2}} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (/
  (*
   2.0
   (sqrt (fma (* u1 u1) (fma u1 (fma u1 0.25 0.3333333333333333) 0.5) u1)))
  (/
   (fma
    (* u2 u2)
    (fma
     (* u2 u2)
     (* (* PI (* PI PI)) 0.3111111111111111)
     (* PI 0.6666666666666666))
    (/ 1.0 PI))
   u2)))
float code(float cosTheta_i, float u1, float u2) {
	return (2.0f * sqrtf(fmaf((u1 * u1), fmaf(u1, fmaf(u1, 0.25f, 0.3333333333333333f), 0.5f), u1))) / (fmaf((u2 * u2), fmaf((u2 * u2), ((((float) M_PI) * (((float) M_PI) * ((float) M_PI))) * 0.3111111111111111f), (((float) M_PI) * 0.6666666666666666f)), (1.0f / ((float) M_PI))) / u2);
}
function code(cosTheta_i, u1, u2)
	return Float32(Float32(Float32(2.0) * sqrt(fma(Float32(u1 * u1), fma(u1, fma(u1, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u1))) / Float32(fma(Float32(u2 * u2), fma(Float32(u2 * u2), Float32(Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi))) * Float32(0.3111111111111111)), Float32(Float32(pi) * Float32(0.6666666666666666))), Float32(Float32(1.0) / Float32(pi))) / u2))
end
\begin{array}{l}

\\
\frac{2 \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}}{\frac{\mathsf{fma}\left(u2 \cdot u2, \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot 0.3111111111111111, \pi \cdot 0.6666666666666666\right), \frac{1}{\pi}\right)}{u2}}
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    13. lower-fma.f3295.3

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified95.3%

    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  6. Applied egg-rr95.2%

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

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

      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot 2}{\color{blue}{\frac{{u2}^{2} \cdot \left(-1 \cdot \left({u2}^{2} \cdot \left(\frac{-4}{9} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{2}{15} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) - \frac{-2}{3} \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{\mathsf{PI}\left(\right)}}{u2}}} \]
  9. Simplified86.8%

    \[\leadsto \frac{\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot 2}{\color{blue}{\frac{\mathsf{fma}\left(u2 \cdot u2, \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot 0.3111111111111111, \pi \cdot 0.6666666666666666\right), \frac{1}{\pi}\right)}{u2}}} \]
  10. Final simplification86.8%

    \[\leadsto \frac{2 \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}}{\frac{\mathsf{fma}\left(u2 \cdot u2, \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot 0.3111111111111111, \pi \cdot 0.6666666666666666\right), \frac{1}{\pi}\right)}{u2}} \]
  11. Add Preprocessing

Alternative 9: 85.1% accurate, 3.1× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), \pi \cdot 2\right)\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (*
  (sqrt (fma (* u1 u1) (fma u1 (fma u1 0.25 0.3333333333333333) 0.5) u1))
  (* u2 (fma -1.3333333333333333 (* (* u2 u2) (* PI (* PI PI))) (* PI 2.0)))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(fmaf((u1 * u1), fmaf(u1, fmaf(u1, 0.25f, 0.3333333333333333f), 0.5f), u1)) * (u2 * fmaf(-1.3333333333333333f, ((u2 * u2) * (((float) M_PI) * (((float) M_PI) * ((float) M_PI)))), (((float) M_PI) * 2.0f)));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(fma(Float32(u1 * u1), fma(u1, fma(u1, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u1)) * Float32(u2 * fma(Float32(-1.3333333333333333), Float32(Float32(u2 * u2) * Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi)))), Float32(Float32(pi) * Float32(2.0)))))
end
\begin{array}{l}

\\
\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), \pi \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    13. lower-fma.f3295.3

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified95.3%

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

    \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \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)} \]
  7. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \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)} \]
    2. lower-fma.f32N/A

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{\left(u2 \cdot u2\right)} \cdot {\mathsf{PI}\left(\right)}^{3}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    6. cube-multN/A

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3}, \left(u2 \cdot u2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{2 \cdot \mathsf{PI}\left(\right)}\right)\right) \]
    13. lower-PI.f3286.0

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \color{blue}{\pi}\right)\right) \]
  8. Simplified86.0%

    \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \color{blue}{\left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \pi\right)\right)} \]
  9. Final simplification86.0%

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

Alternative 10: 85.2% accurate, 3.1× speedup?

\[\begin{array}{l} \\ u2 \cdot \left(\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \left(2 \cdot \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.6666666666666666, \pi\right)\right)\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (*
  u2
  (*
   (sqrt (fma (* u1 u1) (fma u1 (fma u1 0.25 0.3333333333333333) 0.5) u1))
   (* 2.0 (fma (* u2 u2) (* (* PI (* PI PI)) -0.6666666666666666) PI)))))
float code(float cosTheta_i, float u1, float u2) {
	return u2 * (sqrtf(fmaf((u1 * u1), fmaf(u1, fmaf(u1, 0.25f, 0.3333333333333333f), 0.5f), u1)) * (2.0f * fmaf((u2 * u2), ((((float) M_PI) * (((float) M_PI) * ((float) M_PI))) * -0.6666666666666666f), ((float) M_PI))));
}
function code(cosTheta_i, u1, u2)
	return Float32(u2 * Float32(sqrt(fma(Float32(u1 * u1), fma(u1, fma(u1, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u1)) * Float32(Float32(2.0) * fma(Float32(u2 * u2), Float32(Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi))) * Float32(-0.6666666666666666)), Float32(pi)))))
end
\begin{array}{l}

\\
u2 \cdot \left(\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \left(2 \cdot \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.6666666666666666, \pi\right)\right)\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    13. lower-fma.f3295.3

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified95.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \color{blue}{\left(2 \cdot \left(\sin \left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)} \]
    10. lift-sin.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \left(2 \cdot \left(\color{blue}{\sin \left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right) \]
    11. lift-cos.f32N/A

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

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

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \sin \left(\pi \cdot u2\right)\right) \cdot \left(2 \cdot \cos \left(\pi \cdot u2\right)\right)} \]
  8. Taylor expanded in u2 around 0

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

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

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

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

      \[\leadsto u2 \cdot \left(\left(2 \cdot \left({u2}^{2} \cdot \left(\frac{-1}{2} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{-1}{6} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right) \cdot \sqrt{u1 + {u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)} + \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{u1 + {u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)}}\right) \]
  10. Simplified86.0%

    \[\leadsto \color{blue}{u2 \cdot \left(\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \left(2 \cdot \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.6666666666666666, \pi\right)\right)\right)} \]
  11. Add Preprocessing

Alternative 11: 83.6% accurate, 3.3× speedup?

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

\\
\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), \pi \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{u1 \cdot \frac{1}{3}} + \frac{1}{2}, u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    11. lower-fma.f3293.6

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{\mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right)}, u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified93.6%

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

    \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \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)} \]
  7. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \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)} \]
    2. lower-fma.f32N/A

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{\left(u2 \cdot u2\right)} \cdot {\mathsf{PI}\left(\right)}^{3}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    6. cube-multN/A

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3}, \left(u2 \cdot u2\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    7. unpow2N/A

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3}, \left(u2 \cdot u2\right) \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot {\mathsf{PI}\left(\right)}^{2}\right), 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    10. unpow2N/A

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3}, \left(u2 \cdot u2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{2 \cdot \mathsf{PI}\left(\right)}\right)\right) \]
    15. lower-PI.f3284.8

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \color{blue}{\pi}\right)\right) \]
  8. Simplified84.8%

    \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \color{blue}{\left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \pi\right)\right)} \]
  9. Final simplification84.8%

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

Alternative 12: 83.6% accurate, 3.3× speedup?

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

\\
u2 \cdot \left(\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), \pi \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{u1 \cdot \frac{1}{3}} + \frac{1}{2}, u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    11. lower-fma.f3293.6

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{\mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right)}, u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified93.6%

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

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

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

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

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

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

      \[\leadsto u2 \cdot \color{blue}{\left(\sqrt{u1 + {u1}^{2} \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)} \cdot \left(\frac{-4}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
  8. Simplified84.7%

    \[\leadsto \color{blue}{u2 \cdot \left(\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, \left(u2 \cdot u2\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \pi\right)\right)} \]
  9. Final simplification84.7%

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

Alternative 13: 81.6% accurate, 3.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;u2 \cdot \left(\pi \cdot 2\right) \leq 0.005400000140070915:\\ \;\;\;\;\left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}\\ \mathbf{else}:\\ \;\;\;\;u2 \cdot \left(\mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.6666666666666666, \pi\right) \cdot \left(2 \cdot \sqrt{u1}\right)\right)\\ \end{array} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (if (<= (* u2 (* PI 2.0)) 0.005400000140070915)
   (*
    (* 2.0 (* PI u2))
    (sqrt (fma (* u1 u1) (fma u1 (fma u1 0.25 0.3333333333333333) 0.5) u1)))
   (*
    u2
    (*
     (fma (* u2 u2) (* (* PI (* PI PI)) -0.6666666666666666) PI)
     (* 2.0 (sqrt u1))))))
float code(float cosTheta_i, float u1, float u2) {
	float tmp;
	if ((u2 * (((float) M_PI) * 2.0f)) <= 0.005400000140070915f) {
		tmp = (2.0f * (((float) M_PI) * u2)) * sqrtf(fmaf((u1 * u1), fmaf(u1, fmaf(u1, 0.25f, 0.3333333333333333f), 0.5f), u1));
	} else {
		tmp = u2 * (fmaf((u2 * u2), ((((float) M_PI) * (((float) M_PI) * ((float) M_PI))) * -0.6666666666666666f), ((float) M_PI)) * (2.0f * sqrtf(u1)));
	}
	return tmp;
}
function code(cosTheta_i, u1, u2)
	tmp = Float32(0.0)
	if (Float32(u2 * Float32(Float32(pi) * Float32(2.0))) <= Float32(0.005400000140070915))
		tmp = Float32(Float32(Float32(2.0) * Float32(Float32(pi) * u2)) * sqrt(fma(Float32(u1 * u1), fma(u1, fma(u1, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u1)));
	else
		tmp = Float32(u2 * Float32(fma(Float32(u2 * u2), Float32(Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi))) * Float32(-0.6666666666666666)), Float32(pi)) * Float32(Float32(2.0) * sqrt(u1))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;u2 \cdot \left(\pi \cdot 2\right) \leq 0.005400000140070915:\\
\;\;\;\;\left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}\\

\mathbf{else}:\\
\;\;\;\;u2 \cdot \left(\mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.6666666666666666, \pi\right) \cdot \left(2 \cdot \sqrt{u1}\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.00540000014

    1. Initial program 51.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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

        \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      6. lower-fma.f32N/A

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      13. lower-fma.f3296.1

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    5. Simplified96.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left({u1}^{2}, \frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right), u1\right)}} \]
      9. unpow2N/A

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

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

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

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

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

        \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \]
      15. lower-fma.f3295.1

        \[\leadsto \left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \]
    8. Simplified95.1%

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

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

    1. Initial program 57.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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

        \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      6. lower-fma.f32N/A

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
      13. lower-fma.f3293.8

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    5. Simplified93.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \color{blue}{\left(2 \cdot \left(\sin \left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)} \]
      10. lift-sin.f32N/A

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \left(2 \cdot \left(\color{blue}{\sin \left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right) \]
      11. lift-cos.f32N/A

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

        \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \left(2 \cdot \color{blue}{\left(\sin \left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)}\right) \]
    7. Applied egg-rr93.4%

      \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \sin \left(\pi \cdot u2\right)\right) \cdot \left(2 \cdot \cos \left(\pi \cdot u2\right)\right)} \]
    8. Taylor expanded in u1 around 0

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{u1} \cdot \cos \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sin \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \]
      11. lower-PI.f3277.0

        \[\leadsto 2 \cdot \left(\left(\sqrt{u1} \cdot \cos \left(u2 \cdot \pi\right)\right) \cdot \sin \left(u2 \cdot \color{blue}{\pi}\right)\right) \]
    10. Simplified77.0%

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

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

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

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

        \[\leadsto u2 \cdot \left(\left(2 \cdot \sqrt{u1}\right) \cdot \mathsf{PI}\left(\right) + \color{blue}{\left(2 \cdot \sqrt{u1}\right) \cdot \left({u2}^{2} \cdot \left(\frac{-1}{2} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{-1}{6} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)}\right) \]
      4. distribute-lft-outN/A

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

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

        \[\leadsto u2 \cdot \left(\color{blue}{\left(2 \cdot \sqrt{u1}\right)} \cdot \left(\mathsf{PI}\left(\right) + {u2}^{2} \cdot \left(\frac{-1}{2} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{-1}{6} \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right) \]
      7. lower-sqrt.f32N/A

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

        \[\leadsto u2 \cdot \left(\left(2 \cdot \sqrt{u1}\right) \cdot \color{blue}{\left({u2}^{2} \cdot \left(\frac{-1}{2} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{-1}{6} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + \mathsf{PI}\left(\right)\right)}\right) \]
      9. lower-fma.f32N/A

        \[\leadsto u2 \cdot \left(\left(2 \cdot \sqrt{u1}\right) \cdot \color{blue}{\mathsf{fma}\left({u2}^{2}, \frac{-1}{2} \cdot {\mathsf{PI}\left(\right)}^{3} + \frac{-1}{6} \cdot {\mathsf{PI}\left(\right)}^{3}, \mathsf{PI}\left(\right)\right)}\right) \]
    13. Simplified59.2%

      \[\leadsto \color{blue}{u2 \cdot \left(\left(2 \cdot \sqrt{u1}\right) \cdot \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.6666666666666666, \pi\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;u2 \cdot \left(\pi \cdot 2\right) \leq 0.005400000140070915:\\ \;\;\;\;\left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}\\ \mathbf{else}:\\ \;\;\;\;u2 \cdot \left(\mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.6666666666666666, \pi\right) \cdot \left(2 \cdot \sqrt{u1}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 80.5% accurate, 3.6× speedup?

\[\begin{array}{l} \\ \sqrt{\left(-u1\right) \cdot \mathsf{fma}\left(u1, -0.5, -1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333, \pi \cdot \left(\pi \cdot \pi\right), \pi \cdot 2\right)\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (*
  (sqrt (* (- u1) (fma u1 -0.5 -1.0)))
  (* u2 (fma (* (* u2 u2) -1.3333333333333333) (* PI (* PI PI)) (* PI 2.0)))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf((-u1 * fmaf(u1, -0.5f, -1.0f))) * (u2 * fmaf(((u2 * u2) * -1.3333333333333333f), (((float) M_PI) * (((float) M_PI) * ((float) M_PI))), (((float) M_PI) * 2.0f)));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(Float32(-u1) * fma(u1, Float32(-0.5), Float32(-1.0)))) * Float32(u2 * fma(Float32(Float32(u2 * u2) * Float32(-1.3333333333333333)), Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi))), Float32(Float32(pi) * Float32(2.0)))))
end
\begin{array}{l}

\\
\sqrt{\left(-u1\right) \cdot \mathsf{fma}\left(u1, -0.5, -1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -1.3333333333333333, \pi \cdot \left(\pi \cdot \pi\right), \pi \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    3. lower-neg.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(\color{blue}{-u1}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  4. Applied egg-rr98.4%

    \[\leadsto \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Step-by-step derivation
    1. lift-PI.f32N/A

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)}\right) \]
    4. count-2N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2 + \mathsf{PI}\left(\right) \cdot u2\right)} \]
    5. lift-*.f32N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot u2 + \color{blue}{\mathsf{PI}\left(\right) \cdot u2}\right) \]
    7. distribute-lft-outN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    8. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    9. lower-+.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\pi \cdot \color{blue}{\left(u2 + u2\right)}\right) \]
  6. Applied egg-rr98.4%

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \left(u1 \cdot \frac{-1}{2} + \color{blue}{-1}\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
    5. lower-fma.f3290.3

      \[\leadsto \sqrt{-u1 \cdot \color{blue}{\mathsf{fma}\left(u1, -0.5, -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  9. Simplified90.3%

    \[\leadsto \sqrt{-\color{blue}{u1 \cdot \mathsf{fma}\left(u1, -0.5, -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  10. Taylor expanded in u2 around 0

    \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \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)} \]
  11. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \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)} \]
    2. associate-*r*N/A

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\color{blue}{\frac{-4}{3} \cdot {u2}^{2}}, {\mathsf{PI}\left(\right)}^{3}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    5. unpow2N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3} \cdot \color{blue}{\left(u2 \cdot u2\right)}, {\mathsf{PI}\left(\right)}^{3}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    7. cube-multN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3} \cdot \left(u2 \cdot u2\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    8. unpow2N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3} \cdot \left(u2 \cdot u2\right), \color{blue}{\mathsf{PI}\left(\right) \cdot {\mathsf{PI}\left(\right)}^{2}}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    10. lower-PI.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3} \cdot \left(u2 \cdot u2\right), \color{blue}{\mathsf{PI}\left(\right)} \cdot {\mathsf{PI}\left(\right)}^{2}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    11. unpow2N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3} \cdot \left(u2 \cdot u2\right), \mathsf{PI}\left(\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    13. lower-PI.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3} \cdot \left(u2 \cdot u2\right), \mathsf{PI}\left(\right) \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right)\right), 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    14. lower-PI.f32N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(\frac{-4}{3} \cdot \left(u2 \cdot u2\right), \mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), \color{blue}{2 \cdot \mathsf{PI}\left(\right)}\right)\right) \]
    16. lower-PI.f3282.1

      \[\leadsto \sqrt{-u1 \cdot \mathsf{fma}\left(u1, -0.5, -1\right)} \cdot \left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \color{blue}{\pi}\right)\right) \]
  12. Simplified82.1%

    \[\leadsto \sqrt{-u1 \cdot \mathsf{fma}\left(u1, -0.5, -1\right)} \cdot \color{blue}{\left(u2 \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(u2 \cdot u2\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \pi\right)\right)} \]
  13. Final simplification82.1%

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

Alternative 15: 78.3% accurate, 4.7× speedup?

\[\begin{array}{l} \\ \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (*
  (* 2.0 (* PI u2))
  (sqrt (fma (* u1 u1) (fma u1 (fma u1 0.25 0.3333333333333333) 0.5) u1))))
float code(float cosTheta_i, float u1, float u2) {
	return (2.0f * (((float) M_PI) * u2)) * sqrtf(fmaf((u1 * u1), fmaf(u1, fmaf(u1, 0.25f, 0.3333333333333333f), 0.5f), u1));
}
function code(cosTheta_i, u1, u2)
	return Float32(Float32(Float32(2.0) * Float32(Float32(pi) * u2)) * sqrt(fma(Float32(u1 * u1), fma(u1, fma(u1, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u1)))
end
\begin{array}{l}

\\
\left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    13. lower-fma.f3295.3

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified95.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left({u1}^{2}, \frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right), u1\right)}} \]
    9. unpow2N/A

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

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

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

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

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

      \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \]
    15. lower-fma.f3278.4

      \[\leadsto \left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \]
  8. Simplified78.4%

    \[\leadsto \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)}} \]
  9. Final simplification78.4%

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

Alternative 16: 77.0% accurate, 5.4× speedup?

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

\\
\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)} \cdot \left(2 \cdot \left(\pi \cdot u2\right)\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{u1 \cdot \frac{1}{3}} + \frac{1}{2}, u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    11. lower-fma.f3293.6

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{\mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right)}, u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified93.6%

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

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

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

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

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

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

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

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

      \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\color{blue}{{u1}^{2} \cdot \left(\frac{1}{2} + \frac{1}{3} \cdot u1\right) + u1}} \]
    8. lower-fma.f32N/A

      \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left({u1}^{2}, \frac{1}{2} + \frac{1}{3} \cdot u1, u1\right)}} \]
    9. unpow2N/A

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

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

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

      \[\leadsto \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{u1 \cdot \frac{1}{3}} + \frac{1}{2}, u1\right)} \]
    13. lower-fma.f3277.4

      \[\leadsto \left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \color{blue}{\mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right)}, u1\right)} \]
  8. Simplified77.4%

    \[\leadsto \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, 0.3333333333333333, 0.5\right), u1\right)}} \]
  9. Final simplification77.4%

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

Alternative 17: 74.5% accurate, 5.9× speedup?

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

\\
\left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{\left(-u1\right) \cdot \mathsf{fma}\left(u1, -0.5, -1\right)}
\end{array}
Derivation
  1. Initial program 53.4%

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    3. lower-neg.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(\color{blue}{-u1}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  4. Applied egg-rr98.4%

    \[\leadsto \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Step-by-step derivation
    1. lift-PI.f32N/A

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)}\right) \]
    4. count-2N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2 + \mathsf{PI}\left(\right) \cdot u2\right)} \]
    5. lift-*.f32N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot u2 + \color{blue}{\mathsf{PI}\left(\right) \cdot u2}\right) \]
    7. distribute-lft-outN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    8. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    9. lower-+.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\pi \cdot \color{blue}{\left(u2 + u2\right)}\right) \]
  6. Applied egg-rr98.4%

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \left(u1 \cdot \frac{-1}{2} + \color{blue}{-1}\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
    5. lower-fma.f3290.3

      \[\leadsto \sqrt{-u1 \cdot \color{blue}{\mathsf{fma}\left(u1, -0.5, -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  9. Simplified90.3%

    \[\leadsto \sqrt{-\color{blue}{u1 \cdot \mathsf{fma}\left(u1, -0.5, -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  10. Taylor expanded in u2 around 0

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \left(2 \cdot \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    3. lower-PI.f3275.2

      \[\leadsto \sqrt{-u1 \cdot \mathsf{fma}\left(u1, -0.5, -1\right)} \cdot \left(2 \cdot \left(u2 \cdot \color{blue}{\pi}\right)\right) \]
  12. Simplified75.2%

    \[\leadsto \sqrt{-u1 \cdot \mathsf{fma}\left(u1, -0.5, -1\right)} \cdot \color{blue}{\left(2 \cdot \left(u2 \cdot \pi\right)\right)} \]
  13. Final simplification75.2%

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

Alternative 18: 66.4% accurate, 8.9× speedup?

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

\\
\left(\pi \cdot u2\right) \cdot \left(2 \cdot \sqrt{u1}\right)
\end{array}
Derivation
  1. Initial program 53.4%

    \[\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 \sqrt{\color{blue}{u1 \cdot \left(1 + u1 \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right)\right)}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \sqrt{{u1}^{2} \cdot \left(\frac{1}{2} + u1 \cdot \left(\frac{1}{3} + \frac{1}{4} \cdot u1\right)\right) + \color{blue}{u1}} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    6. lower-fma.f32N/A

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{u1 \cdot \frac{1}{4}} + \frac{1}{3}, \frac{1}{2}\right), u1\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    13. lower-fma.f3295.3

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \color{blue}{\mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right)}, 0.5\right), u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Simplified95.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \color{blue}{\left(2 \cdot \left(\sin \left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)} \]
    10. lift-sin.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, \frac{1}{4}, \frac{1}{3}\right), \frac{1}{2}\right), u1\right)} \cdot \left(2 \cdot \left(\color{blue}{\sin \left(\mathsf{PI}\left(\right) \cdot u2\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right) \]
    11. lift-cos.f32N/A

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

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

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(u1 \cdot u1, \mathsf{fma}\left(u1, \mathsf{fma}\left(u1, 0.25, 0.3333333333333333\right), 0.5\right), u1\right)} \cdot \sin \left(\pi \cdot u2\right)\right) \cdot \left(2 \cdot \cos \left(\pi \cdot u2\right)\right)} \]
  8. Taylor expanded in u1 around 0

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\left(\sqrt{u1} \cdot \cos \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sin \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    11. lower-PI.f3279.4

      \[\leadsto 2 \cdot \left(\left(\sqrt{u1} \cdot \cos \left(u2 \cdot \pi\right)\right) \cdot \sin \left(u2 \cdot \color{blue}{\pi}\right)\right) \]
  10. Simplified79.4%

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

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

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

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

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

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

      \[\leadsto \left(2 \cdot \sqrt{u1}\right) \cdot \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)} \]
    6. lower-PI.f3268.2

      \[\leadsto \left(2 \cdot \sqrt{u1}\right) \cdot \left(u2 \cdot \color{blue}{\pi}\right) \]
  13. Simplified68.2%

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

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

Alternative 19: 7.1% accurate, 231.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (cosTheta_i u1 u2) :precision binary32 0.0)
float code(float cosTheta_i, float u1, float u2) {
	return 0.0f;
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = 0.0e0
end function
function code(cosTheta_i, u1, u2)
	return Float32(0.0)
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = single(0.0);
end
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 53.4%

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \]
    3. lower-neg.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(\color{blue}{-u1}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  4. Applied egg-rr98.4%

    \[\leadsto \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  5. Step-by-step derivation
    1. lift-PI.f32N/A

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2\right)}\right) \]
    4. count-2N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2 + \mathsf{PI}\left(\right) \cdot u2\right)} \]
    5. lift-*.f32N/A

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

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot u2 + \color{blue}{\mathsf{PI}\left(\right) \cdot u2}\right) \]
    7. distribute-lft-outN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    8. lower-*.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\mathsf{log1p}\left(\mathsf{neg}\left(u1\right)\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right)} \]
    9. lower-+.f3298.4

      \[\leadsto \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(\pi \cdot \color{blue}{\left(u2 + u2\right)}\right) \]
  6. Applied egg-rr98.4%

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \left(u1 \cdot \frac{-1}{2} + \color{blue}{-1}\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(u2 + u2\right)\right) \]
    5. lower-fma.f3290.3

      \[\leadsto \sqrt{-u1 \cdot \color{blue}{\mathsf{fma}\left(u1, -0.5, -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  9. Simplified90.3%

    \[\leadsto \sqrt{-\color{blue}{u1 \cdot \mathsf{fma}\left(u1, -0.5, -1\right)}} \cdot \sin \left(\pi \cdot \left(u2 + u2\right)\right) \]
  10. Step-by-step derivation
    1. lift-fma.f32N/A

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \sin \color{blue}{\left(\frac{\left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right) - \left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)}{\mathsf{PI}\left(\right) \cdot u2 - \mathsf{PI}\left(\right) \cdot u2}\right)} \]
    10. +-inversesN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \sin \left(\frac{\color{blue}{0}}{\mathsf{PI}\left(\right) \cdot u2 - \mathsf{PI}\left(\right) \cdot u2}\right) \]
    11. +-inversesN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \sin \left(\frac{0}{\color{blue}{0}}\right) \]
    12. div0N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \sin \color{blue}{0} \]
    13. +-inversesN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \sin \color{blue}{\left(\mathsf{PI}\left(\right) \cdot u2 - \mathsf{PI}\left(\right) \cdot u2\right)} \]
    14. +-inversesN/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \sin \color{blue}{0} \]
    15. sin-0N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(u1 \cdot \mathsf{fma}\left(u1, \frac{-1}{2}, -1\right)\right)} \cdot \color{blue}{0} \]
    16. mul0-rgt7.2

      \[\leadsto \color{blue}{0} \]
  11. Applied egg-rr7.2%

    \[\leadsto \color{blue}{0} \]
  12. Add Preprocessing

Reproduce

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