UniformSampleCone, y

Percentage Accurate: 57.9% → 98.3%
Time: 17.2s
Alternatives: 16
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 16 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.9% 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, 1 + \left(\left(1 - maxCos\right) - maxCos\right), \left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(ux \cdot 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
    (+ 1.0 (- (- 1.0 maxCos) maxCos))
    (* (- 1.0 maxCos) (* (+ maxCos -1.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, (1.0f + ((1.0f - maxCos) - maxCos)), ((1.0f - maxCos) * ((maxCos + -1.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, Float32(Float32(1.0) + Float32(Float32(Float32(1.0) - maxCos) - maxCos)), Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(maxCos + Float32(-1.0)) * Float32(ux * 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, 1 + \left(\left(1 - maxCos\right) - maxCos\right), \left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(ux \cdot ux\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 55.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*55.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. sub-neg55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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, 1 + \left(\left(1 - maxCos\right) - maxCos\right), \left(maxCos + -1\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right)\right)} \]
    3. add-cbrt-cube98.3%

      \[\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, 1 + \left(\left(1 - maxCos\right) - maxCos\right), \left(maxCos + -1\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right)\right)} \]
    4. cbrt-unprod98.3%

      \[\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, 1 + \left(\left(1 - maxCos\right) - maxCos\right), \left(maxCos + -1\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right)\right)} \]
    5. pow398.4%

      \[\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, 1 + \left(\left(1 - maxCos\right) - maxCos\right), \left(maxCos + -1\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right)\right)} \]
    6. pow398.4%

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

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

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

Alternative 2: 98.3% accurate, 0.8× speedup?

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

\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot {\left(\mathsf{fma}\left(ux, 1 + \left(1 - \left(maxCos + maxCos\right)\right), \left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(ux \cdot ux\right)\right)\right)\right)}^{0.5}
\end{array}
Derivation
  1. Initial program 55.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*55.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. sub-neg55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \color{blue}{{\left(\mathsf{fma}\left(ux, 1 + \left(\left(1 - maxCos\right) - maxCos\right), \left(maxCos + -1\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right)\right)\right)}^{0.5}} \]
    2. associate--l-98.3%

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

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

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

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

Alternative 3: 98.3% accurate, 0.8× speedup?

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

\\
\sqrt{\mathsf{fma}\left(2 - \left(maxCos + maxCos\right), ux, \left(1 - maxCos\right) \cdot \left(ux \cdot \left(ux \cdot \left(maxCos + -1\right)\right)\right)\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right)
\end{array}
Derivation
  1. Initial program 55.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*55.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. sub-neg55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 95.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 6.199999916134402 \cdot 10^{-5}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(2, ux, ux \cdot \left(-ux\right)\right)}\\

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


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

    1. Initial program 56.0%

      \[\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*56.0%

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

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

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in56.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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*97.7%

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

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

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

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

        \[\leadsto \sin \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(2, ux, -\color{blue}{ux \cdot ux}\right)} \]
      6. distribute-rgt-neg-in97.7%

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

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

    if 6.19999992e-5 < maxCos

    1. Initial program 54.1%

      \[\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*54.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 91.1% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) < 0.999779999

    1. Initial program 90.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)} \]

    if 0.999779999 < (+.f32 (-.f32 1 ux) (*.f32 ux maxCos))

    1. Initial program 34.5%

      \[\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*34.5%

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

        \[\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-34.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-def34.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. +-commutative34.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-34.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - ux\right) + ux \cdot maxCos \leq 0.999779999256134:\\ \;\;\;\;\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(ux + -1\right) - ux \cdot maxCos\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\ \end{array} \]

