UniformSampleCone, x

Percentage Accurate: 57.7% → 98.9%
Time: 15.3s
Alternatives: 10
Speedup: 3.1×

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\\ \cos \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))))
   (* (cos (* (* 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 cosf(((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(cos(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 = cos(((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\\
\cos \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 10 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.7% accurate, 1.0× speedup?

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

Alternative 1: 98.9% accurate, 0.6× speedup?

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

\\
\cos \log \left(e^{uy \cdot \left(\pi \cdot 2\right)}\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(ux \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 58.2%

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

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

      \[\leadsto \cos \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. +-commutative58.2%

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

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.3%

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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-sub058.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.2%

      \[\leadsto \cos \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-58.2%

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

      \[\leadsto \cos \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. +-commutative58.2%

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

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

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

    \[\leadsto \color{blue}{\cos \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.9%

    \[\leadsto \cos \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. fma-def98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)\right)} \]
    13. unpow1/293.5%

      \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{{\left(\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + -2 \cdot maxCos\right)\right)\right)}^{0.5}} \]
  11. Simplified99.0%

    \[\leadsto \color{blue}{\cos \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(ux \cdot \left(2 + \left(maxCos + -1\right) \cdot ux\right)\right)}} \]
  12. Step-by-step derivation
    1. add-log-exp99.1%

      \[\leadsto \cos \color{blue}{\log \left(e^{uy \cdot \left(\pi \cdot 2\right)}\right)} \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(ux \cdot \left(2 + \left(maxCos + -1\right) \cdot ux\right)\right)} \]
  13. Applied egg-rr99.1%

    \[\leadsto \cos \color{blue}{\log \left(e^{uy \cdot \left(\pi \cdot 2\right)}\right)} \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(ux \cdot \left(2 + \left(maxCos + -1\right) \cdot ux\right)\right)} \]
  14. Final simplification99.1%

    \[\leadsto \cos \log \left(e^{uy \cdot \left(\pi \cdot 2\right)}\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(ux \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)} \]

Alternative 2: 98.9% accurate, 1.0× speedup?

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

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

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

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

      \[\leadsto \cos \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. +-commutative58.2%

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

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.3%

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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-sub058.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.2%

      \[\leadsto \cos \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-58.2%

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

      \[\leadsto \cos \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. +-commutative58.2%

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

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

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

    \[\leadsto \color{blue}{\cos \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.9%

    \[\leadsto \cos \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. fma-def98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)\right)} \]
    13. unpow1/293.5%

      \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{{\left(\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + -2 \cdot maxCos\right)\right)\right)}^{0.5}} \]
  11. Simplified99.0%

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

    \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(\left(2 + \left(maxCos - 1\right) \cdot ux\right) \cdot ux\right)}} \]
  13. Step-by-step derivation
    1. *-commutative99.0%

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

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

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

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

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

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

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

      \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(2 \cdot ux + \color{blue}{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot ux}\right)} \]
    9. distribute-rgt-in99.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)}} \]
  15. Final simplification99.0%

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

Alternative 3: 97.4% accurate, 1.0× speedup?

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

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

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

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

      \[\leadsto \cos \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. +-commutative58.2%

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

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.3%

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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-sub058.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.2%

      \[\leadsto \cos \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-58.2%

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

      \[\leadsto \cos \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. +-commutative58.2%

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

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

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

    \[\leadsto \color{blue}{\cos \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.9%

    \[\leadsto \cos \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. fma-def98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)\right)} \]
    13. unpow1/293.5%

      \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{{\left(\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + -2 \cdot maxCos\right)\right)\right)}^{0.5}} \]
  11. Simplified99.0%

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

    \[\leadsto \cos \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \color{blue}{\left(\left(-1 \cdot ux + 2\right) \cdot ux\right)}} \]
  13. Step-by-step derivation
    1. neg-mul-197.4%

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

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

      \[\leadsto \cos \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(\color{blue}{\left(2 - ux\right)} \cdot ux\right)} \]
    4. *-commutative97.4%

      \[\leadsto \cos \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \color{blue}{\left(ux \cdot \left(2 - ux\right)\right)}} \]
  14. Simplified97.4%

    \[\leadsto \cos \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \color{blue}{\left(ux \cdot \left(2 - ux\right)\right)}} \]
  15. Final simplification97.4%

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

