UniformSampleCone, y

Percentage Accurate: 57.8% → 98.3%
Time: 18.1s
Alternatives: 17
Speedup: 1.5×

Specification

?
\[\left(\left(2.328306437 \cdot 10^{-10} \leq ux \land ux \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq uy \land uy \leq 1\right)\right) \land \left(0 \leq maxCos \land maxCos \leq 1\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t_0 \cdot t_0} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
   (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* t_0 t_0))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = (single(1.0) - ux) + (ux * maxCos);
	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0)));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t_0 \cdot t_0}
\end{array}
\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 17 alternatives:

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

Initial Program: 57.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t_0 \cdot t_0} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
   (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* t_0 t_0))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = (single(1.0) - ux) + (ux * maxCos);
	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0)));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t_0 \cdot t_0}
\end{array}
\end{array}

Alternative 1: 98.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \sin \left(\sqrt[3]{{\left(uy \cdot 2\right)}^{3} \cdot {\pi}^{3}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sin (cbrt (* (pow (* uy 2.0) 3.0) (pow PI 3.0))))
  (sqrt
   (fma ux (fma maxCos -2.0 2.0) (* (pow (- 1.0 maxCos) 2.0) (* ux (- ux)))))))
float code(float ux, float uy, float maxCos) {
	return sinf(cbrtf((powf((uy * 2.0f), 3.0f) * powf(((float) M_PI), 3.0f)))) * sqrtf(fmaf(ux, fmaf(maxCos, -2.0f, 2.0f), (powf((1.0f - maxCos), 2.0f) * (ux * -ux))));
}
function code(ux, uy, maxCos)
	return Float32(sin(cbrt(Float32((Float32(uy * Float32(2.0)) ^ Float32(3.0)) * (Float32(pi) ^ Float32(3.0))))) * sqrt(fma(ux, fma(maxCos, Float32(-2.0), Float32(2.0)), Float32((Float32(Float32(1.0) - maxCos) ^ Float32(2.0)) * Float32(ux * Float32(-ux))))))
end
\begin{array}{l}