Alternative 6: 90.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.0009500000160187483:\\
\;\;\;\;2 \cdot \left(\sqrt{\mathsf{fma}\left(2 - \left(maxCos + maxCos\right), ux, \left(1 - maxCos\right) \cdot \left(ux \cdot \left(ux \cdot \left(maxCos + -1\right)\right)\right)\right)} \cdot \left(uy \cdot \pi\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 9.50000016e-4

    1. Initial program 59.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*59.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. sub-neg59.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.50000016e-4 < uy

    1. Initial program 49.2%

      \[\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*49.2%

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

        \[\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-49.3%

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

        \[\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. +-commutative49.3%

        \[\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-49.0%

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

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

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

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

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

Alternative 7: 89.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ux < 3.9999999e-4

    1. Initial program 35.4%

      \[\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*35.4%

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

        \[\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-35.4%

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

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

        \[\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-35.2%

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

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

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

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

    if 3.9999999e-4 < ux

    1. Initial program 90.9%

      \[\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*90.9%

        \[\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. sub-neg90.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{1 + \left(ux - 1\right) \cdot \left(1 - ux\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.00039999998989515007:\\ \;\;\;\;\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \end{array} \]

Alternative 8: 86.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.0005099999834783375:\\
\;\;\;\;2 \cdot \left(\sqrt{\mathsf{fma}\left(2, ux, ux \cdot \left(-ux\right)\right)} \cdot \left(uy \cdot \pi\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 5.09999983e-4

    1. Initial program 60.2%

      \[\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*60.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.09999983e-4 < uy

    1. Initial program 48.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*48.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. +-commutative48.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-48.9%

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

        \[\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. +-commutative48.9%

        \[\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-48.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-def48.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. Simplified48.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 ux around 0 80.8%

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

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

Alternative 9: 77.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00013000000035390258:\\
\;\;\;\;2 \cdot \left(\pi \cdot \left(uy \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ux < 1.3e-4

    1. Initial program 33.3%

      \[\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*33.3%

        \[\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. sub-neg33.3%

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

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in33.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \color{blue}{\left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)} \]
    10. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)} \]
      2. cancel-sign-sub-inv72.7%

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

        \[\leadsto 2 \cdot \left(\sqrt{ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)} \cdot \left(uy \cdot \pi\right)\right) \]
      4. associate-*r*72.7%

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

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

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

        \[\leadsto 2 \cdot \left(\pi \cdot \left(uy \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-2\right)} \cdot maxCos\right)}\right)\right) \]
      8. cancel-sign-sub-inv72.7%

        \[\leadsto 2 \cdot \left(\pi \cdot \left(uy \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)}}\right)\right) \]
      9. *-commutative72.7%

        \[\leadsto 2 \cdot \left(\pi \cdot \left(uy \cdot \sqrt{\color{blue}{\left(2 - 2 \cdot maxCos\right) \cdot ux}}\right)\right) \]
      10. cancel-sign-sub-inv72.7%

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

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

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

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

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

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

    if 1.3e-4 < ux

    1. Initial program 89.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*89.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. sub-neg89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 77.2% accurate, 1.0× speedup?

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

\\
2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\mathsf{fma}\left(2, ux, ux \cdot \left(-ux\right)\right)}\right)\right)
\end{array}
Derivation
  1. Initial program 55.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*55.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. sub-neg55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\mathsf{fma}\left(2, ux, -\color{blue}{ux \cdot ux}\right)}\right)\right) \]
    6. distribute-rgt-neg-in73.6%

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

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

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

Alternative 11: 77.3% accurate, 1.0× speedup?

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

\\
2 \cdot \left(\sqrt{\mathsf{fma}\left(2, ux, ux \cdot \left(-ux\right)\right)} \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 55.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*55.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. sub-neg55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\sqrt{\mathsf{fma}\left(2, ux, -\color{blue}{ux \cdot ux}\right)} \cdot \left(uy \cdot \pi\right)\right) \]
    5. distribute-rgt-neg-in73.7%

      \[\leadsto 2 \cdot \left(\sqrt{\mathsf{fma}\left(2, ux, \color{blue}{ux \cdot \left(-ux\right)}\right)} \cdot \left(uy \cdot \pi\right)\right) \]
  10. Simplified73.7%

    \[\leadsto 2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(2, ux, ux \cdot \left(-ux\right)\right)}} \cdot \left(uy \cdot \pi\right)\right) \]
  11. Final simplification73.7%

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

Alternative 12: 77.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ux \leq 0.00013000000035390258:\\ \;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(ux \cdot maxCos\right) + 2 \cdot ux}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(ux + \left(-1 - ux \cdot maxCos\right)\right) \cdot \left(\left(1 + ux \cdot maxCos\right) - ux\right)}\right)\\ \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (if (<= ux 0.00013000000035390258)
   (* 2.0 (* (* uy PI) (sqrt (+ (* -2.0 (* ux maxCos)) (* 2.0 ux)))))
   (*
    2.0
    (*
     (* uy PI)
     (sqrt
      (+
       1.0
       (* (+ ux (- -1.0 (* ux maxCos))) (- (+ 1.0 (* ux maxCos)) ux))))))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if (ux <= 0.00013000000035390258f) {
		tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf(((-2.0f * (ux * maxCos)) + (2.0f * ux))));
	} else {
		tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf((1.0f + ((ux + (-1.0f - (ux * maxCos))) * ((1.0f + (ux * maxCos)) - ux)))));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	tmp = Float32(0.0)
	if (ux <= Float32(0.00013000000035390258))
		tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(Float32(Float32(-2.0) * Float32(ux * maxCos)) + Float32(Float32(2.0) * ux)))));
	else
		tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(Float32(1.0) + Float32(Float32(ux + Float32(Float32(-1.0) - Float32(ux * maxCos))) * Float32(Float32(Float32(1.0) + Float32(ux * maxCos)) - ux))))));
	end
	return tmp
