UniformSampleCone, x

Percentage Accurate: 57.1% → 99.0%
Time: 14.8s
Alternatives: 22
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 22 alternatives:

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

Initial Program: 57.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.6% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, -ux\right), 1 - maxCos, 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}{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--.f3293.5

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

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

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

    1. Initial program 58.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(maxCos + -1, \left(1 - maxCos\right) \cdot \left(ux \cdot ux\right), \mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \color{blue}{\log \left(e^{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      2. *-un-lft-identityN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(\left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) + 1\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}} \]
    11. Simplified99.4%

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

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

Alternative 3: 93.9% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 54.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{1 - \color{blue}{\left(1 + ux \cdot \left(2 \cdot maxCos - 2\right)\right)}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

    1. Initial program 58.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(maxCos + -1, \left(1 - maxCos\right) \cdot \left(ux \cdot ux\right), \mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \color{blue}{\log \left(e^{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      2. *-un-lft-identityN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(\left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) + 1\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}} \]
    11. Simplified98.8%

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

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

Alternative 4: 97.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 58.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(maxCos + -1, \left(1 - maxCos\right) \cdot \left(ux \cdot ux\right), \mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \color{blue}{\log \left(e^{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      2. *-un-lft-identityN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(\left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) + 1\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}} \]
    11. Simplified99.4%

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

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

    1. Initial program 55.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{\color{blue}{2}}{ux} + -1\right)} \]
      9. lower-/.f3293.8

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

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

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

Alternative 5: 97.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 58.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(maxCos + -1, \left(1 - maxCos\right) \cdot \left(ux \cdot ux\right), \mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \color{blue}{\log \left(e^{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      2. *-un-lft-identityN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(\left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) + 1\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}} \]
    11. Simplified99.4%

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

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

    1. Initial program 55.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(ux \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{\frac{\color{blue}{2}}{ux} + -1} \]
      13. lower-/.f3293.8

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

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

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

Alternative 6: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 98.3% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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(2, ux, -2\right)}\right)\right)} \]
  8. Simplified98.4%

    \[\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(2, ux, -2\right)\right)\right)}} \]
  9. Final simplification98.4%

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

Alternative 8: 97.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 58.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 ux around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(maxCos + -1, \left(1 - maxCos\right) \cdot \left(ux \cdot ux\right), \mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \color{blue}{\log \left(e^{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      2. *-un-lft-identityN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(\left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) + 1\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}} \]
    11. Simplified99.4%

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

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

    1. Initial program 55.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{\color{blue}{2}}{ux} + -1\right)} \]
      9. lower-/.f3293.8

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{neg}\left(ux\right)\right) \cdot ux + \color{blue}{\frac{2}{ux}} \cdot \left(ux \cdot ux\right)} \]
      9. div-invN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{neg}\left(ux\right), ux, \color{blue}{ux \cdot 2}\right)} \]
      20. lower-*.f3293.8

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

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

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

Alternative 9: 88.4% accurate, 2.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(maxCos + -1, \left(1 - maxCos\right) \cdot \left(ux \cdot ux\right), \mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux\right)} \cdot \cos \left(2 \cdot \left(uy \cdot \color{blue}{\log \left(e^{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
    2. *-un-lft-identityN/A

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(\left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)} \]
  10. Step-by-step derivation
    1. associate-*r*N/A

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

      \[\leadsto \color{blue}{\left(-2 \cdot \left({uy}^{2} \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot {\log \mathsf{E}\left(\right)}^{2}\right)\right) + 1\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}} \]
  11. Simplified90.7%

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

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

Alternative 10: 88.4% accurate, 2.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 86.6% accurate, 2.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 8.20000016e-4

    1. Initial program 58.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 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. Simplified58.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. Taylor expanded in ux around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.20000016e-4 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 55.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos - 1\right) \cdot \left(1 + -1 \cdot maxCos\right) + \color{blue}{\left(2 \cdot \frac{1}{ux} + -2 \cdot \frac{maxCos}{ux}\right)}\right)} \]
    5. Simplified98.7%

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{\color{blue}{2}}{ux} + -1\right)} \]
      9. lower-/.f3294.2

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{2}{ux} + -1} \cdot \color{blue}{\mathsf{fma}\left(-2, ux \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right), ux\right)} \]
    11. Simplified71.7%

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

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