\\
\sin \left(\sqrt[3]{{\left(uy \cdot 2\right)}^{3} \cdot {\pi}^{3}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Step-by-step derivation
    1. associate-*r*98.5%

      \[\leadsto \sin \color{blue}{\left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
    2. add-cbrt-cube98.5%

      \[\leadsto \sin \left(\color{blue}{\sqrt[3]{\left(\left(uy \cdot 2\right) \cdot \left(uy \cdot 2\right)\right) \cdot \left(uy \cdot 2\right)}} \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
    3. add-cbrt-cube98.5%

      \[\leadsto \sin \left(\sqrt[3]{\left(\left(uy \cdot 2\right) \cdot \left(uy \cdot 2\right)\right) \cdot \left(uy \cdot 2\right)} \cdot \color{blue}{\sqrt[3]{\left(\pi \cdot \pi\right) \cdot \pi}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
    4. cbrt-unprod98.5%

      \[\leadsto \sin \color{blue}{\left(\sqrt[3]{\left(\left(\left(uy \cdot 2\right) \cdot \left(uy \cdot 2\right)\right) \cdot \left(uy \cdot 2\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)}\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
    5. pow398.5%

      \[\leadsto \sin \left(\sqrt[3]{\color{blue}{{\left(uy \cdot 2\right)}^{3}} \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)}\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
    6. pow398.5%

      \[\leadsto \sin \left(\sqrt[3]{{\left(uy \cdot 2\right)}^{3} \cdot \color{blue}{{\pi}^{3}}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
  8. Applied egg-rr98.5%

    \[\leadsto \sin \color{blue}{\left(\sqrt[3]{{\left(uy \cdot 2\right)}^{3} \cdot {\pi}^{3}}\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
  9. Final simplification98.5%

    \[\leadsto \sin \left(\sqrt[3]{{\left(uy \cdot 2\right)}^{3} \cdot {\pi}^{3}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \]

Alternative 2: 98.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \cdot \sin \left(\mathsf{log1p}\left(\mathsf{expm1}\left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sqrt
   (fma ux (fma maxCos -2.0 2.0) (* (pow (- 1.0 maxCos) 2.0) (* ux (- ux)))))
  (sin (log1p (expm1 (* uy (* 2.0 PI)))))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(fmaf(ux, fmaf(maxCos, -2.0f, 2.0f), (powf((1.0f - maxCos), 2.0f) * (ux * -ux)))) * sinf(log1pf(expm1f((uy * (2.0f * ((float) M_PI))))));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(fma(ux, fma(maxCos, Float32(-2.0), Float32(2.0)), Float32((Float32(Float32(1.0) - maxCos) ^ Float32(2.0)) * Float32(ux * Float32(-ux))))) * sin(log1p(expm1(Float32(uy * Float32(Float32(2.0) * Float32(pi)))))))
end
\begin{array}{l}

\\
\sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \cdot \sin \left(\mathsf{log1p}\left(\mathsf{expm1}\left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Step-by-step derivation
    1. log1p-expm1-u98.5%

      \[\leadsto \sin \color{blue}{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
  8. Applied egg-rr98.5%

    \[\leadsto \sin \color{blue}{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
  9. Final simplification98.5%

    \[\leadsto \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \cdot \sin \left(\mathsf{log1p}\left(\mathsf{expm1}\left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]

Alternative 3: 98.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \sqrt[3]{{\left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}^{1.5}} \cdot \sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (cbrt
   (pow (- (* ux (fma maxCos -2.0 2.0)) (pow (* ux (- 1.0 maxCos)) 2.0)) 1.5))
  (sin (* PI (* uy 2.0)))))
float code(float ux, float uy, float maxCos) {
	return cbrtf(powf(((ux * fmaf(maxCos, -2.0f, 2.0f)) - powf((ux * (1.0f - maxCos)), 2.0f)), 1.5f)) * sinf((((float) M_PI) * (uy * 2.0f)));
}
function code(ux, uy, maxCos)
	return Float32(cbrt((Float32(Float32(ux * fma(maxCos, Float32(-2.0), Float32(2.0))) - (Float32(ux * Float32(Float32(1.0) - maxCos)) ^ Float32(2.0))) ^ Float32(1.5))) * sin(Float32(Float32(pi) * Float32(uy * Float32(2.0)))))
end
\begin{array}{l}

\\
\sqrt[3]{{\left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}^{1.5}} \cdot \sin \left(\pi \cdot \left(uy \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Taylor expanded in uy around inf 98.4%

    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  8. Step-by-step derivation
    1. *-commutative98.4%

      \[\leadsto \color{blue}{\sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  9. Simplified98.4%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right)} \]
  10. Step-by-step derivation
    1. fma-neg98.5%

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), -{\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
    2. unpow-prod-down98.5%

      \[\leadsto \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), -\color{blue}{{ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}}\right)} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
    3. pow298.5%

      \[\leadsto \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), -\color{blue}{\left(ux \cdot ux\right)} \cdot {\left(1 - maxCos\right)}^{2}\right)} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
    4. distribute-rgt-neg-out98.5%

      \[\leadsto \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)}\right)} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
    5. add-cbrt-cube98.4%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  11. Applied egg-rr98.5%

    \[\leadsto \color{blue}{\sqrt[3]{\left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  12. Step-by-step derivation
    1. *-commutative98.5%

      \[\leadsto \sqrt[3]{\color{blue}{\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}} \cdot \left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
    2. unpow1/298.5%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}^{0.5}} \cdot \left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
    3. pow-plus98.4%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}^{\left(0.5 + 1\right)}}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
    4. metadata-eval98.4%

      \[\leadsto \sqrt[3]{{\left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}^{\color{blue}{1.5}}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  13. Simplified98.4%

    \[\leadsto \color{blue}{\sqrt[3]{{\left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}^{1.5}}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  14. Final simplification98.4%

    \[\leadsto \sqrt[3]{{\left(ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}\right)}^{1.5}} \cdot \sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \]

Alternative 4: 98.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sqrt
   (fma ux (fma maxCos -2.0 2.0) (* (pow (- 1.0 maxCos) 2.0) (* ux (- ux)))))
  (sin (* uy (* 2.0 PI)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(fmaf(ux, fmaf(maxCos, -2.0f, 2.0f), (powf((1.0f - maxCos), 2.0f) * (ux * -ux)))) * sinf((uy * (2.0f * ((float) M_PI))));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(fma(ux, fma(maxCos, Float32(-2.0), Float32(2.0)), Float32((Float32(Float32(1.0) - maxCos) ^ Float32(2.0)) * Float32(ux * Float32(-ux))))) * sin(Float32(uy * Float32(Float32(2.0) * Float32(pi)))))
end
\begin{array}{l}

\\
\sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Final simplification98.5%

    \[\leadsto \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \]

Alternative 5: 98.4% accurate, 0.8× speedup?

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

\\
\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(maxCos + -1\right)\right)}
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Taylor expanded in uy around inf 98.4%

    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  8. Step-by-step derivation
    1. *-commutative98.4%

      \[\leadsto \color{blue}{\sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  9. Simplified98.4%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right)} \]
  10. Step-by-step derivation
    1. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right)}}\right)\right) \]
  11. Applied egg-rr98.4%

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right)}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  12. Final simplification98.4%

    \[\leadsto \sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(maxCos + -1\right)\right)} \]

Alternative 6: 97.7% accurate, 0.8× speedup?

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

\\
\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot ux\right) \cdot \left(-1 - maxCos \cdot -2\right)}
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Taylor expanded in uy around inf 98.4%

    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  8. Step-by-step derivation
    1. *-commutative98.4%

      \[\leadsto \color{blue}{\sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  9. Simplified98.4%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right)} \]
  10. Taylor expanded in maxCos around 0 97.6%

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(-2 \cdot \left(maxCos \cdot {ux}^{2}\right) + {ux}^{2}\right)}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  11. Step-by-step derivation
    1. associate-*r*83.0%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(\color{blue}{\left(-2 \cdot maxCos\right) \cdot {ux}^{2}} + {ux}^{2}\right)}\right)\right) \]
    2. distribute-lft1-in83.0%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(-2 \cdot maxCos + 1\right) \cdot {ux}^{2}}}\right)\right) \]
    3. *-commutative83.0%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(\color{blue}{maxCos \cdot -2} + 1\right) \cdot {ux}^{2}}\right)\right) \]
    4. unpow283.0%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(maxCos \cdot -2 + 1\right) \cdot \color{blue}{\left(ux \cdot ux\right)}}\right)\right) \]
  12. Simplified97.6%

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(maxCos \cdot -2 + 1\right) \cdot \left(ux \cdot ux\right)}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  13. Final simplification97.6%

    \[\leadsto \sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot ux\right) \cdot \left(-1 - maxCos \cdot -2\right)} \]

