UniformSampleCone, x

Percentage Accurate: 57.4% → 99.0%
Time: 15.8s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 57.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
    8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
    9. unpow2N/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
    12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
    13. neg-sub0N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
    14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
    15. +-commutativeN/A

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
    20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
    21. unsub-negN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
    8. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
    9. lower-fma.f32N/A

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

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

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

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

Alternative 2: 97.3% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(\left(uy \cdot 2\right) \cdot \pi\right)\\
\mathbf{if}\;t\_0 \leq 0.9998000264167786:\\
\;\;\;\;t\_0 \cdot \left(\sqrt{2 - ux} \cdot \sqrt{ux}\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \cdot \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\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.999800026

    1. Initial program 65.8%

      \[\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. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + \color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}\right)} \]
      5. lift-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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)}} \]
      6. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\sqrt{\color{blue}{2 - ux}} \cdot \sqrt{ux}\right) \]
      4. lower--.f3289.1

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

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

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

    1. Initial program 58.8%

      \[\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. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
      8. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
      9. lower-fma.f32N/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)}} \]
    8. 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
    9. 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
      4. lower-*.f32N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
      10. lower-PI.f3299.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.7%

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

Alternative 3: 97.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(\left(uy \cdot 2\right) \cdot \pi\right)\\
\mathbf{if}\;t\_0 \leq 0.9996200203895569:\\
\;\;\;\;t\_0 \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \cdot \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\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.99962002

    1. Initial program 65.1%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. 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--.f3259.9

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

      \[\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{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
    7. 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(2 + -1 \cdot ux\right)}} \]
      2. mul-1-negN/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
      4. lower--.f3288.4

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
    8. Applied rewrites88.4%

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

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

    1. Initial program 59.2%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. 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. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
      8. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
      9. lower-fma.f32N/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)}} \]
    8. 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
    9. 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
      4. lower-*.f32N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
      10. lower-PI.f3299.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.7%

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

