UniformSampleCone, x

Percentage Accurate: 57.2% → 99.5%
Time: 25.9s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 57.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \langle \left( \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, -1 + \left(ux - ux \cdot maxCos\right), 1\right)} \right)_{\text{binary64}} \rangle_{\text{binary32}} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (cast
  (!
   :precision
   binary64
   (*
    (cos (* uy (* 2.0 PI)))
    (sqrt
     (fma (- (fma ux maxCos 1.0) ux) (+ -1.0 (- ux (* ux maxCos))) 1.0))))))
float code(float ux, float uy, float maxCos) {
	double tmp = cos((((double) uy) * (2.0 * ((double) M_PI)))) * sqrt(fma((fma(ux, maxCos, 1.0) - ((double) ux)), (-1.0 + (((double) ux) - (((double) ux) * ((double) maxCos)))), 1.0));
	return (float) tmp;
}
function code(ux, uy, maxCos)
	tmp = Float64(cos(Float64(Float64(uy) * Float64(2.0 * pi))) * sqrt(fma(Float64(fma(ux, maxCos, 1.0) - Float64(ux)), Float64(-1.0 + Float64(Float64(ux) - Float64(Float64(ux) * Float64(maxCos)))), 1.0)))
	return Float32(tmp)
end
\begin{array}{l}

\\
\langle \left( \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, -1 + \left(ux - ux \cdot maxCos\right), 1\right)} \right)_{\text{binary64}} \rangle_{\text{binary32}}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\langle \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, -1 + \left(ux - ux \cdot maxCos\right), 1\right)} \rangle_{\text{binary64}} \]
  2. Final simplification99.5%

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

Alternative 2: 99.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \langle \left( \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}} \right)_{\text{binary64}} \rangle_{\text{binary32}} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (cast
  (!
   :precision
   binary64
   (*
    (cos (* 2.0 (* uy PI)))
    (sqrt (- 1.0 (pow (- (fma ux maxCos 1.0) ux) 2.0)))))))
float code(float ux, float uy, float maxCos) {
	double tmp = cos((2.0 * (((double) uy) * ((double) M_PI)))) * sqrt((1.0 - pow((fma(ux, maxCos, 1.0) - ((double) ux)), 2.0)));
	return (float) tmp;
}
function code(ux, uy, maxCos)
	tmp = Float64(cos(Float64(2.0 * Float64(Float64(uy) * pi))) * sqrt(Float64(1.0 - (Float64(fma(ux, maxCos, 1.0) - Float64(ux)) ^ 2.0))))
	return Float32(tmp)
end
\begin{array}{l}

\\
\langle \left( \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}} \right)_{\text{binary64}} \rangle_{\text{binary32}}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 - \mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \mathsf{fma}\left(ux, maxCos, 1 - ux\right)} \rangle_{\text{binary64}} \]
  2. Step-by-step derivation
    1. sub-neg99.5%

      \[\leadsto \langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 + \left(-\mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \mathsf{fma}\left(ux, maxCos, 1 - ux\right)\right)} \rangle_{\text{binary64}} \]
    2. pow299.5%

      \[\leadsto \langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 + \left(-{\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right)\right)}^{2}\right)} \rangle_{\text{binary64}} \]
    3. fma-udef99.5%

      \[\leadsto \langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 + \left(-{\left(ux \cdot maxCos + \left(1 - ux\right)\right)}^{2}\right)} \rangle_{\text{binary64}} \]
    4. associate-+r-99.5%

      \[\leadsto \langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 + \left(-{\left(\left(ux \cdot maxCos + 1\right) - ux\right)}^{2}\right)} \rangle_{\text{binary64}} \]
    5. fma-udef99.5%

      \[\leadsto \langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 + \left(-{\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}\right)} \rangle_{\text{binary64}} \]
  3. Applied egg-rr99.5%

    \[\leadsto \langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 + \left(-{\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}\right)} \rangle_{\text{binary64}} \]
  4. Step-by-step derivation
    1. unsub-neg99.5%

      \[\leadsto \langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}} \rangle_{\text{binary64}} \]
  5. Simplified99.5%

    \[\leadsto \langle \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}} \rangle_{\text{binary64}} \]
  6. Final simplification99.5%

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