Alternative 7: 96.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - ux \cdot ux} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (* (sin (* PI (* uy 2.0))) (sqrt (- (* ux (fma maxCos -2.0 2.0)) (* ux ux)))))
float code(float ux, float uy, float maxCos) {
	return sinf((((float) M_PI) * (uy * 2.0f))) * sqrtf(((ux * fmaf(maxCos, -2.0f, 2.0f)) - (ux * ux)));
}
function code(ux, uy, maxCos)
	return Float32(sin(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * sqrt(Float32(Float32(ux * fma(maxCos, Float32(-2.0), Float32(2.0))) - Float32(ux * ux))))
end
\begin{array}{l}

\\
\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - ux \cdot ux}
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Taylor expanded in uy around inf 98.4%

    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  8. Step-by-step derivation
    1. *-commutative98.4%

      \[\leadsto \color{blue}{\sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  9. Simplified98.4%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right)} \]
  10. Taylor expanded in maxCos around 0 97.0%

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{{ux}^{2}}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  11. Step-by-step derivation
    1. unpow282.4%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{ux \cdot ux}}\right)\right) \]
  12. Simplified97.0%

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{ux \cdot ux}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  13. Final simplification97.0%

    \[\leadsto \sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - ux \cdot ux} \]

Alternative 8: 95.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\ \;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(maxCos + -1\right)\right)}\right)\right)\\ \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (if (<= maxCos 1.500000053056283e-6)
   (* (sin (* PI (* uy 2.0))) (sqrt (- (* 2.0 ux) (* ux ux))))
   (*
    2.0
    (*
     uy
     (*
      PI
      (sqrt
       (+
        (* ux (fma maxCos -2.0 2.0))
        (* (* ux (- 1.0 maxCos)) (* ux (+ maxCos -1.0))))))))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if (maxCos <= 1.500000053056283e-6f) {
		tmp = sinf((((float) M_PI) * (uy * 2.0f))) * sqrtf(((2.0f * ux) - (ux * ux)));
	} else {
		tmp = 2.0f * (uy * (((float) M_PI) * sqrtf(((ux * fmaf(maxCos, -2.0f, 2.0f)) + ((ux * (1.0f - maxCos)) * (ux * (maxCos + -1.0f)))))));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	tmp = Float32(0.0)
	if (maxCos <= Float32(1.500000053056283e-6))
		tmp = Float32(sin(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * sqrt(Float32(Float32(Float32(2.0) * ux) - Float32(ux * ux))));
	else
		tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(ux * fma(maxCos, Float32(-2.0), Float32(2.0))) + Float32(Float32(ux * Float32(Float32(1.0) - maxCos)) * Float32(ux * Float32(maxCos + Float32(-1.0)))))))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\
