UniformSampleCone, x

Percentage Accurate: 57.1% → 99.0%
Time: 21.3s
Alternatives: 20
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 20 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.1% 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.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Taylor expanded in ux around 0 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.9% accurate, 0.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 93.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 89.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.0012000000569969416:\\ \;\;\;\;\sqrt{ux + \left(ux \cdot \left(1 - 2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\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 2.0) 0.0012000000569969416)
   (sqrt
    (+
     ux
     (+
      (* ux (- 1.0 (* 2.0 maxCos)))
      (* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0))))))
   (* (cos (* uy (* 2.0 PI))) (sqrt (* 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if ((uy * 2.0f) <= 0.0012000000569969416f) {
		tmp = sqrtf((ux + ((ux * (1.0f - (2.0f * maxCos))) + (powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f))))));
	} 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 (Float32(uy * Float32(2.0)) <= Float32(0.0012000000569969416))
		tmp = sqrt(Float32(ux + Float32(Float32(ux * Float32(Float32(1.0) - Float32(Float32(2.0) * maxCos))) + Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0)))))));
	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(2.0)) <= single(0.0012000000569969416))
		tmp = sqrt((ux + ((ux * (single(1.0) - (single(2.0) * maxCos))) + ((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (maxCos + single(-1.0)))))));
	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 \cdot 2 \leq 0.0012000000569969416:\\
\;\;\;\;\sqrt{ux + \left(ux \cdot \left(1 - 2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\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 (*.f32 uy 2) < 0.00120000006

    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. cancel-sign-sub-inv60.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)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\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)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1}} \]
      4. *-commutative60.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.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{ux + \left(\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \color{blue}{\left(ux \cdot \left(maxCos + -1\right) + 1\right)} - ux \cdot maxCos\right)} \]
      11. fma-def97.9%

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

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

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

    if 0.00120000006 < (*.f32 uy 2)

    1. Initial program 50.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*50.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. cancel-sign-sub-inv50.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)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      3. +-commutative50.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)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1}} \]
      4. *-commutative50.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-def51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 93.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 93.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 79.7% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 79.7% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\left(ux + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)\right) - maxCos \cdot ux}} \]
  8. Step-by-step derivation
    1. sub-neg80.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux + \left(\left(\left(1 - maxCos\right) \cdot \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right) \cdot ux + \color{blue}{\left(-1 \cdot maxCos\right) \cdot ux}\right)} \]
    12. distribute-rgt-in80.4%

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

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

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

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

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

Alternative 12: 79.7% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 76.1% accurate, 2.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 64.5% accurate, 3.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 75.7% accurate, 3.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Step-by-step derivation
    1. fma-udef57.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 62.1% 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 57.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Taylor expanded in uy around 0 50.7%

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

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

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

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

Alternative 17: 18.9% accurate, 53.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Taylor expanded in uy around 0 50.7%

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

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

    \[\leadsto \color{blue}{-1 \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
  7. Final simplification19.1%

    \[\leadsto ux \cdot \left(\left(-maxCos\right) - -1\right) \]

Alternative 18: 18.9% accurate, 64.4× speedup?

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

\\
ux - ux \cdot maxCos
\end{array}
Derivation
  1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Taylor expanded in uy around 0 50.7%

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

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

    \[\leadsto \color{blue}{ux + -1 \cdot \left(maxCos \cdot ux\right)} \]
  7. Final simplification19.1%

    \[\leadsto ux - ux \cdot maxCos \]

Alternative 19: 9.5% accurate, 107.3× speedup?

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

\\
ux \cdot maxCos
\end{array}
Derivation
  1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Taylor expanded in uy around 0 50.7%

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

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

    \[\leadsto \color{blue}{maxCos \cdot ux} \]
  7. Step-by-step derivation
    1. *-commutative9.4%

      \[\leadsto \color{blue}{ux \cdot maxCos} \]
  8. Simplified9.4%

    \[\leadsto \color{blue}{ux \cdot maxCos} \]
  9. Final simplification9.4%

    \[\leadsto ux \cdot maxCos \]

Alternative 20: 4.4% accurate, 161.0× speedup?

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

\\
-ux
\end{array}
Derivation
  1. Initial program 57.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{0 - \left(\left(1 - ux\right) + ux \cdot maxCos\right)}, 1\right)} \]
    10. associate-+l-57.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(1 - \left(ux - ux \cdot maxCos\right)\right)}, 1\right)} \]
    11. associate--r-57.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 - 1\right) + \left(ux - ux \cdot maxCos\right)}, 1\right)} \]
    12. metadata-eval57.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}{-1} + \left(ux - ux \cdot maxCos\right), 1\right)} \]
    13. +-commutative57.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(ux - ux \cdot maxCos\right) + -1}, 1\right)} \]
    14. *-lft-identity57.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, \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) + -1, 1\right)} \]
    15. *-commutative57.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, \left(\color{blue}{ux \cdot 1} - ux \cdot maxCos\right) + -1, 1\right)} \]
    16. distribute-lft-out--57.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 \cdot \left(1 - maxCos\right)} + -1, 1\right)} \]
  3. Simplified57.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 \cdot \left(1 - maxCos\right) + -1, 1\right)}} \]
  4. Taylor expanded in uy around 0 50.7%

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

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

    \[\leadsto \color{blue}{-1 \cdot ux} \]
  7. Step-by-step derivation
    1. mul-1-neg4.3%

      \[\leadsto \color{blue}{-ux} \]
  8. Simplified4.3%

    \[\leadsto \color{blue}{-ux} \]
  9. Final simplification4.3%

    \[\leadsto -ux \]

Reproduce

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