Alternative 12: 86.6% accurate, 2.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 8.20000016e-4

    1. Initial program 58.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 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. Simplified58.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. Taylor expanded in ux around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.20000016e-4 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 55.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos - 1\right) \cdot \left(1 + -1 \cdot maxCos\right) + \color{blue}{\left(2 \cdot \frac{1}{ux} + -2 \cdot \frac{maxCos}{ux}\right)}\right)} \]
    5. Simplified98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(ux \cdot \left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) \cdot \sqrt{2 \cdot \frac{1}{ux} - 1}} \]
    12. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto ux \cdot \left(\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{2 \cdot \frac{1}{ux} - 1}\right) \]
      11. lower-*.f32N/A

        \[\leadsto ux \cdot \left(\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{2 \cdot \frac{1}{ux} - 1}\right) \]
      12. lower-PI.f32N/A

        \[\leadsto ux \cdot \left(\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{2 \cdot \frac{1}{ux} - 1}\right) \]
      13. lower-PI.f32N/A

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

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

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

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

        \[\leadsto ux \cdot \left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\color{blue}{2 \cdot \frac{1}{ux} + -1}}\right) \]
    13. Simplified71.5%

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

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

Alternative 13: 88.4% accurate, 2.4× speedup?

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

\\
\sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, -ux\right), 1 - maxCos, 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 57.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. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 83.6% accurate, 2.6× speedup?

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

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

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


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

    1. Initial program 59.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 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. Simplified58.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. Taylor expanded in ux around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 53.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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 80.1% accurate, 3.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 80.1% accurate, 3.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 80.0% accurate, 4.7× speedup?

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

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    4. distribute-rgt-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    5. unpow2N/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\mathsf{neg}\left(\color{blue}{\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)}\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    7. sub-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)}\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    8. metadata-evalN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\left(maxCos + \color{blue}{-1}\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    9. distribute-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(maxCos\right)\right) + \left(\mathsf{neg}\left(-1\right)\right)\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    10. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\color{blue}{-1 \cdot maxCos} + \left(\mathsf{neg}\left(-1\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    11. metadata-evalN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(-1 \cdot maxCos + \color{blue}{1}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    12. +-commutativeN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 + -1 \cdot maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    13. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    14. sub-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 - maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    15. lower-fma.f32N/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos - 1\right), -2 \cdot \left(maxCos - 1\right)\right)}} \]
  8. Simplified81.5%

    \[\leadsto \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot \left(maxCos + -1\right)\right)}} \]
  9. Taylor expanded in ux around 0

    \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right)}} \]
  10. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right)}} \]
    2. +-commutativeN/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\left(ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)}} \]
    3. associate-*r*N/A

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(maxCos - 1\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    4. distribute-rgt-outN/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\left(\left(maxCos - 1\right) \cdot \left(ux \cdot \left(1 - maxCos\right) + -2\right)\right)}} \]
    5. lower-*.f32N/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\left(\left(maxCos - 1\right) \cdot \left(ux \cdot \left(1 - maxCos\right) + -2\right)\right)}} \]
    6. sub-negN/A

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(ux \cdot \left(1 - maxCos\right) + -2\right)\right)} \]
    7. metadata-evalN/A

      \[\leadsto \sqrt{ux \cdot \left(\left(maxCos + \color{blue}{-1}\right) \cdot \left(ux \cdot \left(1 - maxCos\right) + -2\right)\right)} \]
    8. lower-+.f32N/A

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(maxCos + -1\right)} \cdot \left(ux \cdot \left(1 - maxCos\right) + -2\right)\right)} \]
    9. lower-fma.f32N/A

      \[\leadsto \sqrt{ux \cdot \left(\left(maxCos + -1\right) \cdot \color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right)}\right)} \]
    10. lower--.f3281.5

      \[\leadsto \sqrt{ux \cdot \left(\left(maxCos + -1\right) \cdot \mathsf{fma}\left(ux, \color{blue}{1 - maxCos}, -2\right)\right)} \]
  11. Simplified81.5%

    \[\leadsto \sqrt{\color{blue}{ux \cdot \left(\left(maxCos + -1\right) \cdot \mathsf{fma}\left(ux, 1 - maxCos, -2\right)\right)}} \]
  12. Add Preprocessing