\;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(maxCos + -1\right)\right)}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if maxCos < 1.50000005e-6

    1. Initial program 55.8%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Step-by-step derivation
      1. associate-*l*55.8%

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. +-commutative55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      3. associate-+r-55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      4. fma-def55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      5. +-commutative55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
      6. associate-+r-55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
      7. fma-def55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
    3. Simplified55.8%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    4. Taylor expanded in ux around -inf 98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
    5. Step-by-step derivation
      1. +-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
      2. metadata-eval98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
      3. cancel-sign-sub-inv98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
      4. fma-def98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
      5. cancel-sign-sub-inv98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      6. metadata-eval98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      7. +-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      8. *-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      9. fma-def98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      10. mul-1-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
      11. distribute-rgt-neg-in98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
      12. unpow298.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      13. mul-1-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
      14. unsub-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
    6. Simplified98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
    7. Taylor expanded in maxCos around 0 98.2%

      \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
    8. Step-by-step derivation
      1. associate-*r*98.2%

        \[\leadsto \sin \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux} \]
      2. +-commutative98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{2 \cdot ux + -1 \cdot {ux}^{2}}} \]
      3. mul-1-neg98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux + \color{blue}{\left(-{ux}^{2}\right)}} \]
      4. unsub-neg98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{2 \cdot ux - {ux}^{2}}} \]
      5. unpow298.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}} \]
    9. Simplified98.2%

      \[\leadsto \color{blue}{\sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}} \]

    if 1.50000005e-6 < maxCos

    1. Initial program 53.7%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Step-by-step derivation
      1. associate-*l*53.7%

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. +-commutative53.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      3. associate-+r-53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      4. fma-def53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      5. +-commutative53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
      6. associate-+r-53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
      7. fma-def53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
    3. Simplified53.6%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    4. Taylor expanded in uy around 0 53.2%

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
    5. Step-by-step derivation
      1. associate-*l*53.2%

        \[\leadsto 2 \cdot \color{blue}{\left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right)} \]
      2. +-commutative53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}}\right)\right) \]
      3. *-commutative53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}}\right)\right) \]
      4. fma-udef53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)}^{2}}\right)\right) \]
    6. Simplified53.2%

      \[\leadsto \color{blue}{2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}\right)\right)} \]
    7. Taylor expanded in ux around -inf 92.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}}\right)\right) \]
    8. Step-by-step derivation
      1. +-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
      2. mul-1-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
      3. unsub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}}\right)\right) \]
      4. +-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\left(-2 \cdot maxCos + 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      5. *-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(\color{blue}{maxCos \cdot -2} + 2\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      6. fma-udef92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      7. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot ux\right)} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      8. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot ux\right) \cdot \color{blue}{\left(\left(1 + -1 \cdot maxCos\right) \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
      9. swap-sqr92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
      10. neg-mul-192.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
      11. sub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
      12. neg-mul-192.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right)}\right)\right) \]
      13. sub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right)}\right)\right) \]
      14. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{{\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
    9. Simplified92.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
    10. Step-by-step derivation
      1. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right)}}\right)\right) \]
    11. Applied egg-rr92.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right)}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\ \;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(maxCos + -1\right)\right)}\right)\right)\\ \end{array} \]

Alternative 9: 95.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\ \;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot ux\right) \cdot \left(-1 - maxCos \cdot -2\right)}\right)\right)\\ \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (if (<= maxCos 1.500000053056283e-6)
   (* (sin (* PI (* uy 2.0))) (sqrt (- (* 2.0 ux) (* ux ux))))
   (*
    2.0
    (*
     uy
     (*
      PI
      (sqrt
       (+
        (* ux (fma maxCos -2.0 2.0))
        (* (* ux ux) (- -1.0 (* maxCos -2.0))))))))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if (maxCos <= 1.500000053056283e-6f) {
		tmp = sinf((((float) M_PI) * (uy * 2.0f))) * sqrtf(((2.0f * ux) - (ux * ux)));
	} else {
		tmp = 2.0f * (uy * (((float) M_PI) * sqrtf(((ux * fmaf(maxCos, -2.0f, 2.0f)) + ((ux * ux) * (-1.0f - (maxCos * -2.0f)))))));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	tmp = Float32(0.0)
	if (maxCos <= Float32(1.500000053056283e-6))
		tmp = Float32(sin(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * sqrt(Float32(Float32(Float32(2.0) * ux) - Float32(ux * ux))));
	else
		tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(ux * fma(maxCos, Float32(-2.0), Float32(2.0))) + Float32(Float32(ux * ux) * Float32(Float32(-1.0) - Float32(maxCos * Float32(-2.0)))))))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\