Alternative 3: 99.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \langle \left( \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}} \right)_{\text{binary64}} \rangle_{\text{binary32}} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (cos (* PI (* uy 2.0)))
  (cast
   (!
    :precision
    binary64
    (sqrt (- 1.0 (pow (- (fma ux maxCos 1.0) ux) 2.0)))))))
float code(float ux, float uy, float maxCos) {
	double tmp = sqrt((1.0 - pow((fma(ux, maxCos, 1.0) - ((double) ux)), 2.0)));
	return cosf((((float) M_PI) * (uy * 2.0f))) * ((float) tmp);
}
function code(ux, uy, maxCos)
	tmp = sqrt(Float64(1.0 - (Float64(fma(ux, maxCos, 1.0) - Float64(ux)) ^ 2.0)))
	return Float32(cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * Float32(tmp))
end
\begin{array}{l}

\\
\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \langle \left( \sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}} \right)_{\text{binary64}} \rangle_{\text{binary32}}
\end{array}
Derivation
  1. Initial program 58.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. rewrite-binary32/binary6499.3%

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \langle \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \rangle_{\text{binary64}}} \]
  3. Applied rewrite-once99.3%

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{\langle \color{blue}{\sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \rangle_{\text{binary64}}} \]
  4. Step-by-step derivation
    1. +-commutative99.3%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \langle \sqrt{1 - \left(ux \cdot maxCos + \left(1 - ux\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \rangle_{\text{binary64}} \]
    2. associate-+r-99.3%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \langle \sqrt{1 - \left(\left(ux \cdot maxCos + 1\right) - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \rangle_{\text{binary64}} \]
    3. fma-udef99.3%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \langle \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \rangle_{\text{binary64}} \]
    4. +-commutative99.3%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \langle \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(ux \cdot maxCos + \left(1 - ux\right)\right)} \rangle_{\text{binary64}} \]
    5. associate-+r-99.3%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \langle \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\left(ux \cdot maxCos + 1\right) - ux\right)} \rangle_{\text{binary64}} \]
    6. fma-udef99.3%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \langle \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)} \rangle_{\text{binary64}} \]
  5. Simplified99.3%

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{\langle \color{blue}{\sqrt{1 - {\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}^{2}}} \rangle_{\text{binary64}}} \]
  6. Final simplification99.3%

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

Alternative 4: 99.0% accurate, 0.5× speedup?

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in ux around 0 99.2%

    \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.0% accurate, 0.8× speedup?

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in ux around 0 99.2%

    \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 90.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0013000000035390258:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, \left(ux \cdot ux\right) \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{ux \cdot \left(\left(2 - maxCos\right) - maxCos\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy 2) < 0.0013

    1. Initial program 59.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*59.1%

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

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

        \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in59.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-def59.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. +-commutative59.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-59.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0013 < (*.f32 uy 2)

    1. Initial program 57.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.0013000000035390258:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, \left(ux \cdot ux\right) \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{ux \cdot \left(\left(2 - maxCos\right) - maxCos\right)}\\ \end{array} \]