Alternative 4: 95.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 58.0%

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

        \[\leadsto \cos \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-neg58.0%

        \[\leadsto \cos \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. +-commutative58.0%

        \[\leadsto \cos \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-in58.0%

        \[\leadsto \cos \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-def58.1%

        \[\leadsto \cos \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. +-commutative58.1%

        \[\leadsto \cos \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-58.1%

        \[\leadsto \cos \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-def58.1%

        \[\leadsto \cos \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-sub058.1%

        \[\leadsto \cos \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. +-commutative58.1%

        \[\leadsto \cos \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-58.0%

        \[\leadsto \cos \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-58.0%

        \[\leadsto \cos \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-sub058.0%

        \[\leadsto \cos \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. +-commutative58.0%

        \[\leadsto \cos \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-neg58.0%

        \[\leadsto \cos \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-def58.0%

        \[\leadsto \cos \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. Simplified58.0%

      \[\leadsto \color{blue}{\cos \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 99.0%

      \[\leadsto \cos \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. fma-def99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(1 - maxCos, \left(maxCos - 1\right) \cdot {ux}^{2}, ux \cdot \left(2 - 2 \cdot maxCos\right)\right)}} \]
      8. sub-neg93.0%

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

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

        \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \color{blue}{\left(ux \cdot ux\right)}, ux \cdot \left(2 - 2 \cdot maxCos\right)\right)} \]
      11. cancel-sign-sub-inv93.0%

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

        \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)\right)} \]
      13. unpow1/293.0%

        \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{{\left(\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + -2 \cdot maxCos\right)\right)\right)}^{0.5}} \]
    11. Simplified99.0%

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

      \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(-1 \cdot ux + 2\right) \cdot ux}} \]
    13. Step-by-step derivation
      1. neg-mul-197.8%

        \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(\color{blue}{\left(-ux\right)} + 2\right) \cdot ux} \]
      2. +-commutative97.8%

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

        \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(2 - ux\right)} \cdot ux} \]
      4. *-commutative97.8%

        \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \]
    14. Simplified97.8%

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

    if 1.90000006e-4 < maxCos

    1. Initial program 60.1%

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

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

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

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

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

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

        \[\leadsto \cos \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.6%

        \[\leadsto \cos \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.6%

        \[\leadsto \cos \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.6%

        \[\leadsto \cos \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.6%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos \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.1%

      \[\leadsto \cos \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. fma-def98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right)} + ux \cdot \left(2 - 2 \cdot maxCos\right)} \]
      2. cancel-sign-sub-inv87.7%

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

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

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

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + ux \cdot \left(2 \cdot 1 + \color{blue}{\left(-2\right)} \cdot maxCos\right)} \]
      6. distribute-lft-neg-in87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + ux \cdot \left(2 \cdot 1 + \color{blue}{\left(-2 \cdot maxCos\right)}\right)} \]
      7. distribute-rgt-neg-in87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + ux \cdot \left(2 \cdot 1 + \color{blue}{2 \cdot \left(-maxCos\right)}\right)} \]
      8. distribute-lft-in87.7%

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

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + ux \cdot \left(2 \cdot \color{blue}{\left(1 - maxCos\right)}\right)} \]
      10. associate-*r*87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + \color{blue}{\left(ux \cdot 2\right) \cdot \left(1 - maxCos\right)}} \]
      11. *-commutative87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + \color{blue}{\left(2 \cdot ux\right)} \cdot \left(1 - maxCos\right)} \]
      12. sub-neg87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + \left(2 \cdot ux\right) \cdot \color{blue}{\left(1 + \left(-maxCos\right)\right)}} \]
      13. mul-1-neg87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + \left(2 \cdot ux\right) \cdot \left(1 + \color{blue}{-1 \cdot maxCos}\right)} \]
      14. associate-*r*87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + \color{blue}{2 \cdot \left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)}} \]
      15. associate-*r*87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + \color{blue}{\left(2 \cdot ux\right) \cdot \left(1 + -1 \cdot maxCos\right)}} \]
      16. mul-1-neg87.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) \cdot \left(1 - maxCos\right) + \left(2 \cdot ux\right) \cdot \left(1 + \color{blue}{\left(-maxCos\right)}\right)} \]
      17. sub-neg87.7%

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

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

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