\;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot ux\right) \cdot \left(-1 - maxCos \cdot -2\right)}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if maxCos < 1.50000005e-6

    1. Initial program 55.8%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Step-by-step derivation
      1. associate-*l*55.8%

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. +-commutative55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      3. associate-+r-55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      4. fma-def55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      5. +-commutative55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
      6. associate-+r-55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
      7. fma-def55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
    3. Simplified55.8%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    4. Taylor expanded in ux around -inf 98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
    5. Step-by-step derivation
      1. +-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
      2. metadata-eval98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
      3. cancel-sign-sub-inv98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
      4. fma-def98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
      5. cancel-sign-sub-inv98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      6. metadata-eval98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      7. +-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      8. *-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      9. fma-def98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      10. mul-1-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
      11. distribute-rgt-neg-in98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
      12. unpow298.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      13. mul-1-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
      14. unsub-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
    6. Simplified98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
    7. Taylor expanded in maxCos around 0 98.2%

      \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
    8. Step-by-step derivation
      1. associate-*r*98.2%

        \[\leadsto \sin \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux} \]
      2. +-commutative98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{2 \cdot ux + -1 \cdot {ux}^{2}}} \]
      3. mul-1-neg98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux + \color{blue}{\left(-{ux}^{2}\right)}} \]
      4. unsub-neg98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{2 \cdot ux - {ux}^{2}}} \]
      5. unpow298.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}} \]
    9. Simplified98.2%

      \[\leadsto \color{blue}{\sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}} \]

    if 1.50000005e-6 < maxCos

    1. Initial program 53.7%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Step-by-step derivation
      1. associate-*l*53.7%

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. +-commutative53.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      3. associate-+r-53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      4. fma-def53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      5. +-commutative53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
      6. associate-+r-53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
      7. fma-def53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
    3. Simplified53.6%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    4. Taylor expanded in uy around 0 53.2%

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
    5. Step-by-step derivation
      1. associate-*l*53.2%

        \[\leadsto 2 \cdot \color{blue}{\left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right)} \]
      2. +-commutative53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}}\right)\right) \]
      3. *-commutative53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}}\right)\right) \]
      4. fma-udef53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)}^{2}}\right)\right) \]
    6. Simplified53.2%

      \[\leadsto \color{blue}{2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}\right)\right)} \]
    7. Taylor expanded in ux around -inf 92.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}}\right)\right) \]
    8. Step-by-step derivation
      1. +-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
      2. mul-1-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
      3. unsub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}}\right)\right) \]
      4. +-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\left(-2 \cdot maxCos + 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      5. *-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(\color{blue}{maxCos \cdot -2} + 2\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      6. fma-udef92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      7. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot ux\right)} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      8. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot ux\right) \cdot \color{blue}{\left(\left(1 + -1 \cdot maxCos\right) \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
      9. swap-sqr92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
      10. neg-mul-192.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
      11. sub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
      12. neg-mul-192.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right)}\right)\right) \]
      13. sub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right)}\right)\right) \]
      14. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{{\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
    9. Simplified92.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
    10. Taylor expanded in maxCos around 0 87.1%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(-2 \cdot \left(maxCos \cdot {ux}^{2}\right) + {ux}^{2}\right)}}\right)\right) \]
    11. Step-by-step derivation
      1. associate-*r*87.1%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(\color{blue}{\left(-2 \cdot maxCos\right) \cdot {ux}^{2}} + {ux}^{2}\right)}\right)\right) \]
      2. distribute-lft1-in87.1%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(-2 \cdot maxCos + 1\right) \cdot {ux}^{2}}}\right)\right) \]
      3. *-commutative87.1%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(\color{blue}{maxCos \cdot -2} + 1\right) \cdot {ux}^{2}}\right)\right) \]
      4. unpow287.1%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(maxCos \cdot -2 + 1\right) \cdot \color{blue}{\left(ux \cdot ux\right)}}\right)\right) \]
    12. Simplified87.1%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(maxCos \cdot -2 + 1\right) \cdot \left(ux \cdot ux\right)}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\ \;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) + \left(ux \cdot ux\right) \cdot \left(-1 - maxCos \cdot -2\right)}\right)\right)\\ \end{array} \]

Alternative 10: 94.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\ \;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - ux \cdot ux}\right)\right)\\ \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (if (<= maxCos 1.500000053056283e-6)
   (* (sin (* PI (* uy 2.0))) (sqrt (- (* 2.0 ux) (* ux ux))))
   (* 2.0 (* uy (* PI (sqrt (- (* ux (fma maxCos -2.0 2.0)) (* ux ux))))))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if (maxCos <= 1.500000053056283e-6f) {
		tmp = sinf((((float) M_PI) * (uy * 2.0f))) * sqrtf(((2.0f * ux) - (ux * ux)));
	} else {
		tmp = 2.0f * (uy * (((float) M_PI) * sqrtf(((ux * fmaf(maxCos, -2.0f, 2.0f)) - (ux * ux)))));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	tmp = Float32(0.0)
	if (maxCos <= Float32(1.500000053056283e-6))
		tmp = Float32(sin(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * sqrt(Float32(Float32(Float32(2.0) * ux) - Float32(ux * ux))));
	else
		tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(ux * fma(maxCos, Float32(-2.0), Float32(2.0))) - Float32(ux * ux))))));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\
