UniformSampleCone, x

Percentage Accurate: 57.4% → 99.2%
Time: 4.7s
Alternatives: 11
Speedup: 3.4×

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}

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 11 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.4% 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.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := maxCos \cdot ux - ux\\ \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - t\_0 \cdot t\_0} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (- (* maxCos ux) ux)))
   (*
    (sin (fma (- PI) (+ uy uy) (* PI 0.5)))
    (sqrt (- (- 0.0 (* -2.0 (- ux (* maxCos ux)))) (* t_0 t_0))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (maxCos * ux) - ux;
	return sinf(fmaf(-((float) M_PI), (uy + uy), (((float) M_PI) * 0.5f))) * sqrtf(((0.0f - (-2.0f * (ux - (maxCos * ux)))) - (t_0 * t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(maxCos * ux) - ux)
	return Float32(sin(fma(Float32(-Float32(pi)), Float32(uy + uy), Float32(Float32(pi) * Float32(0.5)))) * sqrt(Float32(Float32(Float32(0.0) - Float32(Float32(-2.0) * Float32(ux - Float32(maxCos * ux)))) - Float32(t_0 * t_0))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := maxCos \cdot ux - ux\\
\sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - t\_0 \cdot t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 57.4%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift-cos.f32N/A

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    2. lift-*.f32N/A

      \[\leadsto \cos \left(\color{blue}{\left(uy \cdot 2\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    3. *-commutativeN/A

      \[\leadsto \cos \left(\color{blue}{\left(2 \cdot uy\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    4. count-2N/A

      \[\leadsto \cos \left(\color{blue}{\left(uy + uy\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    5. lift-+.f32N/A

      \[\leadsto \cos \left(\color{blue}{\left(uy + uy\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    6. cos-neg-revN/A

      \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    7. sin-+PI/2-revN/A

      \[\leadsto \color{blue}{\sin \left(\left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    8. lower-sin.f32N/A

      \[\leadsto \color{blue}{\sin \left(\left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    9. lift-*.f32N/A

      \[\leadsto \sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(uy + uy\right) \cdot \pi}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    10. *-commutativeN/A

      \[\leadsto \sin \left(\left(\mathsf{neg}\left(\color{blue}{\pi \cdot \left(uy + uy\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    11. distribute-lft-neg-inN/A

      \[\leadsto \sin \left(\color{blue}{\left(\mathsf{neg}\left(\pi\right)\right) \cdot \left(uy + uy\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    12. lower-fma.f32N/A

      \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\mathsf{neg}\left(\pi\right), uy + uy, \frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    13. lower-neg.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\color{blue}{-\pi}, uy + uy, \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    14. lift-PI.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \frac{\color{blue}{\pi}}{2}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    15. mult-flipN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    16. metadata-evalN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \color{blue}{\frac{1}{2}}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    17. lower-*.f3299.2

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \color{blue}{\pi \cdot 0.5}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
  7. Applied rewrites99.2%

    \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
  8. Add Preprocessing

Alternative 2: 99.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := ux - maxCos \cdot ux\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot ux - ux, t\_0, t\_0 \cdot 2\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 57.4%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    2. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \color{blue}{\left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    3. fp-cancel-sub-sign-invN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) + \left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    4. +-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right) \cdot \left(maxCos \cdot ux - ux\right) + \left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
    5. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(maxCos \cdot ux - ux\right)}\right)\right) \cdot \left(maxCos \cdot ux - ux\right) + \left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right)} \]
    6. sub-negate-revN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(ux - maxCos \cdot ux\right)} \cdot \left(maxCos \cdot ux - ux\right) + \left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right)} \]
    7. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(ux - maxCos \cdot ux\right)} \cdot \left(maxCos \cdot ux - ux\right) + \left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right)} \]
    8. *-commutativeN/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(maxCos \cdot ux - ux, ux - maxCos \cdot ux, 0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
    10. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot ux - ux, ux - maxCos \cdot ux, \color{blue}{0 - -2 \cdot \left(ux - maxCos \cdot ux\right)}\right)} \]
    11. sub0-negN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot ux - ux, ux - maxCos \cdot ux, \color{blue}{\mathsf{neg}\left(-2 \cdot \left(ux - maxCos \cdot ux\right)\right)}\right)} \]
    12. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot ux - ux, ux - maxCos \cdot ux, \mathsf{neg}\left(\color{blue}{-2 \cdot \left(ux - maxCos \cdot ux\right)}\right)\right)} \]
    13. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot ux - ux, ux - maxCos \cdot ux, \mathsf{neg}\left(\color{blue}{\left(ux - maxCos \cdot ux\right) \cdot -2}\right)\right)} \]
    14. distribute-rgt-neg-inN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot ux - ux, ux - maxCos \cdot ux, \color{blue}{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{neg}\left(-2\right)\right)}\right)} \]
    15. metadata-evalN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot ux - ux, ux - maxCos \cdot ux, \left(ux - maxCos \cdot ux\right) \cdot \color{blue}{2}\right)} \]
    16. lower-*.f3299.0

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

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

Alternative 3: 99.0% accurate, 1.0× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    2. *-commutativeN/A

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

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(maxCos, ux, 2 - ux\right) \cdot \left(ux - maxCos \cdot ux\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right)} \]
  8. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(maxCos, ux, 2 - ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    2. *-commutativeN/A

      \[\leadsto \sqrt{\color{blue}{\left(ux - maxCos \cdot ux\right) \cdot \mathsf{fma}\left(maxCos, ux, 2 - ux\right)}} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    3. lift-fma.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(maxCos \cdot ux + \left(2 - ux\right)\right)}} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    4. lift-*.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\color{blue}{maxCos \cdot ux} + \left(2 - ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    5. lift--.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux + \color{blue}{\left(2 - ux\right)}\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    6. associate-+r-N/A

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

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(maxCos \cdot ux + \color{blue}{\left(1 + 1\right)}\right) - ux\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    8. associate-+r+N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\color{blue}{\left(\left(maxCos \cdot ux + 1\right) + 1\right)} - ux\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    9. lift-*.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(\left(\color{blue}{maxCos \cdot ux} + 1\right) + 1\right) - ux\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    10. lift-fma.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1\right)} + 1\right) - ux\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    11. +-commutativeN/A

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

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(1 + \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right)\right)}} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    13. lift--.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(1 + \color{blue}{\left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right)}\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    14. distribute-lft-inN/A

      \[\leadsto \sqrt{\color{blue}{\left(ux - maxCos \cdot ux\right) \cdot 1 + \left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right)}} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    15. fp-cancel-sign-sub-invN/A

      \[\leadsto \sqrt{\color{blue}{\left(ux - maxCos \cdot ux\right) \cdot 1 - \left(\mathsf{neg}\left(\left(ux - maxCos \cdot ux\right)\right)\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right)}} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    16. *-rgt-identityN/A

      \[\leadsto \sqrt{\color{blue}{\left(ux - maxCos \cdot ux\right)} - \left(\mathsf{neg}\left(\left(ux - maxCos \cdot ux\right)\right)\right) \cdot \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    17. lower--.f32N/A

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

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

Alternative 4: 98.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := ux - maxCos \cdot ux\\ \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right) \cdot \sqrt{-t\_0 \cdot \left(-2 + t\_0\right)} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (- ux (* maxCos ux))))
   (*
    (sin (fma (- PI) (+ uy uy) (* PI 0.5)))
    (sqrt (- (* t_0 (+ -2.0 t_0)))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = ux - (maxCos * ux);
	return sinf(fmaf(-((float) M_PI), (uy + uy), (((float) M_PI) * 0.5f))) * sqrtf(-(t_0 * (-2.0f + t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(ux - Float32(maxCos * ux))
	return Float32(sin(fma(Float32(-Float32(pi)), Float32(uy + uy), Float32(Float32(pi) * Float32(0.5)))) * sqrt(Float32(-Float32(t_0 * Float32(Float32(-2.0) + t_0)))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := ux - maxCos \cdot ux\\
\sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right) \cdot \sqrt{-t\_0 \cdot \left(-2 + t\_0\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 57.4%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift-cos.f32N/A

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    2. lift-*.f32N/A

      \[\leadsto \cos \left(\color{blue}{\left(uy \cdot 2\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    3. *-commutativeN/A

      \[\leadsto \cos \left(\color{blue}{\left(2 \cdot uy\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    4. count-2N/A

      \[\leadsto \cos \left(\color{blue}{\left(uy + uy\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    5. lift-+.f32N/A

      \[\leadsto \cos \left(\color{blue}{\left(uy + uy\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    6. cos-neg-revN/A

      \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    7. sin-+PI/2-revN/A

      \[\leadsto \color{blue}{\sin \left(\left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    8. lower-sin.f32N/A

      \[\leadsto \color{blue}{\sin \left(\left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    9. lift-*.f32N/A

      \[\leadsto \sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(uy + uy\right) \cdot \pi}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    10. *-commutativeN/A

      \[\leadsto \sin \left(\left(\mathsf{neg}\left(\color{blue}{\pi \cdot \left(uy + uy\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    11. distribute-lft-neg-inN/A

      \[\leadsto \sin \left(\color{blue}{\left(\mathsf{neg}\left(\pi\right)\right) \cdot \left(uy + uy\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    12. lower-fma.f32N/A

      \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\mathsf{neg}\left(\pi\right), uy + uy, \frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    13. lower-neg.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\color{blue}{-\pi}, uy + uy, \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    14. lift-PI.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \frac{\color{blue}{\pi}}{2}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    15. mult-flipN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    16. metadata-evalN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \color{blue}{\frac{1}{2}}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    17. lower-*.f3299.2

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \color{blue}{\pi \cdot 0.5}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
  7. Applied rewrites99.2%

    \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
  8. Step-by-step derivation
    1. lift--.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    2. lift--.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right)} - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    3. associate--l-N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{\color{blue}{0 - \left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)\right)}} \]
    4. sub0-negN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{\color{blue}{\mathsf{neg}\left(\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)\right)\right)}} \]
    5. lower-neg.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{\color{blue}{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)\right)}} \]
    6. lift-*.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(\color{blue}{-2 \cdot \left(ux - maxCos \cdot ux\right)} + \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)\right)} \]
    7. lift-*.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \color{blue}{\left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)} \]
    8. sqr-neg-revN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \color{blue}{\left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right)}\right)} \]
    9. lift--.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \left(\mathsf{neg}\left(\color{blue}{\left(maxCos \cdot ux - ux\right)}\right)\right) \cdot \left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right)\right)} \]
    10. sub-negate-revN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \color{blue}{\left(ux - maxCos \cdot ux\right)} \cdot \left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right)\right)} \]
    11. lift--.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \color{blue}{\left(ux - maxCos \cdot ux\right)} \cdot \left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right)\right)} \]
    12. lift--.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(maxCos \cdot ux - ux\right)}\right)\right)\right)} \]
    13. sub-negate-revN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(ux - maxCos \cdot ux\right)}\right)} \]
    14. lift--.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + \left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(ux - maxCos \cdot ux\right)}\right)} \]
    15. distribute-rgt-outN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\color{blue}{\left(ux - maxCos \cdot ux\right) \cdot \left(-2 + \left(ux - maxCos \cdot ux\right)\right)}} \]
    16. lower-*.f32N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot \frac{1}{2}\right)\right) \cdot \sqrt{-\color{blue}{\left(ux - maxCos \cdot ux\right) \cdot \left(-2 + \left(ux - maxCos \cdot ux\right)\right)}} \]
    17. lower-+.f3299.1

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

    \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right) \cdot \sqrt{\color{blue}{-\left(ux - maxCos \cdot ux\right) \cdot \left(-2 + \left(ux - maxCos \cdot ux\right)\right)}} \]
  10. Add Preprocessing

