UniformSampleCone, x

Percentage Accurate: 57.5% → 98.9%
Time: 15.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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 98.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

      \[\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.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-sub055.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. +-commutative55.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-54.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-54.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-sub054.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. +-commutative54.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-neg54.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-def54.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. Simplified54.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.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 51.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*51.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-neg51.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. +-commutative51.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-in51.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-def51.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. +-commutative51.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-51.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-def51.9%

        \[\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-sub051.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}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
      10. +-commutative51.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(ux \cdot maxCos + \left(1 - ux\right)\right)}, 1\right)} \]
      11. associate-+r-51.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-51.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-sub051.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. +-commutative51.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-neg51.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-def51.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. Simplified51.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 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. fma-def99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.00000014e-5 < uy

    1. Initial program 59.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 96.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 51.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*51.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-neg51.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. +-commutative51.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-in51.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-def51.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. +-commutative51.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-51.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-def51.9%

        \[\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-sub051.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}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
      10. +-commutative51.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(ux \cdot maxCos + \left(1 - ux\right)\right)}, 1\right)} \]
      11. associate-+r-51.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-51.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-sub051.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. +-commutative51.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-neg51.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-def51.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. Simplified51.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 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. fma-def99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.00000014e-5 < uy

    1. Initial program 59.2%

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

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

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

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

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

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

        \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{ux \cdot maxCos + \left(1 - ux\right)}, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)} \]
      7. associate-+r-59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 89.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 54.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
      16. fma-def54.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. Simplified54.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 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.00419999985 < uy

    1. Initial program 57.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*57.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. +-commutative57.1%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 79.6% accurate, 2.8× speedup?

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

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

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

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

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

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

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

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

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

      \[\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.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-sub055.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. +-commutative55.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-54.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-54.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-sub054.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. +-commutative54.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-neg54.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-def54.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. Simplified54.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.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\left(ux \cdot \left(2 + \color{blue}{\left(maxCos + \left(-1\right)\right)} \cdot ux\right)\right) \cdot \left(1 - maxCos\right)} \]
    10. metadata-eval80.6%

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

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

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

Alternative 6: 73.6% accurate, 2.9× speedup?

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

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

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


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

    1. Initial program 36.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. add-cube-cbrt36.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\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)}} \cdot \sqrt[3]{\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)}}\right) \cdot \sqrt[3]{\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. pow336.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\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)}}\right)}^{3}} \]
      3. associate-*r*36.6%

        \[\leadsto {\left(\sqrt[3]{\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)}}\right)}^{3} \]
      4. pow236.6%

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

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

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

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

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

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

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

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

    if 3.00000014e-4 < ux

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{ux - \left(ux \cdot maxCos + 1\right)}, 1\right)} \]
      16. fma-def88.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. Simplified88.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 uy around 0 73.0%

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

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

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

Alternative 7: 78.6% accurate, 2.9× speedup?

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

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

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

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

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

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

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

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

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

      \[\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.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-sub055.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. +-commutative55.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-54.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-54.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-sub054.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. +-commutative54.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-neg54.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-def54.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. Simplified54.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.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 64.3% accurate, 3.0× speedup?

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

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

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

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

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

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

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

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

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

      \[\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.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-sub055.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. +-commutative55.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-54.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-54.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-sub054.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. +-commutative54.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-neg54.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-def54.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. Simplified54.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 78.2%

    \[\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. Taylor expanded in uy around 0 67.0%

    \[\leadsto \color{blue}{\sqrt{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)}} \]
  6. Step-by-step derivation
    1. neg-mul-167.0%

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

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(1 - \left(maxCos - 1\right)\right)} - maxCos\right)} \]
    3. sub-neg67.0%

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

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

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

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

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

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

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

Alternative 9: 64.3% accurate, 3.0× speedup?

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

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

    \[\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. add-cube-cbrt54.8%

      \[\leadsto \color{blue}{\left(\sqrt[3]{\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)}} \cdot \sqrt[3]{\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)}}\right) \cdot \sqrt[3]{\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. pow354.8%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\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)}}\right)}^{3}} \]
    3. associate-*r*54.8%

      \[\leadsto {\left(\sqrt[3]{\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)}}\right)}^{3} \]
    4. pow254.8%

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

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

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

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

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

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

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

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

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

Alternative 10: 61.7% 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 54.9%

    \[\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. add-cube-cbrt54.8%

      \[\leadsto \color{blue}{\left(\sqrt[3]{\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)}} \cdot \sqrt[3]{\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)}}\right) \cdot \sqrt[3]{\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. pow354.8%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\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)}}\right)}^{3}} \]
    3. associate-*r*54.8%

      \[\leadsto {\left(\sqrt[3]{\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)}}\right)}^{3} \]
    4. pow254.8%

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\color{blue}{2 \cdot ux}} \]
  9. Final simplification64.6%

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

Reproduce

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