\;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - ux \cdot ux}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if maxCos < 1.50000005e-6

    1. Initial program 55.8%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Step-by-step derivation
      1. associate-*l*55.8%

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. +-commutative55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      3. associate-+r-55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      4. fma-def55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      5. +-commutative55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
      6. associate-+r-55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
      7. fma-def55.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
    3. Simplified55.8%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    4. Taylor expanded in ux around -inf 98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
    5. Step-by-step derivation
      1. +-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
      2. metadata-eval98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
      3. cancel-sign-sub-inv98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
      4. fma-def98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
      5. cancel-sign-sub-inv98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      6. metadata-eval98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      7. +-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      8. *-commutative98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      9. fma-def98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      10. mul-1-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
      11. distribute-rgt-neg-in98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
      12. unpow298.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
      13. mul-1-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
      14. unsub-neg98.4%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
    6. Simplified98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
    7. Taylor expanded in maxCos around 0 98.2%

      \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
    8. Step-by-step derivation
      1. associate-*r*98.2%

        \[\leadsto \sin \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux} \]
      2. +-commutative98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{2 \cdot ux + -1 \cdot {ux}^{2}}} \]
      3. mul-1-neg98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux + \color{blue}{\left(-{ux}^{2}\right)}} \]
      4. unsub-neg98.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{2 \cdot ux - {ux}^{2}}} \]
      5. unpow298.2%

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}} \]
    9. Simplified98.2%

      \[\leadsto \color{blue}{\sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}} \]

    if 1.50000005e-6 < maxCos

    1. Initial program 53.7%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Step-by-step derivation
      1. associate-*l*53.7%

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. +-commutative53.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      3. associate-+r-53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      4. fma-def53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      5. +-commutative53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
      6. associate-+r-53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
      7. fma-def53.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
    3. Simplified53.6%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    4. Taylor expanded in uy around 0 53.2%

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
    5. Step-by-step derivation
      1. associate-*l*53.2%

        \[\leadsto 2 \cdot \color{blue}{\left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right)} \]
      2. +-commutative53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}}\right)\right) \]
      3. *-commutative53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}}\right)\right) \]
      4. fma-udef53.2%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)}^{2}}\right)\right) \]
    6. Simplified53.2%

      \[\leadsto \color{blue}{2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}\right)\right)} \]
    7. Taylor expanded in ux around -inf 92.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}}\right)\right) \]
    8. Step-by-step derivation
      1. +-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
      2. mul-1-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
      3. unsub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}}\right)\right) \]
      4. +-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\left(-2 \cdot maxCos + 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      5. *-commutative92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(\color{blue}{maxCos \cdot -2} + 2\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      6. fma-udef92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      7. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot ux\right)} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
      8. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot ux\right) \cdot \color{blue}{\left(\left(1 + -1 \cdot maxCos\right) \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
      9. swap-sqr92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
      10. neg-mul-192.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
      11. sub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
      12. neg-mul-192.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right)}\right)\right) \]
      13. sub-neg92.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right)}\right)\right) \]
      14. unpow292.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{{\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
    9. Simplified92.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
    10. Taylor expanded in maxCos around 0 82.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{{ux}^{2}}}\right)\right) \]
    11. Step-by-step derivation
      1. unpow282.6%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{ux \cdot ux}}\right)\right) \]
    12. Simplified82.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{ux \cdot ux}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;maxCos \leq 1.500000053056283 \cdot 10^{-6}:\\ \;\;\;\;\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - ux \cdot ux}\right)\right)\\ \end{array} \]

Alternative 11: 92.2% accurate, 1.0× speedup?

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

\\
\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Taylor expanded in maxCos around 0 93.0%

    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
  8. Step-by-step derivation
    1. associate-*r*93.0%

      \[\leadsto \sin \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux} \]
    2. +-commutative93.0%

      \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{2 \cdot ux + -1 \cdot {ux}^{2}}} \]
    3. mul-1-neg93.0%

      \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux + \color{blue}{\left(-{ux}^{2}\right)}} \]
    4. unsub-neg93.0%

      \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{2 \cdot ux - {ux}^{2}}} \]
    5. unpow293.0%

      \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}} \]
  9. Simplified93.0%

    \[\leadsto \color{blue}{\sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}} \]
  10. Final simplification93.0%

    \[\leadsto \sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux} \]

Alternative 12: 92.2% accurate, 1.0× speedup?

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

\\
\sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Taylor expanded in uy around inf 98.4%

    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  8. Step-by-step derivation
    1. *-commutative98.4%

      \[\leadsto \color{blue}{\sqrt{-1 \cdot \left({ux}^{2} \cdot {\left(1 - maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  9. Simplified98.4%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right)} \]
  10. Taylor expanded in maxCos around 0 93.0%

    \[\leadsto \color{blue}{\sqrt{2 \cdot ux - {ux}^{2}}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  11. Step-by-step derivation
    1. unpow293.0%

      \[\leadsto \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
    2. distribute-rgt-out--93.0%

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  12. Simplified93.0%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 - ux\right)}} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
  13. Final simplification93.0%

    \[\leadsto \sin \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)} \]

Alternative 13: 77.5% accurate, 1.5× speedup?

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

\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\right)
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in uy around 0 50.5%

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
  5. Step-by-step derivation
    1. associate-*l*50.5%

      \[\leadsto 2 \cdot \color{blue}{\left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right)} \]
    2. +-commutative50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}}\right)\right) \]
    3. *-commutative50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}}\right)\right) \]
    4. fma-udef50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)}^{2}}\right)\right) \]
  6. Simplified50.5%

    \[\leadsto \color{blue}{2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}\right)\right)} \]
  7. Taylor expanded in ux around -inf 83.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}}\right)\right) \]
  8. Step-by-step derivation
    1. +-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
    2. mul-1-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
    3. unsub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}}\right)\right) \]
    4. +-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\left(-2 \cdot maxCos + 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    5. *-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(\color{blue}{maxCos \cdot -2} + 2\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    6. fma-udef83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    7. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot ux\right)} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    8. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot ux\right) \cdot \color{blue}{\left(\left(1 + -1 \cdot maxCos\right) \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
    9. swap-sqr83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
    10. neg-mul-183.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
    11. sub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
    12. neg-mul-183.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right)}\right)\right) \]
    13. sub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right)}\right)\right) \]
    14. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{{\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
  9. Simplified83.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
  10. Taylor expanded in maxCos around 0 79.1%

    \[\leadsto 2 \cdot \color{blue}{\left(\left(uy \cdot \pi\right) \cdot \sqrt{2 \cdot ux - {ux}^{2}}\right)} \]
  11. Step-by-step derivation
    1. *-commutative79.1%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot 2} - {ux}^{2}}\right) \]
    2. unpow279.1%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot 2 - \color{blue}{ux \cdot ux}}\right) \]
  12. Simplified79.1%

    \[\leadsto 2 \cdot \color{blue}{\left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot 2 - ux \cdot ux}\right)} \]
  13. Final simplification79.1%

    \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\right) \]