end
function tmp_2 = code(ux, uy, maxCos)
	tmp = single(0.0);
	if (ux <= single(0.00013000000035390258))
		tmp = single(2.0) * ((uy * single(pi)) * sqrt(((single(-2.0) * (ux * maxCos)) + (single(2.0) * ux))));
	else
		tmp = single(2.0) * ((uy * single(pi)) * sqrt((single(1.0) + ((ux + (single(-1.0) - (ux * maxCos))) * ((single(1.0) + (ux * maxCos)) - ux)))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00013000000035390258:\\
\;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(ux \cdot maxCos\right) + 2 \cdot ux}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ux < 1.3e-4

    1. Initial program 33.3%

      \[\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*33.3%

        \[\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. sub-neg33.3%

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

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in33.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3e-4 < ux

    1. Initial program 89.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*89.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. sub-neg89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.00013000000035390258:\\ \;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(ux \cdot maxCos\right) + 2 \cdot ux}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(ux + \left(-1 - ux \cdot maxCos\right)\right) \cdot \left(\left(1 + ux \cdot maxCos\right) - ux\right)}\right)\\ \end{array} \]

Alternative 13: 75.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ux \leq 0.00014000000373926014:\\ \;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(ux \cdot maxCos\right) + 2 \cdot ux}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)}\right)\\ \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (if (<= ux 0.00014000000373926014)
   (* 2.0 (* (* uy PI) (sqrt (+ (* -2.0 (* ux maxCos)) (* 2.0 ux)))))
   (* 2.0 (* (* uy PI) (sqrt (+ 1.0 (* (- 1.0 ux) (+ ux -1.0))))))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if (ux <= 0.00014000000373926014f) {
		tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf(((-2.0f * (ux * maxCos)) + (2.0f * ux))));
	} else {
		tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf((1.0f + ((1.0f - ux) * (ux + -1.0f)))));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	tmp = Float32(0.0)
	if (ux <= Float32(0.00014000000373926014))
		tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(Float32(Float32(-2.0) * Float32(ux * maxCos)) + Float32(Float32(2.0) * ux)))));
	else
		tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) - ux) * Float32(ux + Float32(-1.0)))))));
	end
	return tmp
end
function tmp_2 = code(ux, uy, maxCos)
	tmp = single(0.0);
	if (ux <= single(0.00014000000373926014))
		tmp = single(2.0) * ((uy * single(pi)) * sqrt(((single(-2.0) * (ux * maxCos)) + (single(2.0) * ux))));
	else
		tmp = single(2.0) * ((uy * single(pi)) * sqrt((single(1.0) + ((single(1.0) - ux) * (ux + single(-1.0))))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00014000000373926014:\\
\;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(ux \cdot maxCos\right) + 2 \cdot ux}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ux < 1.40000004e-4

    1. Initial program 33.5%

      \[\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*33.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.40000004e-4 < ux

    1. Initial program 89.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*89.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. sub-neg89.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ux \leq 0.00014000000373926014:\\ \;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(ux \cdot maxCos\right) + 2 \cdot ux}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)}\right)\\ \end{array} \]

Alternative 14: 65.9% accurate, 1.5× speedup?

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

\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(ux \cdot maxCos\right) + 2 \cdot ux}\right)
\end{array}
Derivation
  1. Initial program 55.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*55.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. sub-neg55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 65.9% accurate, 1.5× speedup?

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

\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)
\end{array}
Derivation
  1. Initial program 55.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*55.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. sub-neg55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 2 \cdot \left(\sqrt{\color{blue}{\left(2 - 2 \cdot maxCos\right) \cdot ux}} \cdot \left(uy \cdot \pi\right)\right) \]
  9. Final simplification61.5%

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

Alternative 16: 63.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{2 \cdot ux}\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(Float32(uy * 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(\left(uy \cdot \pi\right) \cdot \sqrt{2 \cdot ux}\right)
\end{array}
Derivation
  1. Initial program 55.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*55.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. sub-neg55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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