Alternative 5: 98.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-ux, maxCos, ux\right)\\
\sqrt{0 + t\_0 \cdot \left(2 - t\_0\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right)
\end{array}
\end{array}
Derivation
  1. Initial program 57.4%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift-*.f32N/A

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

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

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

    \[\leadsto \color{blue}{\sqrt{0 + \left(ux - maxCos \cdot ux\right) \cdot \left(2 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right)} \]
  6. Step-by-step derivation
    1. lift--.f32N/A

      \[\leadsto \sqrt{0 + \color{blue}{\left(ux - maxCos \cdot ux\right)} \cdot \left(2 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    2. sub-flipN/A

      \[\leadsto \sqrt{0 + \color{blue}{\left(ux + \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right)} \cdot \left(2 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    3. +-commutativeN/A

      \[\leadsto \sqrt{0 + \color{blue}{\left(\left(\mathsf{neg}\left(maxCos \cdot ux\right)\right) + ux\right)} \cdot \left(2 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    4. lift-*.f32N/A

      \[\leadsto \sqrt{0 + \left(\left(\mathsf{neg}\left(\color{blue}{maxCos \cdot ux}\right)\right) + ux\right) \cdot \left(2 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    5. *-commutativeN/A

      \[\leadsto \sqrt{0 + \left(\left(\mathsf{neg}\left(\color{blue}{ux \cdot maxCos}\right)\right) + ux\right) \cdot \left(2 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \sqrt{0 + \left(\color{blue}{\left(\mathsf{neg}\left(ux\right)\right) \cdot maxCos} + ux\right) \cdot \left(2 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    7. lower-fma.f32N/A

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

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

    \[\leadsto \sqrt{0 + \color{blue}{\mathsf{fma}\left(-ux, maxCos, ux\right)} \cdot \left(2 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
  8. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \sqrt{0 + \mathsf{fma}\left(-ux, maxCos, ux\right) \cdot \left(2 - \color{blue}{\left(\left(\mathsf{neg}\left(maxCos \cdot ux\right)\right) + ux\right)}\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    4. lift-*.f32N/A

      \[\leadsto \sqrt{0 + \mathsf{fma}\left(-ux, maxCos, ux\right) \cdot \left(2 - \left(\left(\mathsf{neg}\left(\color{blue}{maxCos \cdot ux}\right)\right) + ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    5. *-commutativeN/A

      \[\leadsto \sqrt{0 + \mathsf{fma}\left(-ux, maxCos, ux\right) \cdot \left(2 - \left(\left(\mathsf{neg}\left(\color{blue}{ux \cdot maxCos}\right)\right) + ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \sqrt{0 + \mathsf{fma}\left(-ux, maxCos, ux\right) \cdot \left(2 - \left(\color{blue}{\left(\mathsf{neg}\left(ux\right)\right) \cdot maxCos} + ux\right)\right)} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    7. lower-fma.f32N/A

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

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

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

Alternative 6: 98.9% accurate, 1.1× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    2. *-commutativeN/A

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

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

Alternative 7: 98.9% accurate, 1.1× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    2. *-commutativeN/A

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

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

    \[\leadsto \sqrt{\mathsf{fma}\left(maxCos, ux, 2 - ux\right) \cdot \color{blue}{\left(ux \cdot \left(1 - maxCos\right)\right)}} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
  9. Step-by-step derivation
    1. lower-*.f32N/A

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

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

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

Alternative 8: 97.6% accurate, 1.2× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    2. *-commutativeN/A

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

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

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

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

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

Alternative 9: 95.7% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 57.4%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Step-by-step derivation
      1. lift-*.f32N/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
      3. lift-+.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
      4. lift--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
      5. associate-+l-N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
      6. sub-square-powN/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      9. lower--.f32N/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      11. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      12. lower--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      13. lift-*.f32N/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      15. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      16. unpow2N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
      17. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
      18. lower--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
      19. lift-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
      20. *-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
      21. lower-*.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
    4. Step-by-step derivation
      1. lift--.f32N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
      4. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    6. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      2. *-commutativeN/A

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

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

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \cdot \cos \left(\left(uy + uy\right) \cdot \pi\right) \]
    9. Step-by-step derivation
      1. lower-*.f32N/A

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

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

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

    if 7.50000027e-7 < maxCos

    1. Initial program 57.4%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Step-by-step derivation
      1. lift-*.f32N/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
      3. lift-+.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
      4. lift--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
      5. associate-+l-N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
      6. sub-square-powN/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      9. lower--.f32N/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      11. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      12. lower--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      13. lift-*.f32N/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      15. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
      16. unpow2N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
      17. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
      18. lower--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
      19. lift-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
      20. *-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
      21. lower-*.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
    4. Step-by-step derivation
      1. lift--.f32N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
      4. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    6. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \cos \color{blue}{\left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      2. lift-*.f32N/A

        \[\leadsto \cos \left(\color{blue}{\left(uy \cdot 2\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      3. *-commutativeN/A

        \[\leadsto \cos \left(\color{blue}{\left(2 \cdot uy\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      4. associate-*l*N/A

        \[\leadsto \cos \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      5. lift-PI.f32N/A

        \[\leadsto \cos \left(2 \cdot \left(uy \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      6. add-log-expN/A

        \[\leadsto \cos \left(2 \cdot \left(uy \cdot \color{blue}{\log \left(e^{\mathsf{PI}\left(\right)}\right)}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      7. log-pow-revN/A

        \[\leadsto \cos \left(2 \cdot \color{blue}{\log \left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{uy}\right)}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      8. log-pow-revN/A

        \[\leadsto \cos \color{blue}{\log \left({\left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{uy}\right)}^{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      9. lower-log.f32N/A

        \[\leadsto \cos \color{blue}{\log \left({\left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{uy}\right)}^{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      10. lower-pow.f32N/A

        \[\leadsto \cos \log \color{blue}{\left({\left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{uy}\right)}^{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      11. lift-PI.f32N/A

        \[\leadsto \cos \log \left({\left({\left(e^{\color{blue}{\pi}}\right)}^{uy}\right)}^{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      12. pow-expN/A

        \[\leadsto \cos \log \left({\color{blue}{\left(e^{\pi \cdot uy}\right)}}^{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      13. lower-exp.f32N/A

        \[\leadsto \cos \log \left({\color{blue}{\left(e^{\pi \cdot uy}\right)}}^{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
      14. lower-*.f3298.9

        \[\leadsto \cos \log \left({\left(e^{\color{blue}{\pi \cdot uy}}\right)}^{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    7. Applied rewrites98.9%

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

      \[\leadsto \color{blue}{\sqrt{\mathsf{neg}\left(\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + {\left(maxCos \cdot ux - ux\right)}^{2}\right)\right)}} \]
    9. Step-by-step derivation
      1. lower-sqrt.f32N/A

        \[\leadsto \sqrt{\mathsf{neg}\left(\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + {\left(maxCos \cdot ux - ux\right)}^{2}\right)\right)} \]
      2. lower-neg.f32N/A

        \[\leadsto \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
      3. lower-fma.f32N/A

        \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
      4. lower--.f32N/A

        \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
      5. lower-*.f32N/A

        \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
      6. lower-pow.f32N/A

        \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
      7. lower--.f32N/A

        \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
      8. lower-*.f3280.4

        \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
    10. Applied rewrites80.4%

      \[\leadsto \color{blue}{\sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 80.4% accurate, 1.8× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \cos \color{blue}{\left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    2. lift-*.f32N/A

      \[\leadsto \cos \left(\color{blue}{\left(uy \cdot 2\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    3. *-commutativeN/A

      \[\leadsto \cos \left(\color{blue}{\left(2 \cdot uy\right)} \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    4. associate-*l*N/A

      \[\leadsto \cos \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    5. lift-PI.f32N/A

      \[\leadsto \cos \left(2 \cdot \left(uy \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    6. add-log-expN/A

      \[\leadsto \cos \left(2 \cdot \left(uy \cdot \color{blue}{\log \left(e^{\mathsf{PI}\left(\right)}\right)}\right)\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    7. log-pow-revN/A

      \[\leadsto \cos \left(2 \cdot \color{blue}{\log \left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{uy}\right)}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    8. log-pow-revN/A

      \[\leadsto \cos \color{blue}{\log \left({\left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{uy}\right)}^{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    9. lower-log.f32N/A

      \[\leadsto \cos \color{blue}{\log \left({\left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{uy}\right)}^{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    10. lower-pow.f32N/A

      \[\leadsto \cos \log \color{blue}{\left({\left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{uy}\right)}^{2}\right)} \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    11. lift-PI.f32N/A

      \[\leadsto \cos \log \left({\left({\left(e^{\color{blue}{\pi}}\right)}^{uy}\right)}^{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    12. pow-expN/A

      \[\leadsto \cos \log \left({\color{blue}{\left(e^{\pi \cdot uy}\right)}}^{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    13. lower-exp.f32N/A

      \[\leadsto \cos \log \left({\color{blue}{\left(e^{\pi \cdot uy}\right)}}^{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
    14. lower-*.f3298.9

      \[\leadsto \cos \log \left({\left(e^{\color{blue}{\pi \cdot uy}}\right)}^{2}\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)} \]
  7. Applied rewrites98.9%

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

    \[\leadsto \color{blue}{\sqrt{\mathsf{neg}\left(\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + {\left(maxCos \cdot ux - ux\right)}^{2}\right)\right)}} \]
  9. Step-by-step derivation
    1. lower-sqrt.f32N/A

      \[\leadsto \sqrt{\mathsf{neg}\left(\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + {\left(maxCos \cdot ux - ux\right)}^{2}\right)\right)} \]
    2. lower-neg.f32N/A

      \[\leadsto \sqrt{-\left(-2 \cdot \left(ux - maxCos \cdot ux\right) + {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
    3. lower-fma.f32N/A

      \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
    4. lower--.f32N/A

      \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
    5. lower-*.f32N/A

      \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
    6. lower-pow.f32N/A

      \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
    7. lower--.f32N/A

      \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
    8. lower-*.f3280.4

      \[\leadsto \sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)} \]
  10. Applied rewrites80.4%

    \[\leadsto \color{blue}{\sqrt{-\mathsf{fma}\left(-2, ux - maxCos \cdot ux, {\left(maxCos \cdot ux - ux\right)}^{2}\right)}} \]
  11. Add Preprocessing

Alternative 11: 80.4% accurate, 3.4× speedup?

\[\begin{array}{l} \\ \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt (* (- ux (* maxCos ux)) (- (+ 2.0 (* maxCos ux)) ux))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(((ux - (maxCos * ux)) * ((2.0f + (maxCos * ux)) - ux)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(ux, uy, maxcos)
use fmin_fmax_functions
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt(((ux - (maxcos * ux)) * ((2.0e0 + (maxcos * ux)) - ux)))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(Float32(Float32(2.0) + Float32(maxCos * ux)) - ux)))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt(((ux - (maxCos * ux)) * ((single(2.0) + (maxCos * ux)) - ux)));
end
\begin{array}{l}

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}^{2}}} \]
    3. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)}}^{2}} \]
    4. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)}^{2}} \]
    5. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - {\color{blue}{\left(1 - \left(ux - ux \cdot maxCos\right)\right)}}^{2}} \]
    6. sub-square-powN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\color{blue}{1} - 2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    9. lower--.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - \color{blue}{2 \cdot \left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    11. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \color{blue}{\left(1 \cdot \left(ux - ux \cdot maxCos\right)\right)}\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    12. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \color{blue}{\left(ux - ux \cdot maxCos\right)}\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    13. lift-*.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    15. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) + {\left(ux - ux \cdot maxCos\right)}^{2}\right)} \]
    16. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    17. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right) \cdot \left(ux - ux \cdot maxCos\right)}\right)} \]
    18. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \color{blue}{\left(ux - ux \cdot maxCos\right)} \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    19. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{ux \cdot maxCos}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    20. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - \color{blue}{maxCos \cdot ux}\right) \cdot \left(ux - ux \cdot maxCos\right)\right)} \]
    21. lower-*.f32N/A

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right) + \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)\right)}} \]
  4. Step-by-step derivation
    1. lift--.f32N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 - \left(1 - 2 \cdot \left(1 \cdot \left(ux - maxCos \cdot ux\right)\right)\right)\right) - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}} \]
    4. lower--.f32N/A

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  6. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(0 - -2 \cdot \left(ux - maxCos \cdot ux\right)\right) - \left(maxCos \cdot ux - ux\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    2. *-commutativeN/A

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

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

    \[\leadsto \color{blue}{\sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)}} \]
  9. Step-by-step derivation
    1. lower-sqrt.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \]
    2. lower-*.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \]
    3. lower--.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \]
    4. lower-*.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \]
    5. lower--.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \]
    6. lower-+.f32N/A

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \]
    7. lower-*.f3280.4

      \[\leadsto \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)} \]
  10. Applied rewrites80.4%

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

Reproduce

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