Alternative 5: 89.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 0.00150000001

    1. Initial program 58.1%

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

        \[\leadsto \cos \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-neg58.1%

        \[\leadsto \cos \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. +-commutative58.1%

        \[\leadsto \cos \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-in58.1%

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

        \[\leadsto \cos \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. +-commutative58.2%

        \[\leadsto \cos \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-58.2%

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

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

        \[\leadsto \cos \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. +-commutative58.2%

        \[\leadsto \cos \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-58.1%

        \[\leadsto \cos \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-58.1%

        \[\leadsto \cos \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-sub058.1%

        \[\leadsto \cos \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. +-commutative58.1%

        \[\leadsto \cos \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-neg58.1%

        \[\leadsto \cos \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-def58.1%

        \[\leadsto \cos \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. Simplified58.1%

      \[\leadsto \color{blue}{\cos \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 99.3%

      \[\leadsto \cos \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. fma-def99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.00150000001 < uy

    1. Initial program 58.4%

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

        \[\leadsto \cos \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-neg58.4%

        \[\leadsto \cos \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. +-commutative58.4%

        \[\leadsto \cos \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-in58.4%

        \[\leadsto \cos \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-def58.6%

        \[\leadsto \cos \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. +-commutative58.6%

        \[\leadsto \cos \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-58.7%

        \[\leadsto \cos \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-def58.7%

        \[\leadsto \cos \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-sub058.7%

        \[\leadsto \cos \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. +-commutative58.7%

        \[\leadsto \cos \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-58.5%

        \[\leadsto \cos \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-58.5%

        \[\leadsto \cos \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-sub058.5%

        \[\leadsto \cos \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. +-commutative58.5%

        \[\leadsto \cos \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-neg58.5%

        \[\leadsto \cos \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-def58.5%

        \[\leadsto \cos \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. Simplified58.5%

      \[\leadsto \color{blue}{\cos \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 56.7%

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

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

        \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
    7. Simplified72.7%

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

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

Alternative 6: 79.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot {ux}^{2}\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt
  (+
   (* (- 1.0 maxCos) (* (+ maxCos -1.0) (pow ux 2.0)))
   (* ux (- 2.0 (* 2.0 maxCos))))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((((1.0f - maxCos) * ((maxCos + -1.0f) * powf(ux, 2.0f))) + (ux * (2.0f - (2.0f * maxCos)))));
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt((((1.0e0 - maxcos) * ((maxcos + (-1.0e0)) * (ux ** 2.0e0))) + (ux * (2.0e0 - (2.0e0 * maxcos)))))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(maxCos + Float32(-1.0)) * (ux ^ Float32(2.0)))) + Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((((single(1.0) - maxCos) * ((maxCos + single(-1.0)) * (ux ^ single(2.0)))) + (ux * (single(2.0) - (single(2.0) * maxCos)))));
end
\begin{array}{l}

\\
\sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot {ux}^{2}\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}
\end{array}
Derivation
  1. Initial program 58.2%

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

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

      \[\leadsto \cos \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. +-commutative58.2%

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

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.3%

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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-sub058.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.2%

      \[\leadsto \cos \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-58.2%

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

      \[\leadsto \cos \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. +-commutative58.2%

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

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

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

    \[\leadsto \color{blue}{\cos \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.9%

    \[\leadsto \cos \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. fma-def98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 79.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \sqrt{ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 + \left(maxCos \cdot ux - ux\right)\right)\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt (* ux (* (- 1.0 maxCos) (+ 2.0 (- (* maxCos ux) ux))))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux * ((1.0f - maxCos) * (2.0f + ((maxCos * ux) - ux)))));
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt((ux * ((1.0e0 - maxcos) * (2.0e0 + ((maxcos * ux) - ux)))))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(ux * Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(2.0) + Float32(Float32(maxCos * ux) - ux)))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((ux * ((single(1.0) - maxCos) * (single(2.0) + ((maxCos * ux) - ux)))));
end
\begin{array}{l}

\\
\sqrt{ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 + \left(maxCos \cdot ux - ux\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 58.2%

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

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

      \[\leadsto \cos \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. +-commutative58.2%

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

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.3%

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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-sub058.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.2%

      \[\leadsto \cos \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-58.2%

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

      \[\leadsto \cos \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. +-commutative58.2%

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

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

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

    \[\leadsto \color{blue}{\cos \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.9%

    \[\leadsto \cos \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. fma-def98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + \color{blue}{-2} \cdot maxCos\right)\right)} \]
    13. unpow1/293.5%

      \[\leadsto \left({\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\cos \left(uy \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{{\left(\mathsf{fma}\left(1 - maxCos, \left(maxCos + -1\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(2 + -2 \cdot maxCos\right)\right)\right)}^{0.5}} \]
  11. Simplified99.0%

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

    \[\leadsto \color{blue}{\sqrt{\left(1 - maxCos\right) \cdot \left(ux \cdot \left(2 + \left(maxCos - 1\right) \cdot ux\right)\right)}} \]
  13. Step-by-step derivation
    1. *-commutative79.3%

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

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

      \[\leadsto \sqrt{\left(\left(2 + \color{blue}{ux \cdot \left(maxCos - 1\right)}\right) \cdot ux\right) \cdot \left(1 - maxCos\right)} \]
    4. sub-neg79.3%

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

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

      \[\leadsto \sqrt{\color{blue}{\left(ux \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)} \cdot \left(1 - maxCos\right)} \]
    7. associate-*l*79.3%

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(\left(2 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(1 - maxCos\right)\right)}} \]
    8. distribute-rgt-in79.3%

      \[\leadsto \sqrt{ux \cdot \left(\left(2 + \color{blue}{\left(maxCos \cdot ux + -1 \cdot ux\right)}\right) \cdot \left(1 - maxCos\right)\right)} \]
    9. neg-mul-179.3%

      \[\leadsto \sqrt{ux \cdot \left(\left(2 + \left(maxCos \cdot ux + \color{blue}{\left(-ux\right)}\right)\right) \cdot \left(1 - maxCos\right)\right)} \]
    10. unsub-neg79.3%

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

      \[\leadsto \sqrt{ux \cdot \left(\left(2 + \left(\color{blue}{ux \cdot maxCos} - ux\right)\right) \cdot \left(1 - maxCos\right)\right)} \]
  14. Simplified79.3%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \left(\left(2 + \left(ux \cdot maxCos - ux\right)\right) \cdot \left(1 - maxCos\right)\right)}} \]
  15. Final simplification79.3%

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

Alternative 8: 75.5% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \sqrt{2 \cdot ux - ux \cdot ux} \end{array} \]
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* 2.0 ux) (* ux ux))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(((2.0f * ux) - (ux * ux)));
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt(((2.0e0 * ux) - (ux * ux)))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(Float32(2.0) * ux) - Float32(ux * ux)))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt(((single(2.0) * ux) - (ux * ux)));
end
\begin{array}{l}

\\
\sqrt{2 \cdot ux - ux \cdot ux}
\end{array}
Derivation
  1. Initial program 58.2%

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

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

      \[\leadsto \cos \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. +-commutative58.2%

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

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.3%

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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-sub058.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.2%

      \[\leadsto \cos \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-58.2%

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

      \[\leadsto \cos \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. +-commutative58.2%

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

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

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

    \[\leadsto \color{blue}{\cos \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.9%

    \[\leadsto \cos \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. fma-def98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
  8. Taylor expanded in maxCos around 0 74.9%

    \[\leadsto \color{blue}{\sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
  9. Step-by-step derivation
    1. +-commutative74.9%

      \[\leadsto \sqrt{\color{blue}{2 \cdot ux + -1 \cdot {ux}^{2}}} \]
    2. mul-1-neg74.9%

      \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(-{ux}^{2}\right)}} \]
    3. unsub-neg74.9%

      \[\leadsto \sqrt{\color{blue}{2 \cdot ux - {ux}^{2}}} \]
    4. *-commutative74.9%

      \[\leadsto \sqrt{\color{blue}{ux \cdot 2} - {ux}^{2}} \]
    5. unpow274.9%

      \[\leadsto \sqrt{ux \cdot 2 - \color{blue}{ux \cdot ux}} \]
  10. Simplified74.9%

    \[\leadsto \color{blue}{\sqrt{ux \cdot 2 - ux \cdot ux}} \]
  11. Final simplification74.9%

    \[\leadsto \sqrt{2 \cdot ux - ux \cdot ux} \]

Alternative 9: 75.5% accurate, 3.1× speedup?

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

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

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

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

      \[\leadsto \cos \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. +-commutative58.2%

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

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.3%

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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-sub058.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.2%

      \[\leadsto \cos \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-58.2%

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

      \[\leadsto \cos \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. +-commutative58.2%

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

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

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

    \[\leadsto \color{blue}{\cos \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.9%

    \[\leadsto \cos \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. fma-def98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos - 1\right) \cdot {ux}^{2}\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
  8. Taylor expanded in maxCos around 0 78.6%

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(maxCos, \mathsf{fma}\left(ux, -2, 2 \cdot \left(ux \cdot ux\right)\right), \color{blue}{2 \cdot ux - {ux}^{2}}\right)} \]
    8. *-commutative78.6%

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

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

    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(maxCos, \mathsf{fma}\left(ux, -2, 2 \cdot \left(ux \cdot ux\right)\right), ux \cdot 2 - ux \cdot ux\right)}} \]
  11. Taylor expanded in maxCos around 0 74.9%

    \[\leadsto \color{blue}{\sqrt{2 \cdot ux - {ux}^{2}}} \]
  12. Step-by-step derivation
    1. unpow274.9%

      \[\leadsto \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}} \]
    2. cancel-sign-sub-inv74.9%

      \[\leadsto \sqrt{\color{blue}{2 \cdot ux + \left(-ux\right) \cdot ux}} \]
    3. distribute-rgt-out74.8%

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 + \left(-ux\right)\right)}} \]
    4. sub-neg74.8%

      \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
  13. Simplified74.8%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 - ux\right)}} \]
  14. Final simplification74.8%

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

Alternative 10: 6.6% accurate, 3.2× speedup?

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

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

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

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

      \[\leadsto \cos \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. +-commutative58.2%

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

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.3%

      \[\leadsto \cos \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-def58.3%

      \[\leadsto \cos \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-sub058.3%

      \[\leadsto \cos \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. +-commutative58.3%

      \[\leadsto \cos \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-58.2%

      \[\leadsto \cos \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-58.2%

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

      \[\leadsto \cos \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. +-commutative58.2%

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

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

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

    \[\leadsto \color{blue}{\cos \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 49.3%

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

    \[\leadsto \sqrt{1 + \color{blue}{-1}} \]
  6. Final simplification6.6%

    \[\leadsto \sqrt{0} \]

Reproduce

?
herbie shell --seed 2023172 
(FPCore (ux uy maxCos)
  :name "UniformSampleCone, x"
  :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)))
  (* (cos (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))