UniformSampleCone, x

Percentage Accurate: 57.8% → 99.0%
Time: 13.8s
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.8% 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: 99.0% accurate, 0.5× speedup?

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

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

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

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

      \[\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. +-commutative55.6%

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

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

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

      \[\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-55.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-def55.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-sub055.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. +-commutative55.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-55.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(\left(ux \cdot maxCos + 1\right) - ux\right)}, 1\right)} \]
    12. associate--r-55.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}{\left(0 - \left(ux \cdot maxCos + 1\right)\right) + ux}, 1\right)} \]
    13. neg-sub055.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}{\left(-\left(ux \cdot maxCos + 1\right)\right)} + ux, 1\right)} \]
    14. +-commutative55.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}{ux + \left(-\left(ux \cdot maxCos + 1\right)\right)}, 1\right)} \]
    15. sub-neg55.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}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
    16. fma-def55.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
  3. Simplified55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.0% accurate, 0.8× speedup?

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

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

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

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

      \[\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. +-commutative55.6%

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

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

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

      \[\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-55.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-def55.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-sub055.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. +-commutative55.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-55.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(\left(ux \cdot maxCos + 1\right) - ux\right)}, 1\right)} \]
    12. associate--r-55.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}{\left(0 - \left(ux \cdot maxCos + 1\right)\right) + ux}, 1\right)} \]
    13. neg-sub055.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}{\left(-\left(ux \cdot maxCos + 1\right)\right)} + ux, 1\right)} \]
    14. +-commutative55.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}{ux + \left(-\left(ux \cdot maxCos + 1\right)\right)}, 1\right)} \]
    15. sub-neg55.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}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
    16. fma-def55.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
  3. Simplified55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.0% accurate, 0.8× speedup?

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

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

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

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

      \[\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. +-commutative55.6%

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

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

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

      \[\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-55.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-def55.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-sub055.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. +-commutative55.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-55.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(\left(ux \cdot maxCos + 1\right) - ux\right)}, 1\right)} \]
    12. associate--r-55.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}{\left(0 - \left(ux \cdot maxCos + 1\right)\right) + ux}, 1\right)} \]
    13. neg-sub055.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}{\left(-\left(ux \cdot maxCos + 1\right)\right)} + ux, 1\right)} \]
    14. +-commutative55.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}{ux + \left(-\left(ux \cdot maxCos + 1\right)\right)}, 1\right)} \]
    15. sub-neg55.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}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
    16. fma-def55.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
  3. Simplified55.6%

    \[\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 -inf 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 90.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 60.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.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. +-commutative60.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-59.9%

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

        \[\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.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}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
      10. +-commutative60.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(ux \cdot maxCos + \left(1 - ux\right)\right)}, 1\right)} \]
      11. associate-+r-59.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(2 - 2 \cdot maxCos, ux, \left(maxCos - 1\right) \cdot \left(\left(1 - maxCos\right) \cdot {ux}^{2}\right)\right)}} \]
      2. cancel-sign-sub-inv97.8%

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

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

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

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

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

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

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

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

    if 5.09999983e-4 < uy

    1. Initial program 48.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 96.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 55.8%

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

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

        \[\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. +-commutative55.8%

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

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

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

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

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

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

        \[\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. +-commutative55.8%

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

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

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

        \[\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. +-commutative55.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.19999992e-5 < maxCos

    1. Initial program 54.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*54.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-neg54.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. +-commutative54.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-in54.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-def54.7%

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

        \[\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-54.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-def54.8%

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

        \[\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. +-commutative54.8%

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

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

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

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

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

        \[\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-def53.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
    3. Simplified53.3%

      \[\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 97.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. +-commutative97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 80.1% accurate, 1.5× speedup?

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

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

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

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

      \[\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. +-commutative55.6%

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

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

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

      \[\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-55.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-def55.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-sub055.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. +-commutative55.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-55.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(\left(ux \cdot maxCos + 1\right) - ux\right)}, 1\right)} \]
    12. associate--r-55.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}{\left(0 - \left(ux \cdot maxCos + 1\right)\right) + ux}, 1\right)} \]
    13. neg-sub055.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}{\left(-\left(ux \cdot maxCos + 1\right)\right)} + ux, 1\right)} \]
    14. +-commutative55.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}{ux + \left(-\left(ux \cdot maxCos + 1\right)\right)}, 1\right)} \]
    15. sub-neg55.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}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
    16. fma-def55.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
  3. Simplified55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(2 - 2 \cdot maxCos, ux, \left(maxCos - 1\right) \cdot \left(\left(1 - maxCos\right) \cdot {ux}^{2}\right)\right)}} \]
    2. cancel-sign-sub-inv76.3%

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

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

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

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

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

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

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

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

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