Alternative 14: 77.5% accurate, 1.5× speedup?

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

\\
2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - ux\right)}\right)\right)
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in uy around 0 50.5%

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
  5. Step-by-step derivation
    1. associate-*l*50.5%

      \[\leadsto 2 \cdot \color{blue}{\left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right)} \]
    2. +-commutative50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}}\right)\right) \]
    3. *-commutative50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}}\right)\right) \]
    4. fma-udef50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)}^{2}}\right)\right) \]
  6. Simplified50.5%

    \[\leadsto \color{blue}{2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}\right)\right)} \]
  7. Taylor expanded in ux around -inf 83.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}}\right)\right) \]
  8. Step-by-step derivation
    1. +-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
    2. mul-1-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
    3. unsub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}}\right)\right) \]
    4. +-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\left(-2 \cdot maxCos + 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    5. *-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(\color{blue}{maxCos \cdot -2} + 2\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    6. fma-udef83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    7. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot ux\right)} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    8. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot ux\right) \cdot \color{blue}{\left(\left(1 + -1 \cdot maxCos\right) \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
    9. swap-sqr83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
    10. neg-mul-183.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
    11. sub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
    12. neg-mul-183.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right)}\right)\right) \]
    13. sub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right)}\right)\right) \]
    14. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{{\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
  9. Simplified83.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
  10. Taylor expanded in maxCos around 0 79.1%

    \[\leadsto 2 \cdot \left(uy \cdot \color{blue}{\left(\pi \cdot \sqrt{2 \cdot ux - {ux}^{2}}\right)}\right) \]
  11. Step-by-step derivation
    1. unpow279.1%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}}\right)\right) \]
    2. distribute-rgt-out--79.1%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}}\right)\right) \]
  12. Simplified79.1%

    \[\leadsto 2 \cdot \left(uy \cdot \color{blue}{\left(\pi \cdot \sqrt{ux \cdot \left(2 - ux\right)}\right)}\right) \]
  13. Final simplification79.1%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - ux\right)}\right)\right) \]

Alternative 15: 77.5% accurate, 1.5× speedup?

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

\\
2 \cdot \left(\sqrt{ux \cdot \left(2 - ux\right)} \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in uy around 0 50.5%

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
  5. Step-by-step derivation
    1. associate-*l*50.5%

      \[\leadsto 2 \cdot \color{blue}{\left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right)} \]
    2. +-commutative50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}}\right)\right) \]
    3. *-commutative50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}}\right)\right) \]
    4. fma-udef50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)}^{2}}\right)\right) \]
  6. Simplified50.5%

    \[\leadsto \color{blue}{2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}\right)\right)} \]
  7. Taylor expanded in ux around -inf 83.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}}\right)\right) \]
  8. Step-by-step derivation
    1. +-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
    2. mul-1-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}}\right)\right) \]
    3. unsub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}}\right)\right) \]
    4. +-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\left(-2 \cdot maxCos + 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    5. *-commutative83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(\color{blue}{maxCos \cdot -2} + 2\right) - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    6. fma-udef83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)} - {ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    7. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot ux\right)} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)\right) \]
    8. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot ux\right) \cdot \color{blue}{\left(\left(1 + -1 \cdot maxCos\right) \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
    9. swap-sqr83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}}\right)\right) \]
    10. neg-mul-183.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
    11. sub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right) \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}\right)\right) \]
    12. neg-mul-183.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right)}\right)\right) \]
    13. sub-neg83.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot \color{blue}{\left(1 - maxCos\right)}\right)}\right)\right) \]
    14. unpow283.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - \color{blue}{{\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
  9. Simplified83.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right) - {\left(ux \cdot \left(1 - maxCos\right)\right)}^{2}}}\right)\right) \]
  10. Taylor expanded in maxCos around 0 79.1%

    \[\leadsto 2 \cdot \color{blue}{\left(\left(uy \cdot \pi\right) \cdot \sqrt{2 \cdot ux - {ux}^{2}}\right)} \]
  11. Step-by-step derivation
    1. unpow279.1%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}}\right) \]
    2. distribute-rgt-out--79.1%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}}\right) \]
  12. Simplified79.1%

    \[\leadsto 2 \cdot \color{blue}{\left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\right)} \]
  13. Final simplification79.1%

    \[\leadsto 2 \cdot \left(\sqrt{ux \cdot \left(2 - ux\right)} \cdot \left(uy \cdot \pi\right)\right) \]