Alternative 7: 96.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy 2) < 9.50000031e-5

    1. Initial program 59.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.50000031e-5 < (*.f32 uy 2)

    1. Initial program 57.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
    4. Taylor expanded in ux around 0 98.5%

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{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-def98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 89.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.0013000000035390258:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, \left(ux \cdot ux\right) \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.0013000000035390258)
   (sqrt
    (fma
     ux
     (+ 2.0 (* maxCos -2.0))
     (* (* ux ux) (* (- 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.0013000000035390258f) {
		tmp = sqrtf(fmaf(ux, (2.0f + (maxCos * -2.0f)), ((ux * ux) * ((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.0013000000035390258))
		tmp = sqrt(fma(ux, Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0))), Float32(Float32(ux * ux) * 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
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0013000000035390258:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, \left(ux \cdot ux\right) \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.0013

    1. Initial program 59.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*59.1%

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

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

        \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in59.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-def59.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. +-commutative59.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-59.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0013 < (*.f32 uy 2)

    1. Initial program 57.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.0013000000035390258:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, \left(ux \cdot ux\right) \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 9: 79.7% accurate, 1.5× speedup?

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

\\
\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, \left(ux \cdot ux\right) \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 58.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*58.6%

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in ux around 0 99.2%

    \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 64.7% 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 58.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*58.6%

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in uy around 0 51.7%

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 + \color{blue}{\frac{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}{-1 - \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    8. clear-num51.7%

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

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

      \[\leadsto \sqrt{1 + \frac{1}{\frac{\color{blue}{\left(-1 - ux\right) + maxCos \cdot ux}}{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    11. *-commutative51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 75.4% accurate, 3.0× speedup?

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

\\
\sqrt{\left(ux + ux\right) - ux \cdot ux}
\end{array}
Derivation
  1. Initial program 58.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*58.6%

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in uy around 0 51.7%

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 + \color{blue}{\frac{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}{-1 - \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    8. clear-num51.7%

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

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

      \[\leadsto \sqrt{1 + \frac{1}{\frac{\color{blue}{\left(-1 - ux\right) + maxCos \cdot ux}}{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    11. *-commutative51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 25.5% accurate, 3.1× speedup?

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

\\
\sqrt{ux \cdot 0.25}
\end{array}
Derivation
  1. Initial program 58.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*58.6%

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in uy around 0 51.7%

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 + \color{blue}{\frac{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}{-1 - \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    8. clear-num51.7%

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

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

      \[\leadsto \sqrt{1 + \frac{1}{\frac{\color{blue}{\left(-1 - ux\right) + maxCos \cdot ux}}{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    11. *-commutative51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{ux \cdot \color{blue}{0.25}} \]
  11. Final simplification25.4%

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

Alternative 13: 27.3% accurate, 3.1× speedup?

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

\\
\sqrt{ux \cdot 0.5}
\end{array}
Derivation
  1. Initial program 58.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*58.6%

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in uy around 0 51.7%

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 + \color{blue}{\frac{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}{-1 - \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    8. clear-num51.7%

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

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

      \[\leadsto \sqrt{1 + \frac{1}{\frac{\color{blue}{\left(-1 - ux\right) + maxCos \cdot ux}}{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    11. *-commutative51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{ux \cdot \color{blue}{0.5}} \]
  11. Final simplification27.1%

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

Alternative 14: 62.1% accurate, 3.1× speedup?

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

\\
\sqrt{ux + ux}
\end{array}
Derivation
  1. Initial program 58.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*58.6%

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in uy around 0 51.7%

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 + \color{blue}{\frac{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}{-1 - \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    8. clear-num51.7%

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

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

      \[\leadsto \sqrt{1 + \frac{1}{\frac{\color{blue}{\left(-1 - ux\right) + maxCos \cdot ux}}{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    11. *-commutative51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\color{blue}{2 \cdot ux}} \]
  11. Step-by-step derivation
    1. count-263.5%

      \[\leadsto \sqrt{\color{blue}{ux + ux}} \]
  12. Simplified63.5%

    \[\leadsto \sqrt{\color{blue}{ux + ux}} \]
  13. Final simplification63.5%

    \[\leadsto \sqrt{ux + ux} \]

Alternative 15: 4.5% accurate, 107.3× speedup?

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

\\
ux \cdot -8
\end{array}
Derivation
  1. Initial program 58.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*58.6%

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.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-def58.5%

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux, \left(\color{blue}{-1} + ux\right) - ux \cdot maxCos, 1\right)} \]
    14. associate-+r-58.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)} \]
  3. Simplified58.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, -1 + \left(ux - ux \cdot maxCos\right), 1\right)}} \]
  4. Taylor expanded in uy around 0 51.7%

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 + \color{blue}{\frac{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}{-1 - \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    8. clear-num51.7%

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

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

      \[\leadsto \sqrt{1 + \frac{1}{\frac{\color{blue}{\left(-1 - ux\right) + maxCos \cdot ux}}{-1 \cdot -1 - \left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}} \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)} \]
    11. *-commutative51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-8 \cdot ux} \]
  11. Step-by-step derivation
    1. *-commutative4.4%

      \[\leadsto \color{blue}{ux \cdot -8} \]
  12. Simplified4.4%

    \[\leadsto \color{blue}{ux \cdot -8} \]
  13. Final simplification4.4%

    \[\leadsto ux \cdot -8 \]

Reproduce

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