Alternative 7: 80.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \sqrt{\left(maxCos + -1\right) \cdot \left(\left(1 - maxCos\right) \cdot \left(ux \cdot ux\right)\right) + ux \cdot \left(2 + maxCos \cdot -2\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt
  (+
   (* (+ maxCos -1.0) (* (- 1.0 maxCos) (* ux ux)))
   (* ux (+ 2.0 (* maxCos -2.0))))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((((maxCos + -1.0f) * ((1.0f - maxCos) * (ux * ux))) + (ux * (2.0f + (maxCos * -2.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((((maxcos + (-1.0e0)) * ((1.0e0 - maxcos) * (ux * ux))) + (ux * (2.0e0 + (maxcos * (-2.0e0))))))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(ux * ux))) + Float32(ux * Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0))))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((((maxCos + single(-1.0)) * ((single(1.0) - maxCos) * (ux * ux))) + (ux * (single(2.0) + (maxCos * single(-2.0))))));
end
\begin{array}{l}

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

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

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

      \[\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. +-commutative55.6%

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

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

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

      \[\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-55.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-def55.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-sub055.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. +-commutative55.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-55.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(\left(ux \cdot maxCos + 1\right) - ux\right)}, 1\right)} \]
    12. associate--r-55.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}{\left(0 - \left(ux \cdot maxCos + 1\right)\right) + ux}, 1\right)} \]
    13. neg-sub055.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}{\left(-\left(ux \cdot maxCos + 1\right)\right)} + ux, 1\right)} \]
    14. +-commutative55.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}{ux + \left(-\left(ux \cdot maxCos + 1\right)\right)}, 1\right)} \]
    15. sub-neg55.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}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
    16. fma-def55.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
  3. Simplified55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(2 - 2 \cdot maxCos, ux, \left(maxCos - 1\right) \cdot \left(\left(1 - maxCos\right) \cdot {ux}^{2}\right)\right)}} \]
    2. cancel-sign-sub-inv76.3%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(2 + -2 \cdot maxCos, ux, \left(maxCos + -1\right) \cdot \left(ux \cdot \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right)}} \]
  12. Step-by-step derivation
    1. fma-udef76.3%

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + \left(maxCos + -1\right) \cdot \color{blue}{\left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right)}} \]
  13. Applied egg-rr76.3%

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

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

Alternative 8: 64.5% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt (* ux (+ 2.0 (* maxCos -2.0)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux * (2.0f + (maxCos * -2.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((ux * (2.0e0 + (maxcos * (-2.0e0)))))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(ux * Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0)))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((ux * (single(2.0) + (maxCos * single(-2.0)))));
end
\begin{array}{l}

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

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

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

      \[\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. +-commutative55.6%

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

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

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

      \[\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-55.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-def55.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-sub055.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. +-commutative55.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-55.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(\left(ux \cdot maxCos + 1\right) - ux\right)}, 1\right)} \]
    12. associate--r-55.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}{\left(0 - \left(ux \cdot maxCos + 1\right)\right) + ux}, 1\right)} \]
    13. neg-sub055.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}{\left(-\left(ux \cdot maxCos + 1\right)\right)} + ux, 1\right)} \]
    14. +-commutative55.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}{ux + \left(-\left(ux \cdot maxCos + 1\right)\right)}, 1\right)} \]
    15. sub-neg55.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}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
    16. fma-def55.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
  3. Simplified55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\left(1 - 2 \cdot maxCos\right) \cdot ux} + ux} \]
    2. distribute-lft1-in60.1%

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

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

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

      \[\leadsto \sqrt{\left(\color{blue}{2} - 2 \cdot maxCos\right) \cdot ux} \]
    6. cancel-sign-sub-inv60.0%

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

      \[\leadsto \sqrt{\left(2 + \color{blue}{-2} \cdot maxCos\right) \cdot ux} \]
  11. Simplified60.0%

    \[\leadsto \color{blue}{\sqrt{\left(2 + -2 \cdot maxCos\right) \cdot ux}} \]
  12. Final simplification60.0%

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