Alternative 4: 86.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{ux \cdot \left(2 - ux\right)}\\
\mathbf{if}\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \leq 0.9999995231628418:\\
\;\;\;\;\mathsf{fma}\left(-2, t\_0 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \pi\right)\right), t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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.999999523

    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. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + \left(-2 \cdot maxCos + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right)\right)} + -2 \cdot \left(\sqrt{ux \cdot \left(2 + \left(-2 \cdot maxCos + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right)\right)} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \]
    7. Applied rewrites69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-2, \left(\left(uy \cdot uy\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}, \color{blue}{\sqrt{ux \cdot \left(2 + -1 \cdot ux\right)}}\right) \]
    10. Applied rewrites67.7%

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

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

    1. Initial program 60.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 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. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \color{blue}{\left(1 - maxCos\right)}, 2 + -2 \cdot maxCos\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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)}} \]
    6. Step-by-step derivation
      1. lift-+.f32N/A

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
      8. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
      9. lower-fma.f32N/A

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

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

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

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

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

        \[\leadsto \color{blue}{1} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
    10. Recombined 2 regimes into one program.
    11. Final simplification86.3%

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

    Alternative 5: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

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

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

    Alternative 6: 98.2% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 - ux, maxCos \cdot \left(ux \cdot \mathsf{fma}\left(ux, 2, -2\right)\right)\right)} \end{array} \]
    (FPCore (ux uy maxCos)
     :precision binary32
     (*
      (cos (* (* uy 2.0) PI))
      (sqrt (fma ux (- 2.0 ux) (* maxCos (* ux (fma ux 2.0 -2.0)))))))
    float code(float ux, float uy, float maxCos) {
    	return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(fmaf(ux, (2.0f - ux), (maxCos * (ux * fmaf(ux, 2.0f, -2.0f)))));
    }
    
    function code(ux, uy, maxCos)
    	return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(fma(ux, Float32(Float32(2.0) - ux), Float32(maxCos * Float32(ux * fma(ux, Float32(2.0), Float32(-2.0)))))))
    end
    
    \begin{array}{l}
    
    \\
    \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 - ux, maxCos \cdot \left(ux \cdot \mathsf{fma}\left(ux, 2, -2\right)\right)\right)}
    \end{array}
    
    Derivation
    1. Initial program 60.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 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. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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{\color{blue}{maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right) + ux \cdot \left(2 + -1 \cdot ux\right)}} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right) + maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right)}} \]
      2. 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(ux, 2 + -1 \cdot ux, maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right)\right)}} \]
      3. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 93.8% accurate, 1.1× speedup?

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

      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. +-commutativeN/A

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
        8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
        9. unpow2N/A

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
        12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
        13. neg-sub0N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
        14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
        15. +-commutativeN/A

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
        20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
        21. unsub-negN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
        8. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
        9. lower-fma.f32N/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)}} \]
      8. 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
      9. 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
        4. lower-*.f32N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
        10. lower-PI.f3297.9

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

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

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

      1. Initial program 62.1%

        \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. 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--.f3258.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 rewrites58.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{\color{blue}{2 \cdot ux}} \]
      7. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
        2. lower-*.f3271.1

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

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

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

    Alternative 8: 88.3% accurate, 2.2× speedup?

    \[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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
       (fma
        (fma ux (* (+ maxCos -1.0) (- 1.0 maxCos)) (* maxCos -2.0))
        ux
        (* 2.0 ux)))
      (fma (* -2.0 (* uy uy)) (* PI PI) 1.0)))
    float code(float ux, float uy, float maxCos) {
    	return sqrtf(fmaf(fmaf(ux, ((maxCos + -1.0f) * (1.0f - maxCos)), (maxCos * -2.0f)), ux, (2.0f * ux))) * fmaf((-2.0f * (uy * uy)), (((float) M_PI) * ((float) M_PI)), 1.0f);
    }
    
    function code(ux, uy, maxCos)
    	return Float32(sqrt(fma(fma(ux, Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos)), Float32(maxCos * Float32(-2.0))), ux, Float32(Float32(2.0) * ux))) * fma(Float32(Float32(-2.0) * Float32(uy * uy)), Float32(Float32(pi) * Float32(pi)), Float32(1.0)))
    end
    
    \begin{array}{l}
    
    \\
    \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \cdot \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right)
    \end{array}
    
    Derivation
    1. Initial program 60.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 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. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
      8. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
      9. lower-fma.f32N/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)}} \]
    8. 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
    9. 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
      4. lower-*.f32N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-2 \cdot {uy}^{2}}, {\mathsf{PI}\left(\right)}^{2}, 1\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
      10. lower-PI.f3287.4

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

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

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

    Alternative 9: 88.3% accurate, 2.4× speedup?

    \[\begin{array}{l} \\ \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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 ux (* (+ maxCos -1.0) (- 1.0 maxCos)) (fma maxCos -2.0 2.0))))
      (fma (* -2.0 (* uy uy)) (* PI PI) 1.0)))
    float code(float ux, float uy, float maxCos) {
    	return sqrtf((ux * fmaf(ux, ((maxCos + -1.0f) * (1.0f - maxCos)), fmaf(maxCos, -2.0f, 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(ux, Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos)), fma(maxCos, Float32(-2.0), 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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.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 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. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
      8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
      9. unpow2N/A

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
      12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
      13. neg-sub0N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
      15. +-commutativeN/A

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
      20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
      21. unsub-negN/A

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
      10. lower-PI.f3287.3

        \[\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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
    8. Applied rewrites87.3%

      \[\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(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
    9. Final simplification87.3%

      \[\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)} \cdot \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right) \]
    10. Add Preprocessing

    Alternative 10: 83.1% accurate, 2.8× speedup?

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

      1. Initial program 60.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 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. +-commutativeN/A

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
        8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
        9. unpow2N/A

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
        12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
        13. neg-sub0N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
        14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
        15. +-commutativeN/A

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
        20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
        21. unsub-negN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
        8. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
        9. lower-fma.f32N/A

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

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

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

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

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

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

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

        1. Initial program 60.8%

          \[\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{\color{blue}{2 \cdot ux}} \]
        7. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
          2. lower-*.f3271.9

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
        9. 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} \]
        10. 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.f3253.3

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right)} \cdot \sqrt{ux \cdot 2} \]
      10. Recombined 2 regimes into one program.
      11. Final simplification82.4%

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

      Alternative 11: 83.1% accurate, 2.9× speedup?

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

        1. Initial program 60.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 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 rewrites60.6%

          \[\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. Step-by-step derivation
          1. lift--.f32N/A

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

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

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

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

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

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

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

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

            \[\leadsto \sqrt{\mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \left(\left(\mathsf{neg}\left(ux\right)\right) \cdot \left(maxCos + -1\right)\right) + \left(\color{blue}{-1 \cdot \mathsf{fma}\left(ux, maxCos, 1 - ux\right)} + 1\right)} \]
          10. neg-mul-1N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(maxCos, \mathsf{neg}\left(ux\right), ux\right), \color{blue}{\mathsf{fma}\left(ux, -1 \cdot maxCos, ux\right)}\right)} \]
          10. mul-1-negN/A

            \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(maxCos, \mathsf{neg}\left(ux\right), ux\right), \mathsf{fma}\left(ux, \color{blue}{\mathsf{neg}\left(maxCos\right)}, ux\right)\right)} \]
          11. lower-neg.f3297.9

            \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(maxCos, -ux, ux\right), \mathsf{fma}\left(ux, \color{blue}{-maxCos}, ux\right)\right)} \]
        10. Applied rewrites97.9%

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

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

        1. Initial program 60.8%

          \[\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{\color{blue}{2 \cdot ux}} \]
        7. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
          2. lower-*.f3271.9

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
        9. 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} \]
        10. 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.f3253.3

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

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

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

      Alternative 12: 79.9% accurate, 3.7× speedup?

      \[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(maxCos, -ux, ux\right), \mathsf{fma}\left(ux, -maxCos, ux\right)\right)} \end{array} \]
      (FPCore (ux uy maxCos)
       :precision binary32
       (sqrt
        (fma
         (fma ux maxCos (- 1.0 ux))
         (fma maxCos (- ux) ux)
         (fma ux (- maxCos) ux))))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf(fmaf(fmaf(ux, maxCos, (1.0f - ux)), fmaf(maxCos, -ux, ux), fmaf(ux, -maxCos, ux)));
      }
      
      function code(ux, uy, maxCos)
      	return sqrt(fma(fma(ux, maxCos, Float32(Float32(1.0) - ux)), fma(maxCos, Float32(-ux), ux), fma(ux, Float32(-maxCos), ux)))
      end
      
      \begin{array}{l}
      
      \\
      \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(maxCos, -ux, ux\right), \mathsf{fma}\left(ux, -maxCos, ux\right)\right)}
      \end{array}
      
      Derivation
      1. Initial program 60.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 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 rewrites50.8%

        \[\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. Step-by-step derivation
        1. lift--.f32N/A

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

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

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

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

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

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

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

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

          \[\leadsto \sqrt{\mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \left(\left(\mathsf{neg}\left(ux\right)\right) \cdot \left(maxCos + -1\right)\right) + \left(\color{blue}{-1 \cdot \mathsf{fma}\left(ux, maxCos, 1 - ux\right)} + 1\right)} \]
        10. neg-mul-1N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(maxCos, \mathsf{neg}\left(ux\right), ux\right), \color{blue}{\mathsf{fma}\left(ux, -1 \cdot maxCos, ux\right)}\right)} \]
        10. mul-1-negN/A

          \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(maxCos, \mathsf{neg}\left(ux\right), ux\right), \mathsf{fma}\left(ux, \color{blue}{\mathsf{neg}\left(maxCos\right)}, ux\right)\right)} \]
        11. lower-neg.f3278.6

          \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(maxCos, -ux, ux\right), \mathsf{fma}\left(ux, \color{blue}{-maxCos}, ux\right)\right)} \]
      10. Applied rewrites78.6%

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

      Alternative 13: 79.8% accurate, 4.0× speedup?

      \[\begin{array}{l} \\ \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(-2, maxCos, 2\right)\right)} \end{array} \]
      (FPCore (ux uy maxCos)
       :precision binary32
       (sqrt
        (* ux (fma ux (* (+ maxCos -1.0) (- 1.0 maxCos)) (fma -2.0 maxCos 2.0)))))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf((ux * fmaf(ux, ((maxCos + -1.0f) * (1.0f - maxCos)), fmaf(-2.0f, maxCos, 2.0f))));
      }
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(ux * fma(ux, Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos)), fma(Float32(-2.0), maxCos, Float32(2.0)))))
      end
      
      \begin{array}{l}
      
      \\
      \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(-2, maxCos, 2\right)\right)}
      \end{array}
      
      Derivation
      1. Initial program 60.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 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. +-commutativeN/A

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + \left(2 + -2 \cdot maxCos\right)\right)} \]
        8. 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(ux, \mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right), 2 + -2 \cdot maxCos\right)}} \]
        9. unpow2N/A

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(0 - \left(maxCos - 1\right)\right)}, 2 + -2 \cdot maxCos\right)} \]
        12. 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(ux, \left(maxCos - 1\right) \cdot \color{blue}{\left(\left(0 - maxCos\right) + 1\right)}, 2 + -2 \cdot maxCos\right)} \]
        13. neg-sub0N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} + 1\right), 2 + -2 \cdot maxCos\right)} \]
        14. 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(ux, \left(maxCos - 1\right) \cdot \left(\color{blue}{-1 \cdot maxCos} + 1\right), 2 + -2 \cdot maxCos\right)} \]
        15. +-commutativeN/A

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{\left(maxCos + -1\right)} \cdot \left(1 + -1 \cdot maxCos\right), 2 + -2 \cdot maxCos\right)} \]
        20. 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(ux, \left(maxCos + -1\right) \cdot \left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right), 2 + -2 \cdot maxCos\right)} \]
        21. unsub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 14: 75.6% accurate, 7.8× speedup?

      \[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(ux, 1 - ux, ux\right)} \end{array} \]
      (FPCore (ux uy maxCos) :precision binary32 (sqrt (fma ux (- 1.0 ux) ux)))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf(fmaf(ux, (1.0f - ux), ux));
      }
      
      function code(ux, uy, maxCos)
      	return sqrt(fma(ux, Float32(Float32(1.0) - ux), ux))
      end
      
      \begin{array}{l}
      
      \\
      \sqrt{\mathsf{fma}\left(ux, 1 - ux, ux\right)}
      \end{array}
      
      Derivation
      1. Initial program 60.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 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 rewrites50.8%

        \[\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. Step-by-step derivation
        1. lift--.f32N/A

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

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

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

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

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

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

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

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

          \[\leadsto \sqrt{\mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \left(\left(\mathsf{neg}\left(ux\right)\right) \cdot \left(maxCos + -1\right)\right) + \left(\color{blue}{-1 \cdot \mathsf{fma}\left(ux, maxCos, 1 - ux\right)} + 1\right)} \]
        10. neg-mul-1N/A

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

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

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

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

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

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

          \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - ux, ux\right)}} \]
        3. lower--.f3274.5

          \[\leadsto \sqrt{\mathsf{fma}\left(ux, \color{blue}{1 - ux}, ux\right)} \]
      10. Applied rewrites74.5%

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

      Alternative 15: 62.3% accurate, 9.8× speedup?

      \[\begin{array}{l} \\ \sqrt{2 \cdot ux} \end{array} \]
      (FPCore (ux uy maxCos) :precision binary32 (sqrt (* 2.0 ux)))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf((2.0f * ux));
      }
      
      real(4) function code(ux, uy, maxcos)
          real(4), intent (in) :: ux
          real(4), intent (in) :: uy
          real(4), intent (in) :: maxcos
          code = sqrt((2.0e0 * ux))
      end function
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(Float32(2.0) * ux))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = sqrt((single(2.0) * ux));
      end
      
      \begin{array}{l}
      
      \\
      \sqrt{2 \cdot ux}
      \end{array}
      
      Derivation
      1. Initial program 60.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.6

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

        \[\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{\color{blue}{2 \cdot ux}} \]
      7. Step-by-step derivation
        1. *-commutativeN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
      8. Applied rewrites72.2%

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

        \[\leadsto \color{blue}{1} \cdot \sqrt{ux \cdot 2} \]
      10. Step-by-step derivation
        1. Applied rewrites60.6%

          \[\leadsto \color{blue}{1} \cdot \sqrt{ux \cdot 2} \]
        2. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto 1 \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
          2. lift-sqrt.f32N/A

            \[\leadsto 1 \cdot \color{blue}{\sqrt{ux \cdot 2}} \]
          3. *-lft-identity60.6

            \[\leadsto \color{blue}{\sqrt{ux \cdot 2}} \]
          4. lift-*.f32N/A

            \[\leadsto \sqrt{\color{blue}{ux \cdot 2}} \]
          5. *-commutativeN/A

            \[\leadsto \sqrt{\color{blue}{2 \cdot ux}} \]
          6. lower-*.f3260.6

            \[\leadsto \sqrt{\color{blue}{2 \cdot ux}} \]
        3. Applied rewrites60.6%

          \[\leadsto \color{blue}{\sqrt{2 \cdot ux}} \]
        4. Add Preprocessing

        Reproduce

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