UniformSampleCone, x

Percentage Accurate: 57.2% → 99.0%
Time: 31.5s
Alternatives: 16
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 16 alternatives:

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

Initial Program: 57.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 0.5× speedup?

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

\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, {\left(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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. +-commutative59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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(1 - maxCos\right)}^{2} \cdot \left(ux \cdot \left(-ux\right)\right)\right)} \]

Alternative 2: 99.0% accurate, 0.8× speedup?

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

\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot {ux}^{2}\right) + ux \cdot \left(2 + maxCos \cdot -2\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.0% accurate, 0.8× speedup?

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

\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot {ux}^{2}\right) + ux \cdot \left(\left(2 - maxCos\right) - maxCos\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\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. associate--l+99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.0% accurate, 0.8× speedup?

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

\\
\sqrt{ux \cdot \left(\mathsf{fma}\left(maxCos, -2, 2\right) + \left(1 - maxCos\right) \cdot \left(ux \cdot \left(maxCos + -1\right)\right)\right)} \cdot \cos \left(\pi \cdot \left(uy \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\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. associate--l+99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.3% accurate, 1.0× speedup?

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

\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(2 \cdot ux - ux \cdot ux\right) - maxCos \cdot \left(ux \cdot \left(\left(1 - ux\right) + \left(1 - ux\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 97.7% accurate, 1.0× speedup?

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

\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(2 \cdot ux - ux \cdot ux\right) - maxCos \cdot \left(ux + ux \cdot \left(1 - ux\right)\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.5% accurate, 1.0× speedup?

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

\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(2 \cdot ux - ux \cdot ux\right) + -2 \cdot \left(maxCos \cdot ux\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 93.1% accurate, 1.0× speedup?

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

\\
\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}
\end{array}
Derivation
  1. Initial program 59.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*59.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. +-commutative59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 89.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 60.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.00380000006 < uy

    1. Initial program 55.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, 0 - \color{blue}{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}, 1\right)} \]
      11. associate-+r-55.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-55.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-sub055.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. +-commutative55.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-neg55.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-def55.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. Simplified55.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 maxCos around 0 52.2%

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

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

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

Alternative 10: 93.1% accurate, 1.0× speedup?

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

\\
\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\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. associate--l+99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 79.9% accurate, 2.7× speedup?

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

\\
\sqrt{\left(1 - maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos + -1\right)\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\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. associate--l+99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 79.4% accurate, 2.8× speedup?

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

\\
\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) + \left(ux \cdot ux\right) \cdot \left(-1 + 2 \cdot maxCos\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\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. associate--l+99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 79.1% accurate, 2.8× speedup?

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

\\
\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) + \left(ux \cdot ux\right) \cdot \left(maxCos + -1\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\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. associate--l+99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 75.8% accurate, 3.0× speedup?

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

\\
\sqrt{2 \cdot ux - ux \cdot ux}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(1 - maxCos, \left(ux \cdot ux\right) \cdot \left(maxCos + -1\right), ux \cdot \left(1 + \left(\color{blue}{\left(0 - \left(maxCos - 1\right)\right)} - maxCos\right)\right)\right)} \]
    9. associate-+l-80.2%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\color{blue}{ux \cdot \left(\left(-ux\right) + 2\right)}} \]
  11. Step-by-step derivation
    1. distribute-rgt-in77.0%

      \[\leadsto \sqrt{\color{blue}{\left(-ux\right) \cdot ux + 2 \cdot ux}} \]
  12. Applied egg-rr77.0%

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

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

Alternative 15: 75.8% accurate, 3.1× speedup?

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

\\
\sqrt{ux \cdot \left(2 - ux\right)}
\end{array}
Derivation
  1. Initial program 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(1 - maxCos, \left(ux \cdot ux\right) \cdot \left(maxCos + -1\right), ux \cdot \left(1 + \left(\color{blue}{\left(0 - \left(maxCos - 1\right)\right)} - maxCos\right)\right)\right)} \]
    9. associate-+l-80.2%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\color{blue}{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
  12. Step-by-step derivation
    1. mul-1-neg77.0%

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

      \[\leadsto \sqrt{\left(-\color{blue}{ux \cdot ux}\right) + 2 \cdot ux} \]
    3. distribute-lft-neg-out77.0%

      \[\leadsto \sqrt{\color{blue}{\left(-ux\right) \cdot ux} + 2 \cdot ux} \]
    4. distribute-rgt-out76.9%

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(\left(-ux\right) + 2\right)}} \]
    5. +-commutative76.9%

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

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

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

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

Alternative 16: 62.2% 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 59.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*59.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-neg59.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. +-commutative59.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-in59.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-def59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(1 - maxCos, \left(ux \cdot ux\right) \cdot \left(maxCos + -1\right), ux \cdot \left(1 + \left(\color{blue}{\left(0 - \left(maxCos - 1\right)\right)} - maxCos\right)\right)\right)} \]
    9. associate-+l-80.2%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\color{blue}{2 \cdot ux}} \]
  12. Step-by-step derivation
    1. *-commutative61.4%

      \[\leadsto \sqrt{\color{blue}{ux \cdot 2}} \]
  13. Simplified61.4%

    \[\leadsto \sqrt{\color{blue}{ux \cdot 2}} \]
  14. Final simplification61.4%

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

Reproduce

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