Alternative 9: 75.7% 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 55.6%

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

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

      \[\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. +-commutative55.6%

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

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

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

      \[\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-55.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-def55.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-sub055.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. +-commutative55.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-55.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(\left(ux \cdot maxCos + 1\right) - ux\right)}, 1\right)} \]
    12. associate--r-55.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}{\left(0 - \left(ux \cdot maxCos + 1\right)\right) + ux}, 1\right)} \]
    13. neg-sub055.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}{\left(-\left(ux \cdot maxCos + 1\right)\right)} + ux, 1\right)} \]
    14. +-commutative55.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}{ux + \left(-\left(ux \cdot maxCos + 1\right)\right)}, 1\right)} \]
    15. sub-neg55.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}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
    16. fma-def55.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
  3. Simplified55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(2 - 2 \cdot maxCos, ux, \left(maxCos - 1\right) \cdot \left(\left(1 - maxCos\right) \cdot {ux}^{2}\right)\right)}} \]
    2. cancel-sign-sub-inv76.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{2 \cdot ux - \color{blue}{ux \cdot ux}} \]
  14. Simplified72.2%

    \[\leadsto \sqrt{\color{blue}{2 \cdot ux - ux \cdot ux}} \]
  15. Final simplification72.2%

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

Alternative 10: 61.8% accurate, 3.1× speedup?

\[\begin{array}{l} \\ \sqrt{2 \cdot ux} \end{array} \]
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* 2.0 ux)))
float code(float ux, float uy, float maxCos) {
	return sqrtf((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((2.0e0 * ux))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(2.0) * ux))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((single(2.0) * ux));
end
\begin{array}{l}

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

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

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

      \[\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. +-commutative55.6%

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

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

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

      \[\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-55.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-def55.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-sub055.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. +-commutative55.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-55.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(\left(ux \cdot maxCos + 1\right) - ux\right)}, 1\right)} \]
    12. associate--r-55.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}{\left(0 - \left(ux \cdot maxCos + 1\right)\right) + ux}, 1\right)} \]
    13. neg-sub055.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}{\left(-\left(ux \cdot maxCos + 1\right)\right)} + ux, 1\right)} \]
    14. +-commutative55.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}{ux + \left(-\left(ux \cdot maxCos + 1\right)\right)}, 1\right)} \]
    15. sub-neg55.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}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
    16. fma-def55.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, ux - \color{blue}{\mathsf{fma}\left(ux, maxCos, 1\right)}, 1\right)} \]
  3. Simplified55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\left(1 - 2 \cdot maxCos\right) \cdot ux} + ux} \]
    2. distribute-lft1-in60.1%

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

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

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

      \[\leadsto \sqrt{\left(\color{blue}{2} - 2 \cdot maxCos\right) \cdot ux} \]
    6. cancel-sign-sub-inv60.0%

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

      \[\leadsto \sqrt{\left(2 + \color{blue}{-2} \cdot maxCos\right) \cdot ux} \]
  11. Simplified60.0%

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

    \[\leadsto \sqrt{\color{blue}{2 \cdot ux}} \]
  13. Final simplification57.5%

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

Reproduce

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