Alternative 18: 79.1% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, -ux \cdot ux\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt (fma (fma maxCos -2.0 2.0) ux (- (* ux ux)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(fmaf(fmaf(maxCos, -2.0f, 2.0f), ux, -(ux * ux)));
}
function code(ux, uy, maxCos)
	return sqrt(fma(fma(maxCos, Float32(-2.0), Float32(2.0)), ux, Float32(-Float32(ux * ux))))
end
\begin{array}{l}

\\
\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, -ux \cdot ux\right)}
\end{array}
Derivation
  1. Initial program 57.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. Simplified51.4%

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(-ux, maxCos + -1, -1\right), 1\right)}} \]
  6. Taylor expanded in ux around 0

    \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
  7. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
    2. +-commutativeN/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + -2 \cdot \left(maxCos - 1\right)\right)}} \]
    3. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    4. distribute-rgt-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    5. unpow2N/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\mathsf{neg}\left(\color{blue}{\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)}\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    7. sub-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)}\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    8. metadata-evalN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\left(maxCos + \color{blue}{-1}\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    9. distribute-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(maxCos\right)\right) + \left(\mathsf{neg}\left(-1\right)\right)\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    10. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\color{blue}{-1 \cdot maxCos} + \left(\mathsf{neg}\left(-1\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    11. metadata-evalN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(-1 \cdot maxCos + \color{blue}{1}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    12. +-commutativeN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 + -1 \cdot maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    13. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    14. sub-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 - maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    15. lower-fma.f32N/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos - 1\right), -2 \cdot \left(maxCos - 1\right)\right)}} \]
  8. Simplified81.5%

    \[\leadsto \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot \left(maxCos + -1\right)\right)}} \]
  9. Step-by-step derivation
    1. lift-+.f32N/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(maxCos + -1\right)} \cdot \left(1 - maxCos\right)\right) + -2 \cdot \left(maxCos + -1\right)\right)} \]
    2. lift--.f32N/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \color{blue}{\left(1 - maxCos\right)}\right) + -2 \cdot \left(maxCos + -1\right)\right)} \]
    3. lift-*.f32N/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \color{blue}{\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)} + -2 \cdot \left(maxCos + -1\right)\right)} \]
    4. lift-+.f32N/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + -2 \cdot \color{blue}{\left(maxCos + -1\right)}\right)} \]
    5. lift-*.f32N/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + \color{blue}{-2 \cdot \left(maxCos + -1\right)}\right)} \]
    6. +-commutativeN/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-2 \cdot \left(maxCos + -1\right) + ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)}} \]
    7. distribute-lft-inN/A

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos + -1\right)\right) + ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)}} \]
    8. *-commutativeN/A

      \[\leadsto \sqrt{\color{blue}{\left(-2 \cdot \left(maxCos + -1\right)\right) \cdot ux} + ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)} \]
    9. lower-fma.f32N/A

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(-2 \cdot \left(maxCos + -1\right), ux, ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)\right)}} \]
    10. lift-*.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\color{blue}{-2 \cdot \left(maxCos + -1\right)}, ux, ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)\right)} \]
    11. lift-+.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(-2 \cdot \color{blue}{\left(maxCos + -1\right)}, ux, ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)\right)} \]
    12. distribute-rgt-inN/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\color{blue}{maxCos \cdot -2 + -1 \cdot -2}, ux, ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)\right)} \]
    13. metadata-evalN/A

      \[\leadsto \sqrt{\mathsf{fma}\left(maxCos \cdot -2 + \color{blue}{2}, ux, ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)\right)} \]
    14. lift-fma.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(maxCos, -2, 2\right)}, ux, ux \cdot \left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)\right)} \]
    15. associate-*r*N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \color{blue}{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)}\right)} \]
    16. lift-*.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \color{blue}{\left(ux \cdot ux\right)} \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)} \]
    17. *-commutativeN/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \color{blue}{\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) \cdot \left(ux \cdot ux\right)}\right)} \]
    18. lift-*.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \color{blue}{\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)} \cdot \left(ux \cdot ux\right)\right)} \]
  10. Applied egg-rr81.6%

    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \left(maxCos + -1\right) \cdot \left(\left(1 - maxCos\right) \cdot \left(ux \cdot ux\right)\right)\right)}} \]
  11. Taylor expanded in maxCos around 0

    \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \color{blue}{-1 \cdot {ux}^{2}}\right)} \]
  12. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \color{blue}{\mathsf{neg}\left({ux}^{2}\right)}\right)} \]
    2. lower-neg.f32N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \color{blue}{\mathsf{neg}\left({ux}^{2}\right)}\right)} \]
    3. unpow2N/A

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \mathsf{neg}\left(\color{blue}{ux \cdot ux}\right)\right)} \]
    4. lower-*.f3280.1

      \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, -\color{blue}{ux \cdot ux}\right)} \]
  13. Simplified80.1%

    \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -2, 2\right), ux, \color{blue}{-ux \cdot ux}\right)} \]
  14. Add Preprocessing

