UniformSampleCone, x

Percentage Accurate: 57.1% → 98.9%
Time: 15.5s
Alternatives: 16
Speedup: 9.8×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 16 alternatives:

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

Initial Program: 57.1% accurate, 1.0× speedup?

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

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

Alternative 1: 98.9% accurate, 0.6× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 0

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2}\right)} \]
    8. mul-1-negN/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right)\right) + 2\right)} \]
    10. unpow2N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{\left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)} \cdot ux\right)\right) + 2\right)} \]
    11. associate-*l*N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} + 2\right)} \]
    14. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(\left(2 \cdot uy\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
    7. associate-*r*N/A

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

      \[\leadsto \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
    9. cos-2N/A

      \[\leadsto \color{blue}{\left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(uy \cdot \mathsf{PI}\left(\right)\right) - \sin \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
    10. cancel-sign-sub-invN/A

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

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right), \color{blue}{\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)}, \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
    14. lower-*.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)} + \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
    4. sqr-cos-aN/A

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{2} + \left(\frac{1}{2} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
    7. count-2N/A

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

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

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

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

Alternative 2: 83.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \leq 0.9999949932098389:\\
\;\;\;\;\sqrt{ux \cdot 2} \cdot \mathsf{fma}\left(-2 \cdot \left(\pi \cdot \left(uy \cdot uy\right)\right), \pi, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) < 0.999994993

    1. Initial program 56.5%

      \[\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. Add Preprocessing
    3. Taylor expanded in maxCos around 0

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
      3. unpow2N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(1 - ux\right) \cdot \left(1 - ux\right)}\right)\right) + 1} \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
      5. mul-1-negN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(1 - ux\right) \cdot \color{blue}{\left(-1 \cdot \left(1 - ux\right)\right)} + 1} \]
      6. lower-fma.f32N/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
      8. mul-1-negN/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
      10. lower--.f3255.0

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot \color{blue}{ux}} \]
    7. Step-by-step derivation
      1. Applied rewrites72.8%

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

        \[\leadsto \color{blue}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \cdot \sqrt{ux \cdot 2} \]
      3. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + 1\right)} \cdot \sqrt{ux \cdot 2} \]
        2. associate-*r*N/A

          \[\leadsto \left(\color{blue}{\left(-2 \cdot {uy}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}} + 1\right) \cdot \sqrt{ux \cdot 2} \]
        3. lower-fma.f32N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot {uy}^{2}, {\mathsf{PI}\left(\right)}^{2}, 1\right)} \cdot \sqrt{ux \cdot 2} \]
        4. lower-*.f32N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
        5. unpow2N/A

          \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
        6. lower-*.f32N/A

          \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
        7. unpow2N/A

          \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot 2} \]
        8. lower-*.f32N/A

          \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot 2} \]
        9. lower-PI.f32N/A

          \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{ux \cdot 2} \]
        10. lower-PI.f3258.0

          \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \color{blue}{\pi}, 1\right) \cdot \sqrt{ux \cdot 2} \]
      4. Applied rewrites58.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right)} \cdot \sqrt{ux \cdot 2} \]
      5. Step-by-step derivation
        1. Applied rewrites58.0%

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

        if 0.999994993 < (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32)))

        1. Initial program 62.0%

          \[\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. Add Preprocessing
        3. Taylor expanded in uy around 0

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

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

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

            \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
          4. unpow2N/A

            \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
          5. distribute-rgt-neg-inN/A

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

            \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 + maxCos \cdot ux\right) - ux, \mathsf{neg}\left(\left(\left(1 + maxCos \cdot ux\right) - ux\right)\right), 1\right)}} \]
        5. Applied rewrites62.3%

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

          \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
        7. Step-by-step derivation
          1. Applied rewrites98.7%

            \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
          2. Step-by-step derivation
            1. Applied rewrites98.8%

              \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot ux\right)\right)} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification85.6%

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

          Alternative 3: 83.0% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \leq 0.9999949932098389:\\ \;\;\;\;\sqrt{ux \cdot 2} \cdot \mathsf{fma}\left(-2 \cdot \left(\pi \cdot \left(uy \cdot uy\right)\right), \pi, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{ux \cdot \mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos + -1\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)}\\ \end{array} \end{array} \]
          (FPCore (ux uy maxCos)
           :precision binary32
           (if (<= (cos (* PI (* uy 2.0))) 0.9999949932098389)
             (* (sqrt (* ux 2.0)) (fma (* -2.0 (* PI (* uy uy))) PI 1.0))
             (sqrt
              (* ux (fma ux (* (- 1.0 maxCos) (+ maxCos -1.0)) (fma maxCos -2.0 2.0))))))
          float code(float ux, float uy, float maxCos) {
          	float tmp;
          	if (cosf((((float) M_PI) * (uy * 2.0f))) <= 0.9999949932098389f) {
          		tmp = sqrtf((ux * 2.0f)) * fmaf((-2.0f * (((float) M_PI) * (uy * uy))), ((float) M_PI), 1.0f);
          	} else {
          		tmp = sqrtf((ux * fmaf(ux, ((1.0f - maxCos) * (maxCos + -1.0f)), fmaf(maxCos, -2.0f, 2.0f))));
          	}
          	return tmp;
          }
          
          function code(ux, uy, maxCos)
          	tmp = Float32(0.0)
          	if (cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) <= Float32(0.9999949932098389))
          		tmp = Float32(sqrt(Float32(ux * Float32(2.0))) * fma(Float32(Float32(-2.0) * Float32(Float32(pi) * Float32(uy * uy))), Float32(pi), Float32(1.0)));
          	else
          		tmp = sqrt(Float32(ux * fma(ux, Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0))), fma(maxCos, Float32(-2.0), Float32(2.0)))));
          	end
          	return tmp
          end
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \leq 0.9999949932098389:\\
          \;\;\;\;\sqrt{ux \cdot 2} \cdot \mathsf{fma}\left(-2 \cdot \left(\pi \cdot \left(uy \cdot uy\right)\right), \pi, 1\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\sqrt{ux \cdot \mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos + -1\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) < 0.999994993

            1. Initial program 56.5%

              \[\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. Add Preprocessing
            3. Taylor expanded in maxCos around 0

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
            4. Step-by-step derivation
              1. sub-negN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right)}} \]
              2. +-commutativeN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
              3. unpow2N/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(1 - ux\right) \cdot \left(1 - ux\right)}\right)\right) + 1} \]
              4. distribute-rgt-neg-inN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
              5. mul-1-negN/A

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(1 - ux\right) \cdot \color{blue}{\left(-1 \cdot \left(1 - ux\right)\right)} + 1} \]
              6. lower-fma.f32N/A

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

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
              8. mul-1-negN/A

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

                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
              10. lower--.f3255.0

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

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

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot \color{blue}{ux}} \]
            7. Step-by-step derivation
              1. Applied rewrites72.8%

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

                \[\leadsto \color{blue}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \cdot \sqrt{ux \cdot 2} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + 1\right)} \cdot \sqrt{ux \cdot 2} \]
                2. associate-*r*N/A

                  \[\leadsto \left(\color{blue}{\left(-2 \cdot {uy}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}} + 1\right) \cdot \sqrt{ux \cdot 2} \]
                3. lower-fma.f32N/A

                  \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot {uy}^{2}, {\mathsf{PI}\left(\right)}^{2}, 1\right)} \cdot \sqrt{ux \cdot 2} \]
                4. lower-*.f32N/A

                  \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                5. unpow2N/A

                  \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                6. lower-*.f32N/A

                  \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                7. unpow2N/A

                  \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                8. lower-*.f32N/A

                  \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                9. lower-PI.f32N/A

                  \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{ux \cdot 2} \]
                10. lower-PI.f3258.0

                  \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \color{blue}{\pi}, 1\right) \cdot \sqrt{ux \cdot 2} \]
              4. Applied rewrites58.0%

                \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right)} \cdot \sqrt{ux \cdot 2} \]
              5. Step-by-step derivation
                1. Applied rewrites58.0%

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

                if 0.999994993 < (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32)))

                1. Initial program 62.0%

                  \[\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. Add Preprocessing
                3. Taylor expanded in uy around 0

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

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

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

                    \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
                  4. unpow2N/A

                    \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
                  5. distribute-rgt-neg-inN/A

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

                    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 + maxCos \cdot ux\right) - ux, \mathsf{neg}\left(\left(\left(1 + maxCos \cdot ux\right) - ux\right)\right), 1\right)}} \]
                5. Applied rewrites62.3%

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

                  \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
                7. Step-by-step derivation
                  1. Applied rewrites98.7%

                    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
                8. Recombined 2 regimes into one program.
                9. Final simplification85.5%

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

                Alternative 4: 83.0% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \leq 0.9999949932098389:\\ \;\;\;\;\sqrt{ux \cdot 2} \cdot \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{ux \cdot \mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos + -1\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)}\\ \end{array} \end{array} \]
                (FPCore (ux uy maxCos)
                 :precision binary32
                 (if (<= (cos (* PI (* uy 2.0))) 0.9999949932098389)
                   (* (sqrt (* ux 2.0)) (fma (* -2.0 (* uy uy)) (* PI PI) 1.0))
                   (sqrt
                    (* ux (fma ux (* (- 1.0 maxCos) (+ maxCos -1.0)) (fma maxCos -2.0 2.0))))))
                float code(float ux, float uy, float maxCos) {
                	float tmp;
                	if (cosf((((float) M_PI) * (uy * 2.0f))) <= 0.9999949932098389f) {
                		tmp = sqrtf((ux * 2.0f)) * fmaf((-2.0f * (uy * uy)), (((float) M_PI) * ((float) M_PI)), 1.0f);
                	} else {
                		tmp = sqrtf((ux * fmaf(ux, ((1.0f - maxCos) * (maxCos + -1.0f)), fmaf(maxCos, -2.0f, 2.0f))));
                	}
                	return tmp;
                }
                
                function code(ux, uy, maxCos)
                	tmp = Float32(0.0)
                	if (cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) <= Float32(0.9999949932098389))
                		tmp = Float32(sqrt(Float32(ux * Float32(2.0))) * fma(Float32(Float32(-2.0) * Float32(uy * uy)), Float32(Float32(pi) * Float32(pi)), Float32(1.0)));
                	else
                		tmp = sqrt(Float32(ux * fma(ux, Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0))), fma(maxCos, Float32(-2.0), Float32(2.0)))));
                	end
                	return tmp
                end
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \leq 0.9999949932098389:\\
                \;\;\;\;\sqrt{ux \cdot 2} \cdot \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\sqrt{ux \cdot \mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos + -1\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) < 0.999994993

                  1. Initial program 56.5%

                    \[\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. Add Preprocessing
                  3. Taylor expanded in maxCos around 0

                    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
                  4. Step-by-step derivation
                    1. sub-negN/A

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right)}} \]
                    2. +-commutativeN/A

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
                    3. unpow2N/A

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(1 - ux\right) \cdot \left(1 - ux\right)}\right)\right) + 1} \]
                    4. distribute-rgt-neg-inN/A

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
                    5. mul-1-negN/A

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(1 - ux\right) \cdot \color{blue}{\left(-1 \cdot \left(1 - ux\right)\right)} + 1} \]
                    6. lower-fma.f32N/A

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

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
                    8. mul-1-negN/A

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

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
                    10. lower--.f3255.0

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

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

                    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot \color{blue}{ux}} \]
                  7. Step-by-step derivation
                    1. Applied rewrites72.8%

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

                      \[\leadsto \color{blue}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \cdot \sqrt{ux \cdot 2} \]
                    3. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + 1\right)} \cdot \sqrt{ux \cdot 2} \]
                      2. associate-*r*N/A

                        \[\leadsto \left(\color{blue}{\left(-2 \cdot {uy}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}} + 1\right) \cdot \sqrt{ux \cdot 2} \]
                      3. lower-fma.f32N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot {uy}^{2}, {\mathsf{PI}\left(\right)}^{2}, 1\right)} \cdot \sqrt{ux \cdot 2} \]
                      4. lower-*.f32N/A

                        \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                      5. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                      6. lower-*.f32N/A

                        \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                      7. unpow2N/A

                        \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                      8. lower-*.f32N/A

                        \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                      9. lower-PI.f32N/A

                        \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{ux \cdot 2} \]
                      10. lower-PI.f3258.0

                        \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \color{blue}{\pi}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                    4. Applied rewrites58.0%

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

                    if 0.999994993 < (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32)))

                    1. Initial program 62.0%

                      \[\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. Add Preprocessing
                    3. Taylor expanded in uy around 0

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

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

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

                        \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
                      4. unpow2N/A

                        \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
                      5. distribute-rgt-neg-inN/A

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

                        \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 + maxCos \cdot ux\right) - ux, \mathsf{neg}\left(\left(\left(1 + maxCos \cdot ux\right) - ux\right)\right), 1\right)}} \]
                    5. Applied rewrites62.3%

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

                      \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
                    7. Step-by-step derivation
                      1. Applied rewrites98.7%

                        \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
                    8. Recombined 2 regimes into one program.
                    9. Final simplification85.5%

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

                    Alternative 5: 99.0% accurate, 1.0× speedup?

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

                      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in ux around 0

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                      2. cancel-sign-sub-invN/A

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

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

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

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

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2}\right)} \]
                      8. mul-1-negN/A

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right)\right) + 2\right)} \]
                      10. unpow2N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{\left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)} \cdot ux\right)\right) + 2\right)} \]
                      11. associate-*l*N/A

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

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} + 2\right)} \]
                      14. neg-sub0N/A

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

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

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

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

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

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

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

                    Alternative 6: 98.2% accurate, 1.0× speedup?

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

                      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in ux around 0

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                      2. cancel-sign-sub-invN/A

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

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

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

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

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2}\right)} \]
                      8. mul-1-negN/A

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right)\right) + 2\right)} \]
                      10. unpow2N/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{\left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)} \cdot ux\right)\right) + 2\right)} \]
                      11. associate-*l*N/A

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

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} + 2\right)} \]
                      14. neg-sub0N/A

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

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

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

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

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

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

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

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

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

                      Alternative 7: 97.5% accurate, 1.1× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.017000000923871994:\\ \;\;\;\;\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, -ux\right), 2\right)\right)} \cdot \left(0.5 + \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\ \end{array} \end{array} \]
                      (FPCore (ux uy maxCos)
                       :precision binary32
                       (if (<= (* uy 2.0) 0.017000000923871994)
                         (*
                          (sqrt
                           (* ux (fma maxCos -2.0 (fma (- 1.0 maxCos) (fma ux maxCos (- ux)) 2.0))))
                          (+ 0.5 (fma (* -2.0 (* uy uy)) (* PI PI) 0.5)))
                         (* (cos (* PI (* uy 2.0))) (sqrt (* ux (- 2.0 ux))))))
                      float code(float ux, float uy, float maxCos) {
                      	float tmp;
                      	if ((uy * 2.0f) <= 0.017000000923871994f) {
                      		tmp = sqrtf((ux * fmaf(maxCos, -2.0f, fmaf((1.0f - maxCos), fmaf(ux, maxCos, -ux), 2.0f)))) * (0.5f + fmaf((-2.0f * (uy * uy)), (((float) M_PI) * ((float) M_PI)), 0.5f));
                      	} else {
                      		tmp = cosf((((float) M_PI) * (uy * 2.0f))) * sqrtf((ux * (2.0f - ux)));
                      	}
                      	return tmp;
                      }
                      
                      function code(ux, uy, maxCos)
                      	tmp = Float32(0.0)
                      	if (Float32(uy * Float32(2.0)) <= Float32(0.017000000923871994))
                      		tmp = Float32(sqrt(Float32(ux * fma(maxCos, Float32(-2.0), fma(Float32(Float32(1.0) - maxCos), fma(ux, maxCos, Float32(-ux)), Float32(2.0))))) * Float32(Float32(0.5) + fma(Float32(Float32(-2.0) * Float32(uy * uy)), Float32(Float32(pi) * Float32(pi)), Float32(0.5))));
                      	else
                      		tmp = Float32(cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * sqrt(Float32(ux * Float32(Float32(2.0) - ux))));
                      	end
                      	return tmp
                      end
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;uy \cdot 2 \leq 0.017000000923871994:\\
                      \;\;\;\;\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, -ux\right), 2\right)\right)} \cdot \left(0.5 + \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 0.5\right)\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if (*.f32 uy #s(literal 2 binary32)) < 0.0170000009

                        1. Initial program 60.9%

                          \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                        2. Add Preprocessing
                        3. Taylor expanded in ux around 0

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                          2. cancel-sign-sub-invN/A

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

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

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

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

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2}\right)} \]
                          8. mul-1-negN/A

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right)\right) + 2\right)} \]
                          10. unpow2N/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{\left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)} \cdot ux\right)\right) + 2\right)} \]
                          11. associate-*l*N/A

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

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} + 2\right)} \]
                          14. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \cos \left(\left(2 \cdot uy\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          7. associate-*r*N/A

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

                            \[\leadsto \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          9. cos-2N/A

                            \[\leadsto \color{blue}{\left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(uy \cdot \mathsf{PI}\left(\right)\right) - \sin \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          10. cancel-sign-sub-invN/A

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

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

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

                            \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right), \color{blue}{\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)}, \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          14. lower-*.f32N/A

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

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

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

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

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

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

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

                            \[\leadsto \left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)} + \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          4. sqr-cos-aN/A

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

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

                            \[\leadsto \color{blue}{\left(\frac{1}{2} + \left(\frac{1}{2} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          7. count-2N/A

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

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

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

                          \[\leadsto \left(\frac{1}{2} + \color{blue}{\left(\frac{1}{2} + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                        11. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \left(\frac{1}{2} + \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{1}{2}\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          2. associate-*r*N/A

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

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

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

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

                            \[\leadsto \left(\frac{1}{2} + \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, \frac{1}{2}\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          7. unpow2N/A

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

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

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

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

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

                        if 0.0170000009 < (*.f32 uy #s(literal 2 binary32))

                        1. Initial program 57.7%

                          \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                        2. Add Preprocessing
                        3. Taylor expanded in maxCos around 0

                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
                        4. Step-by-step derivation
                          1. sub-negN/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right)}} \]
                          2. +-commutativeN/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
                          3. unpow2N/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(1 - ux\right) \cdot \left(1 - ux\right)}\right)\right) + 1} \]
                          4. distribute-rgt-neg-inN/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
                          5. mul-1-negN/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(1 - ux\right) \cdot \color{blue}{\left(-1 \cdot \left(1 - ux\right)\right)} + 1} \]
                          6. lower-fma.f32N/A

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
                          8. mul-1-negN/A

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
                          10. lower--.f3257.0

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

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

                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 + -1 \cdot ux\right)}} \]
                        7. Step-by-step derivation
                          1. Applied rewrites93.5%

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

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

                        Alternative 8: 93.8% accurate, 1.1× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.10000000149011612:\\ \;\;\;\;\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, -ux\right), 2\right)\right)} \cdot \left(0.5 + \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(uy \cdot \left(\pi + \pi\right)\right) \cdot \sqrt{ux \cdot 2}\\ \end{array} \end{array} \]
                        (FPCore (ux uy maxCos)
                         :precision binary32
                         (if (<= (* uy 2.0) 0.10000000149011612)
                           (*
                            (sqrt
                             (* ux (fma maxCos -2.0 (fma (- 1.0 maxCos) (fma ux maxCos (- ux)) 2.0))))
                            (+ 0.5 (fma (* -2.0 (* uy uy)) (* PI PI) 0.5)))
                           (* (cos (* uy (+ PI PI))) (sqrt (* ux 2.0)))))
                        float code(float ux, float uy, float maxCos) {
                        	float tmp;
                        	if ((uy * 2.0f) <= 0.10000000149011612f) {
                        		tmp = sqrtf((ux * fmaf(maxCos, -2.0f, fmaf((1.0f - maxCos), fmaf(ux, maxCos, -ux), 2.0f)))) * (0.5f + fmaf((-2.0f * (uy * uy)), (((float) M_PI) * ((float) M_PI)), 0.5f));
                        	} else {
                        		tmp = cosf((uy * (((float) M_PI) + ((float) M_PI)))) * sqrtf((ux * 2.0f));
                        	}
                        	return tmp;
                        }
                        
                        function code(ux, uy, maxCos)
                        	tmp = Float32(0.0)
                        	if (Float32(uy * Float32(2.0)) <= Float32(0.10000000149011612))
                        		tmp = Float32(sqrt(Float32(ux * fma(maxCos, Float32(-2.0), fma(Float32(Float32(1.0) - maxCos), fma(ux, maxCos, Float32(-ux)), Float32(2.0))))) * Float32(Float32(0.5) + fma(Float32(Float32(-2.0) * Float32(uy * uy)), Float32(Float32(pi) * Float32(pi)), Float32(0.5))));
                        	else
                        		tmp = Float32(cos(Float32(uy * Float32(Float32(pi) + Float32(pi)))) * sqrt(Float32(ux * Float32(2.0))));
                        	end
                        	return tmp
                        end
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;uy \cdot 2 \leq 0.10000000149011612:\\
                        \;\;\;\;\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, -ux\right), 2\right)\right)} \cdot \left(0.5 + \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 0.5\right)\right)\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\cos \left(uy \cdot \left(\pi + \pi\right)\right) \cdot \sqrt{ux \cdot 2}\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (*.f32 uy #s(literal 2 binary32)) < 0.100000001

                          1. Initial program 60.4%

                            \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                          2. Add Preprocessing
                          3. Taylor expanded in ux around 0

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                            2. cancel-sign-sub-invN/A

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

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

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

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

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2}\right)} \]
                            8. mul-1-negN/A

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right)\right) + 2\right)} \]
                            10. unpow2N/A

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{\left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)} \cdot ux\right)\right) + 2\right)} \]
                            11. associate-*l*N/A

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

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} + 2\right)} \]
                            14. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \cos \left(\left(2 \cdot uy\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            7. associate-*r*N/A

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

                              \[\leadsto \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            9. cos-2N/A

                              \[\leadsto \color{blue}{\left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(uy \cdot \mathsf{PI}\left(\right)\right) - \sin \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            10. cancel-sign-sub-invN/A

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

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

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

                              \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right), \color{blue}{\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)}, \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            14. lower-*.f32N/A

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

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

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

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

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

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

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

                              \[\leadsto \left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)} + \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            4. sqr-cos-aN/A

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

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

                              \[\leadsto \color{blue}{\left(\frac{1}{2} + \left(\frac{1}{2} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            7. count-2N/A

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

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

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

                            \[\leadsto \left(\frac{1}{2} + \color{blue}{\left(\frac{1}{2} + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          11. Step-by-step derivation
                            1. +-commutativeN/A

                              \[\leadsto \left(\frac{1}{2} + \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{1}{2}\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            2. associate-*r*N/A

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

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

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

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

                              \[\leadsto \left(\frac{1}{2} + \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, \frac{1}{2}\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            7. unpow2N/A

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

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

                              \[\leadsto \left(\frac{1}{2} + \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), \frac{1}{2}\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            10. lower-PI.f3297.0

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

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

                          if 0.100000001 < (*.f32 uy #s(literal 2 binary32))

                          1. Initial program 58.6%

                            \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                          2. Add Preprocessing
                          3. Taylor expanded in maxCos around 0

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
                          4. Step-by-step derivation
                            1. sub-negN/A

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right)}} \]
                            2. +-commutativeN/A

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
                            3. unpow2N/A

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(1 - ux\right) \cdot \left(1 - ux\right)}\right)\right) + 1} \]
                            4. distribute-rgt-neg-inN/A

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
                            5. mul-1-negN/A

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(1 - ux\right) \cdot \color{blue}{\left(-1 \cdot \left(1 - ux\right)\right)} + 1} \]
                            6. lower-fma.f32N/A

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
                            8. mul-1-negN/A

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
                            10. lower--.f3257.2

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

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot \color{blue}{ux}} \]
                          7. Step-by-step derivation
                            1. Applied rewrites69.8%

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

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

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

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

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

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

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

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

                                \[\leadsto \sqrt{ux \cdot 2} \cdot \cos \left(\left(2 \cdot uy\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \]
                              9. associate-*r*N/A

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

                                \[\leadsto \sqrt{ux \cdot 2} \cdot \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \]
                              11. count-2N/A

                                \[\leadsto \sqrt{ux \cdot 2} \cdot \cos \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right) + uy \cdot \mathsf{PI}\left(\right)\right)} \]
                            3. Applied rewrites69.8%

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

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

                          Alternative 9: 88.3% accurate, 2.3× speedup?

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

                            \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                          2. Add Preprocessing
                          3. Taylor expanded in ux around 0

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                            2. cancel-sign-sub-invN/A

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

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

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

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

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2}\right)} \]
                            8. mul-1-negN/A

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right)\right) + 2\right)} \]
                            10. unpow2N/A

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{\left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)} \cdot ux\right)\right) + 2\right)} \]
                            11. associate-*l*N/A

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

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} + 2\right)} \]
                            14. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \cos \left(\left(2 \cdot uy\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            7. associate-*r*N/A

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

                              \[\leadsto \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            9. cos-2N/A

                              \[\leadsto \color{blue}{\left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(uy \cdot \mathsf{PI}\left(\right)\right) - \sin \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            10. cancel-sign-sub-invN/A

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

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

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

                              \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right), \color{blue}{\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)}, \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            14. lower-*.f32N/A

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

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

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

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

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

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

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

                              \[\leadsto \left(\cos \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)} + \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            4. sqr-cos-aN/A

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

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

                              \[\leadsto \color{blue}{\left(\frac{1}{2} + \left(\frac{1}{2} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + \left(\mathsf{neg}\left(\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sin \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            7. count-2N/A

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

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

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

                            \[\leadsto \left(\frac{1}{2} + \color{blue}{\left(\frac{1}{2} + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          11. Step-by-step derivation
                            1. +-commutativeN/A

                              \[\leadsto \left(\frac{1}{2} + \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{1}{2}\right)}\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            2. associate-*r*N/A

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

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

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

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

                              \[\leadsto \left(\frac{1}{2} + \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, \frac{1}{2}\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            7. unpow2N/A

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

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

                              \[\leadsto \left(\frac{1}{2} + \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), \frac{1}{2}\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            10. lower-PI.f3289.7

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

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

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

                          Alternative 10: 88.3% accurate, 2.4× speedup?

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

                            \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                          2. Add Preprocessing
                          3. Taylor expanded in ux around 0

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
                            2. cancel-sign-sub-invN/A

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

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

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

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

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2}\right)} \]
                            8. mul-1-negN/A

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right)\right) + 2\right)} \]
                            10. unpow2N/A

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \left(\mathsf{neg}\left(\color{blue}{\left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)} \cdot ux\right)\right) + 2\right)} \]
                            11. associate-*l*N/A

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

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} + 2\right)} \]
                            14. neg-sub0N/A

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

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

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

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

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

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

                            \[\leadsto \color{blue}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                          7. Step-by-step derivation
                            1. +-commutativeN/A

                              \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + 1\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            2. associate-*r*N/A

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

                              \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot {uy}^{2}, {\mathsf{PI}\left(\right)}^{2}, 1\right)} \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            4. lower-*.f32N/A

                              \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            5. unpow2N/A

                              \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            6. lower-*.f32N/A

                              \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            7. unpow2N/A

                              \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            8. lower-*.f32N/A

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

                              \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(1 - maxCos, \mathsf{fma}\left(ux, maxCos, \mathsf{neg}\left(ux\right)\right), 2\right)\right)} \]
                            10. lower-PI.f3289.7

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

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

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

                          Alternative 11: 86.9% accurate, 3.1× speedup?

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

                            1. Initial program 60.9%

                              \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            2. Add Preprocessing
                            3. Taylor expanded in maxCos around 0

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
                            4. Step-by-step derivation
                              1. sub-negN/A

                                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right)}} \]
                              2. +-commutativeN/A

                                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
                              3. unpow2N/A

                                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(1 - ux\right) \cdot \left(1 - ux\right)}\right)\right) + 1} \]
                              4. distribute-rgt-neg-inN/A

                                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
                              5. mul-1-negN/A

                                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(1 - ux\right) \cdot \color{blue}{\left(-1 \cdot \left(1 - ux\right)\right)} + 1} \]
                              6. lower-fma.f32N/A

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

                                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
                              8. mul-1-negN/A

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

                                \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
                              10. lower--.f3261.1

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

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

                              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot \color{blue}{ux}} \]
                            7. Step-by-step derivation
                              1. Applied rewrites75.0%

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

                                \[\leadsto \color{blue}{\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \cdot \sqrt{ux \cdot 2} \]
                              3. Step-by-step derivation
                                1. +-commutativeN/A

                                  \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + 1\right)} \cdot \sqrt{ux \cdot 2} \]
                                2. associate-*r*N/A

                                  \[\leadsto \left(\color{blue}{\left(-2 \cdot {uy}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2}} + 1\right) \cdot \sqrt{ux \cdot 2} \]
                                3. lower-fma.f32N/A

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot {uy}^{2}, {\mathsf{PI}\left(\right)}^{2}, 1\right)} \cdot \sqrt{ux \cdot 2} \]
                                4. lower-*.f32N/A

                                  \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                                5. unpow2N/A

                                  \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                                6. lower-*.f32N/A

                                  \[\leadsto \mathsf{fma}\left(-2 \cdot \color{blue}{\left(uy \cdot uy\right)}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                                7. unpow2N/A

                                  \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                                8. lower-*.f32N/A

                                  \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                                9. lower-PI.f32N/A

                                  \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{ux \cdot 2} \]
                                10. lower-PI.f3270.0

                                  \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \color{blue}{\pi}, 1\right) \cdot \sqrt{ux \cdot 2} \]
                              4. Applied rewrites70.0%

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

                                \[\leadsto \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 + -1 \cdot ux\right)}} \]
                              6. Step-by-step derivation
                                1. Applied rewrites89.5%

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

                                if 1.99999999e-6 < maxCos

                                1. Initial program 56.9%

                                  \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                2. Add Preprocessing
                                3. Taylor expanded in uy around 0

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

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

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

                                    \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
                                  4. unpow2N/A

                                    \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
                                  5. distribute-rgt-neg-inN/A

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

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

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

                                  \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
                                7. Step-by-step derivation
                                  1. Applied rewrites83.1%

                                    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites83.2%

                                      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot ux\right)\right)} \]
                                  3. Recombined 2 regimes into one program.
                                  4. Final simplification88.5%

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

                                  Alternative 12: 79.7% accurate, 4.0× speedup?

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

                                    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in uy around 0

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

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

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

                                      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
                                    4. unpow2N/A

                                      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
                                    5. distribute-rgt-neg-inN/A

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

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

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

                                    \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
                                  7. Step-by-step derivation
                                    1. Applied rewrites81.6%

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

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

                                    Alternative 13: 79.2% accurate, 4.3× speedup?

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

                                      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in uy around 0

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

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

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

                                        \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
                                      4. unpow2N/A

                                        \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
                                      5. distribute-rgt-neg-inN/A

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

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

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

                                      \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites81.6%

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

                                        \[\leadsto \sqrt{maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right) + ux \cdot \left(2 + -1 \cdot ux\right)} \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites81.2%

                                          \[\leadsto \sqrt{\mathsf{fma}\left(maxCos \cdot ux, \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 - ux\right)\right)} \]
                                        2. Final simplification81.2%

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

                                        Alternative 14: 75.4% accurate, 6.5× speedup?

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

                                          \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in uy around 0

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

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

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

                                            \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
                                          4. unpow2N/A

                                            \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
                                          5. distribute-rgt-neg-inN/A

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

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

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

                                          \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites81.6%

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

                                            \[\leadsto \sqrt{ux \cdot \left(2 + -1 \cdot ux\right)} \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites76.9%

                                              \[\leadsto \sqrt{ux \cdot \left(2 - ux\right)} \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites76.9%

                                                \[\leadsto \sqrt{\mathsf{fma}\left(ux, 2, \left(-ux\right) \cdot ux\right)} \]
                                              2. Final simplification76.9%

                                                \[\leadsto \sqrt{\mathsf{fma}\left(ux, 2, -ux \cdot ux\right)} \]
                                              3. Add Preprocessing

                                              Alternative 15: 75.4% accurate, 8.2× speedup?

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

                                                \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in uy around 0

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

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

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

                                                  \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
                                                4. unpow2N/A

                                                  \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
                                                5. distribute-rgt-neg-inN/A

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

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

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

                                                \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
                                              7. Step-by-step derivation
                                                1. Applied rewrites81.6%

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

                                                  \[\leadsto \sqrt{ux \cdot \left(2 + -1 \cdot ux\right)} \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites76.9%

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

                                                  Alternative 16: 61.9% accurate, 9.8× speedup?

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

                                                    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in uy around 0

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

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

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

                                                      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}\right)\right) + 1}} \]
                                                    4. unpow2N/A

                                                      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)}\right)\right) + 1} \]
                                                    5. distribute-rgt-neg-inN/A

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

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

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

                                                    \[\leadsto \sqrt{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \]
                                                  7. Step-by-step derivation
                                                    1. Applied rewrites81.6%

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

                                                      \[\leadsto \sqrt{ux \cdot \left(2 + -1 \cdot ux\right)} \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites76.9%

                                                        \[\leadsto \sqrt{ux \cdot \left(2 - ux\right)} \]
                                                      2. Taylor expanded in ux around 0

                                                        \[\leadsto \sqrt{2 \cdot ux} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites62.1%

                                                          \[\leadsto \sqrt{2 \cdot ux} \]
                                                        2. Final simplification62.1%

                                                          \[\leadsto \sqrt{ux \cdot 2} \]
                                                        3. Add Preprocessing

                                                        Reproduce

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