Alternative 16: 63.3% accurate, 1.5× speedup?

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

\\
2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right)
\end{array}
Derivation
  1. Initial program 55.6%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in uy around 0 50.5%

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
  5. Step-by-step derivation
    1. associate-*l*50.5%

      \[\leadsto 2 \cdot \color{blue}{\left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right)} \]
    2. +-commutative50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}}\right)\right) \]
    3. *-commutative50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(\color{blue}{ux \cdot maxCos} + 1\right) - ux\right)}^{2}}\right)\right) \]
    4. fma-udef50.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)}^{2}}\right)\right) \]
  6. Simplified50.5%

    \[\leadsto \color{blue}{2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}\right)\right)} \]
  7. Taylor expanded in ux around 0 68.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot \left(2 - 2 \cdot maxCos\right)}}\right)\right) \]
  8. Taylor expanded in maxCos around 0 65.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{2 \cdot ux}}\right)\right) \]
  9. Step-by-step derivation
    1. *-commutative65.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot 2}}\right)\right) \]
  10. Simplified65.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{ux \cdot 2}}\right)\right) \]
  11. Final simplification65.6%

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right) \]

Alternative 17: 7.1% accurate, 322.0× speedup?

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

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

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. associate-*l*55.6%

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. +-commutative55.6%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. +-commutative55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}} \]
    6. associate-+r-55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}} \]
    7. fma-def55.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)} - ux\right)} \]
  3. Simplified55.5%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  4. Taylor expanded in ux around -inf 98.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{-1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right) + ux \cdot \left(2 + -2 \cdot maxCos\right)}} \]
  5. Step-by-step derivation
    1. +-commutative98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -2 \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)}} \]
    2. metadata-eval98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right) + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    3. cancel-sign-sub-inv98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)} + -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)} \]
    4. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 2 - 2 \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)}} \]
    5. cancel-sign-sub-inv98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{2 + \left(-2\right) \cdot maxCos}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    6. metadata-eval98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 + \color{blue}{-2} \cdot maxCos, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    7. +-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{-2 \cdot maxCos + 2}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    8. *-commutative98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{maxCos \cdot -2} + 2, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    9. fma-def98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, -1 \cdot \left({ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    10. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{-{ux}^{2} \cdot {\left(1 + -1 \cdot maxCos\right)}^{2}}\right)} \]
    11. distribute-rgt-neg-in98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{{ux}^{2} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)}\right)} \]
    12. unpow298.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \color{blue}{\left(ux \cdot ux\right)} \cdot \left(-{\left(1 + -1 \cdot maxCos\right)}^{2}\right)\right)} \]
    13. mul-1-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 + \color{blue}{\left(-maxCos\right)}\right)}^{2}\right)\right)} \]
    14. unsub-neg98.5%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\color{blue}{\left(1 - maxCos\right)}}^{2}\right)\right)} \]
  6. Simplified98.5%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)}} \]
  7. Step-by-step derivation
    1. add-cube-cbrt97.2%

      \[\leadsto \sin \color{blue}{\left(\left(\sqrt[3]{uy \cdot \left(2 \cdot \pi\right)} \cdot \sqrt[3]{uy \cdot \left(2 \cdot \pi\right)}\right) \cdot \sqrt[3]{uy \cdot \left(2 \cdot \pi\right)}\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
    2. pow397.3%

      \[\leadsto \sin \color{blue}{\left({\left(\sqrt[3]{uy \cdot \left(2 \cdot \pi\right)}\right)}^{3}\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
  8. Applied egg-rr97.3%

    \[\leadsto \sin \color{blue}{\left({\left(\sqrt[3]{uy \cdot \left(2 \cdot \pi\right)}\right)}^{3}\right)} \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, -2, 2\right), \left(ux \cdot ux\right) \cdot \left(-{\left(1 - maxCos\right)}^{2}\right)\right)} \]
  9. Taylor expanded in uy around 0 7.1%

    \[\leadsto \color{blue}{0} \]
  10. Final simplification7.1%

    \[\leadsto 0 \]

Reproduce

?
herbie shell --seed 2023293 
(FPCore (ux uy maxCos)
  :name "UniformSampleCone, y"
  :precision binary32
  :pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
  (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))