Alternative 19: 79.0% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \sqrt{ux \cdot \mathsf{fma}\left(ux, -1, \left(maxCos + -1\right) \cdot -2\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt (* ux (fma ux -1.0 (* (+ maxCos -1.0) -2.0)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux * fmaf(ux, -1.0f, ((maxCos + -1.0f) * -2.0f))));
}
function code(ux, uy, maxCos)
	return sqrt(Float32(ux * fma(ux, Float32(-1.0), Float32(Float32(maxCos + Float32(-1.0)) * Float32(-2.0)))))
end
\begin{array}{l}

\\
\sqrt{ux \cdot \mathsf{fma}\left(ux, -1, \left(maxCos + -1\right) \cdot -2\right)}
\end{array}
Derivation
  1. Initial program 57.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. Simplified51.4%

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(-ux, maxCos + -1, -1\right), 1\right)}} \]
  6. Taylor expanded in ux around 0

    \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
  7. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
    2. +-commutativeN/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + -2 \cdot \left(maxCos - 1\right)\right)}} \]
    3. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    4. distribute-rgt-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    5. unpow2N/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\mathsf{neg}\left(\color{blue}{\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)}\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
    7. sub-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)}\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    8. metadata-evalN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\left(maxCos + \color{blue}{-1}\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    9. distribute-neg-inN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(maxCos\right)\right) + \left(\mathsf{neg}\left(-1\right)\right)\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    10. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\color{blue}{-1 \cdot maxCos} + \left(\mathsf{neg}\left(-1\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    11. metadata-evalN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(-1 \cdot maxCos + \color{blue}{1}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    12. +-commutativeN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 + -1 \cdot maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    13. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    14. sub-negN/A

      \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 - maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
    15. lower-fma.f32N/A

      \[\leadsto \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos - 1\right), -2 \cdot \left(maxCos - 1\right)\right)}} \]
  8. Simplified81.5%

    \[\leadsto \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot \left(maxCos + -1\right)\right)}} \]
  9. Taylor expanded in maxCos around 0

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{-1}, -2 \cdot \left(maxCos + -1\right)\right)} \]
  10. Step-by-step derivation
    1. Simplified80.1%

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \color{blue}{-1}, -2 \cdot \left(maxCos + -1\right)\right)} \]
    2. Final simplification80.1%

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, -1, \left(maxCos + -1\right) \cdot -2\right)} \]
    3. Add Preprocessing

    Alternative 20: 75.8% accurate, 6.5× speedup?

    \[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(-ux, ux, ux \cdot 2\right)} \end{array} \]
    (FPCore (ux uy maxCos) :precision binary32 (sqrt (fma (- ux) ux (* ux 2.0))))
    float code(float ux, float uy, float maxCos) {
    	return sqrtf(fmaf(-ux, ux, (ux * 2.0f)));
    }
    
    function code(ux, uy, maxCos)
    	return sqrt(fma(Float32(-ux), ux, Float32(ux * Float32(2.0))))
    end
    
    \begin{array}{l}
    
    \\
    \sqrt{\mathsf{fma}\left(-ux, ux, ux \cdot 2\right)}
    \end{array}
    
    Derivation
    1. Initial program 57.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. Simplified51.4%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(-ux, maxCos + -1, -1\right), 1\right)}} \]
    6. Taylor expanded in ux around 0

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
    7. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + -2 \cdot \left(maxCos - 1\right)\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      5. unpow2N/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\mathsf{neg}\left(\color{blue}{\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)}\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      7. sub-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)}\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\left(maxCos + \color{blue}{-1}\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      9. distribute-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(maxCos\right)\right) + \left(\mathsf{neg}\left(-1\right)\right)\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      10. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\color{blue}{-1 \cdot maxCos} + \left(\mathsf{neg}\left(-1\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      11. metadata-evalN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(-1 \cdot maxCos + \color{blue}{1}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      12. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 + -1 \cdot maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      13. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      14. sub-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 - maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      15. lower-fma.f32N/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos - 1\right), -2 \cdot \left(maxCos - 1\right)\right)}} \]
    8. Simplified81.5%

      \[\leadsto \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot \left(maxCos + -1\right)\right)}} \]
    9. Taylor expanded in maxCos around 0

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-1 \cdot ux + 2\right)}} \]
      2. distribute-rgt-inN/A

        \[\leadsto \sqrt{\color{blue}{\left(-1 \cdot ux\right) \cdot ux + 2 \cdot ux}} \]
      3. associate-*r*N/A

        \[\leadsto \sqrt{\color{blue}{-1 \cdot \left(ux \cdot ux\right)} + 2 \cdot ux} \]
      4. unpow2N/A

        \[\leadsto \sqrt{-1 \cdot \color{blue}{{ux}^{2}} + 2 \cdot ux} \]
      5. lower-sqrt.f32N/A

        \[\leadsto \color{blue}{\sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
      6. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{2 \cdot ux + -1 \cdot {ux}^{2}}} \]
      7. mul-1-negN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(\mathsf{neg}\left({ux}^{2}\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \sqrt{2 \cdot ux + \left(\mathsf{neg}\left(\color{blue}{ux \cdot ux}\right)\right)} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right) \cdot ux}} \]
      10. mul-1-negN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(-1 \cdot ux\right)} \cdot ux} \]
      11. distribute-rgt-inN/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
      12. lower-*.f32N/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
      13. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)} \]
      14. unsub-negN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
      15. lower--.f3276.9

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
    11. Simplified76.9%

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 - ux\right)}} \]
    12. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)}} \]
      2. distribute-rgt-inN/A

        \[\leadsto \sqrt{\color{blue}{2 \cdot ux + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux}} \]
      3. unpow1N/A

        \[\leadsto \sqrt{2 \cdot \color{blue}{{ux}^{1}} + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      4. metadata-evalN/A

        \[\leadsto \sqrt{2 \cdot {ux}^{\color{blue}{\left(-1 + 2\right)}} + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      5. pow-prod-upN/A

        \[\leadsto \sqrt{2 \cdot \color{blue}{\left({ux}^{-1} \cdot {ux}^{2}\right)} + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      6. inv-powN/A

        \[\leadsto \sqrt{2 \cdot \left(\color{blue}{\frac{1}{ux}} \cdot {ux}^{2}\right) + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      7. pow2N/A

        \[\leadsto \sqrt{2 \cdot \left(\frac{1}{ux} \cdot \color{blue}{\left(ux \cdot ux\right)}\right) + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      8. lift-*.f32N/A

        \[\leadsto \sqrt{2 \cdot \left(\frac{1}{ux} \cdot \color{blue}{\left(ux \cdot ux\right)}\right) + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      9. associate-*l*N/A

        \[\leadsto \sqrt{\color{blue}{\left(2 \cdot \frac{1}{ux}\right) \cdot \left(ux \cdot ux\right)} + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      10. div-invN/A

        \[\leadsto \sqrt{\color{blue}{\frac{2}{ux}} \cdot \left(ux \cdot ux\right) + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      11. lift-/.f32N/A

        \[\leadsto \sqrt{\color{blue}{\frac{2}{ux}} \cdot \left(ux \cdot ux\right) + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux} \]
      12. neg-mul-1N/A

        \[\leadsto \sqrt{\frac{2}{ux} \cdot \left(ux \cdot ux\right) + \color{blue}{\left(-1 \cdot ux\right)} \cdot ux} \]
      13. associate-*r*N/A

        \[\leadsto \sqrt{\frac{2}{ux} \cdot \left(ux \cdot ux\right) + \color{blue}{-1 \cdot \left(ux \cdot ux\right)}} \]
      14. lift-*.f32N/A

        \[\leadsto \sqrt{\frac{2}{ux} \cdot \left(ux \cdot ux\right) + -1 \cdot \color{blue}{\left(ux \cdot ux\right)}} \]
      15. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{-1 \cdot \left(ux \cdot ux\right) + \frac{2}{ux} \cdot \left(ux \cdot ux\right)}} \]
      16. lift-/.f32N/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + \color{blue}{\frac{2}{ux}} \cdot \left(ux \cdot ux\right)} \]
      17. div-invN/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + \color{blue}{\left(2 \cdot \frac{1}{ux}\right)} \cdot \left(ux \cdot ux\right)} \]
      18. associate-*l*N/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + \color{blue}{2 \cdot \left(\frac{1}{ux} \cdot \left(ux \cdot ux\right)\right)}} \]
      19. inv-powN/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + 2 \cdot \left(\color{blue}{{ux}^{-1}} \cdot \left(ux \cdot ux\right)\right)} \]
      20. lift-*.f32N/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + 2 \cdot \left({ux}^{-1} \cdot \color{blue}{\left(ux \cdot ux\right)}\right)} \]
      21. pow2N/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + 2 \cdot \left({ux}^{-1} \cdot \color{blue}{{ux}^{2}}\right)} \]
      22. pow-prod-upN/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + 2 \cdot \color{blue}{{ux}^{\left(-1 + 2\right)}}} \]
      23. metadata-evalN/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + 2 \cdot {ux}^{\color{blue}{1}}} \]
      24. unpow1N/A

        \[\leadsto \sqrt{-1 \cdot \left(ux \cdot ux\right) + 2 \cdot \color{blue}{ux}} \]
    13. Applied egg-rr77.0%

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(-ux, ux, ux \cdot 2\right)}} \]
    14. Add Preprocessing

    Alternative 21: 75.8% accurate, 8.2× speedup?

    \[\begin{array}{l} \\ \sqrt{ux \cdot \left(2 - ux\right)} \end{array} \]
    (FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (- 2.0 ux))))
    float code(float ux, float uy, float maxCos) {
    	return sqrtf((ux * (2.0f - ux)));
    }
    
    real(4) function code(ux, uy, maxcos)
        real(4), intent (in) :: ux
        real(4), intent (in) :: uy
        real(4), intent (in) :: maxcos
        code = sqrt((ux * (2.0e0 - ux)))
    end function
    
    function code(ux, uy, maxCos)
    	return sqrt(Float32(ux * Float32(Float32(2.0) - ux)))
    end
    
    function tmp = code(ux, uy, maxCos)
    	tmp = sqrt((ux * (single(2.0) - ux)));
    end
    
    \begin{array}{l}
    
    \\
    \sqrt{ux \cdot \left(2 - ux\right)}
    \end{array}
    
    Derivation
    1. Initial program 57.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. Simplified51.4%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(-ux, maxCos + -1, -1\right), 1\right)}} \]
    6. Taylor expanded in ux around 0

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
    7. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + -2 \cdot \left(maxCos - 1\right)\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      5. unpow2N/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\mathsf{neg}\left(\color{blue}{\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)}\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      7. sub-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)}\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\left(maxCos + \color{blue}{-1}\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      9. distribute-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(maxCos\right)\right) + \left(\mathsf{neg}\left(-1\right)\right)\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      10. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\color{blue}{-1 \cdot maxCos} + \left(\mathsf{neg}\left(-1\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      11. metadata-evalN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(-1 \cdot maxCos + \color{blue}{1}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      12. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 + -1 \cdot maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      13. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      14. sub-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 - maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      15. lower-fma.f32N/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos - 1\right), -2 \cdot \left(maxCos - 1\right)\right)}} \]
    8. Simplified81.5%

      \[\leadsto \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot \left(maxCos + -1\right)\right)}} \]
    9. Taylor expanded in maxCos around 0

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-1 \cdot ux + 2\right)}} \]
      2. distribute-rgt-inN/A

        \[\leadsto \sqrt{\color{blue}{\left(-1 \cdot ux\right) \cdot ux + 2 \cdot ux}} \]
      3. associate-*r*N/A

        \[\leadsto \sqrt{\color{blue}{-1 \cdot \left(ux \cdot ux\right)} + 2 \cdot ux} \]
      4. unpow2N/A

        \[\leadsto \sqrt{-1 \cdot \color{blue}{{ux}^{2}} + 2 \cdot ux} \]
      5. lower-sqrt.f32N/A

        \[\leadsto \color{blue}{\sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
      6. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{2 \cdot ux + -1 \cdot {ux}^{2}}} \]
      7. mul-1-negN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(\mathsf{neg}\left({ux}^{2}\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \sqrt{2 \cdot ux + \left(\mathsf{neg}\left(\color{blue}{ux \cdot ux}\right)\right)} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right) \cdot ux}} \]
      10. mul-1-negN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(-1 \cdot ux\right)} \cdot ux} \]
      11. distribute-rgt-inN/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
      12. lower-*.f32N/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
      13. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)} \]
      14. unsub-negN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
      15. lower--.f3276.9

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
    11. Simplified76.9%

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 - ux\right)}} \]
    12. Add Preprocessing

    Alternative 22: 62.4% accurate, 9.8× speedup?

    \[\begin{array}{l} \\ \sqrt{ux \cdot 2} \end{array} \]
    (FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux 2.0)))
    float code(float ux, float uy, float maxCos) {
    	return sqrtf((ux * 2.0f));
    }
    
    real(4) function code(ux, uy, maxcos)
        real(4), intent (in) :: ux
        real(4), intent (in) :: uy
        real(4), intent (in) :: maxcos
        code = sqrt((ux * 2.0e0))
    end function
    
    function code(ux, uy, maxCos)
    	return sqrt(Float32(ux * Float32(2.0)))
    end
    
    function tmp = code(ux, uy, maxCos)
    	tmp = sqrt((ux * single(2.0)));
    end
    
    \begin{array}{l}
    
    \\
    \sqrt{ux \cdot 2}
    \end{array}
    
    Derivation
    1. Initial program 57.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. Simplified51.4%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), \mathsf{fma}\left(-ux, maxCos + -1, -1\right), 1\right)}} \]
    6. Taylor expanded in ux around 0

      \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
    7. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(-2 \cdot \left(maxCos - 1\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + -2 \cdot \left(maxCos - 1\right)\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(\color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(\color{blue}{ux \cdot \left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      5. unpow2N/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\mathsf{neg}\left(\color{blue}{\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)}\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right) \cdot \left(maxCos - 1\right)\right)} + -2 \cdot \left(maxCos - 1\right)\right)} \]
      7. sub-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)}\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\mathsf{neg}\left(\left(maxCos + \color{blue}{-1}\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      9. distribute-neg-inN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(maxCos\right)\right) + \left(\mathsf{neg}\left(-1\right)\right)\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      10. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(\color{blue}{-1 \cdot maxCos} + \left(\mathsf{neg}\left(-1\right)\right)\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      11. metadata-evalN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(-1 \cdot maxCos + \color{blue}{1}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      12. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 + -1 \cdot maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      13. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)}\right) \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      14. sub-negN/A

        \[\leadsto \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(1 - maxCos\right)} \cdot \left(maxCos - 1\right)\right) + -2 \cdot \left(maxCos - 1\right)\right)} \]
      15. lower-fma.f32N/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(ux, \left(1 - maxCos\right) \cdot \left(maxCos - 1\right), -2 \cdot \left(maxCos - 1\right)\right)}} \]
    8. Simplified81.5%

      \[\leadsto \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot \left(maxCos + -1\right)\right)}} \]
    9. Taylor expanded in maxCos around 0

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(-1 \cdot ux + 2\right)}} \]
      2. distribute-rgt-inN/A

        \[\leadsto \sqrt{\color{blue}{\left(-1 \cdot ux\right) \cdot ux + 2 \cdot ux}} \]
      3. associate-*r*N/A

        \[\leadsto \sqrt{\color{blue}{-1 \cdot \left(ux \cdot ux\right)} + 2 \cdot ux} \]
      4. unpow2N/A

        \[\leadsto \sqrt{-1 \cdot \color{blue}{{ux}^{2}} + 2 \cdot ux} \]
      5. lower-sqrt.f32N/A

        \[\leadsto \color{blue}{\sqrt{-1 \cdot {ux}^{2} + 2 \cdot ux}} \]
      6. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{2 \cdot ux + -1 \cdot {ux}^{2}}} \]
      7. mul-1-negN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(\mathsf{neg}\left({ux}^{2}\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \sqrt{2 \cdot ux + \left(\mathsf{neg}\left(\color{blue}{ux \cdot ux}\right)\right)} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right) \cdot ux}} \]
      10. mul-1-negN/A

        \[\leadsto \sqrt{2 \cdot ux + \color{blue}{\left(-1 \cdot ux\right)} \cdot ux} \]
      11. distribute-rgt-inN/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
      12. lower-*.f32N/A

        \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
      13. mul-1-negN/A

        \[\leadsto \sqrt{ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)} \]
      14. unsub-negN/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
      15. lower--.f3276.9

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
    11. Simplified76.9%

      \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 - ux\right)}} \]
    12. Taylor expanded in ux around 0

      \[\leadsto \sqrt{ux \cdot \color{blue}{2}} \]
    13. Step-by-step derivation
      1. Simplified62.6%

        \[\leadsto \sqrt{ux \cdot \color{blue}{2}} \]
      2. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2024219 
      (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)))))))