UniformSampleCone, x

Percentage Accurate: 58.1% → 99.0%
Time: 14.6s
Alternatives: 14
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 14 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: 58.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} \\ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, ux \cdot \mathsf{fma}\left(maxCos, ux, -ux\right), ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (cos (* (* uy 2.0) PI))
  (sqrt
   (fma
    (- 1.0 maxCos)
    (* ux (fma maxCos ux (- ux)))
    (* ux (fma maxCos -2.0 2.0))))))
float code(float ux, float uy, float maxCos) {
	return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(fmaf((1.0f - maxCos), (ux * fmaf(maxCos, ux, -ux)), (ux * fmaf(maxCos, -2.0f, 2.0f))));
}
function code(ux, uy, maxCos)
	return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(fma(Float32(Float32(1.0) - maxCos), Float32(ux * fma(maxCos, ux, Float32(-ux))), Float32(ux * fma(maxCos, Float32(-2.0), Float32(2.0))))))
end
\begin{array}{l}

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 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. 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)} \]
    2. associate-*l*N/A

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
    8. distribute-neg-inN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\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)\right)} \]
    9. distribute-lft-neg-inN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
    10. metadata-evalN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
    11. associate-+l+N/A

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

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

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

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

      Alternative 2: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 3: 98.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(1 + -1 \cdot maxCos\right)} \cdot \left(ux \cdot \left(maxCos - 1\right)\right) + 2\right)} \]
      5. Applied rewrites98.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(1 - maxCos, \mathsf{fma}\left(ux, maxCos, -ux\right), 2\right)\right)}} \]
      6. Taylor expanded in maxCos around 0

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

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

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

        Alternative 4: 97.6% accurate, 1.0× speedup?

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

          1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 64.4%

            \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
          2. Add Preprocessing
          3. Taylor expanded in ux around 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. 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)} \]
            2. associate-*l*N/A

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

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

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

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

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

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
            8. distribute-neg-inN/A

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\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)\right)} \]
            9. distribute-lft-neg-inN/A

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
            10. metadata-evalN/A

              \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
            11. associate-+l+N/A

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

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

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

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

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

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

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

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

          Alternative 5: 97.6% accurate, 1.1× speedup?

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

            1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 6: 93.8% accurate, 1.1× speedup?

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

              1. Initial program 53.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              1. Initial program 60.0%

                \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in 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. 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)} \]
                2. associate-*l*N/A

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

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

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

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

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

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                8. distribute-neg-inN/A

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\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)\right)} \]
                9. distribute-lft-neg-inN/A

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                10. metadata-evalN/A

                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                11. associate-+l+N/A

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

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

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

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

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

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

                Alternative 7: 88.5% accurate, 2.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, -2, \color{blue}{\left(1 + -1 \cdot maxCos\right)} \cdot \left(ux \cdot \left(maxCos - 1\right)\right) + 2\right)} \]
                5. Applied rewrites98.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(1 - maxCos, \mathsf{fma}\left(ux, maxCos, -ux\right), 2\right)\right)}} \]
                6. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 8: 87.1% accurate, 2.8× speedup?

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

                  1. Initial program 55.5%

                    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                  2. Add Preprocessing
                  3. Taylor expanded in ux around 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. 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)} \]
                    2. associate-*l*N/A

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

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

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

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

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

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                    8. distribute-neg-inN/A

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\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)\right)} \]
                    9. distribute-lft-neg-inN/A

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                    10. metadata-evalN/A

                      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                    11. associate-+l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if 1.2e-6 < maxCos

                    1. Initial program 50.7%

                      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in ux around 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. 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)} \]
                      2. associate-*l*N/A

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

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

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

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

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

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                      8. distribute-neg-inN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\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)\right)} \]
                      9. distribute-lft-neg-inN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                      10. metadata-evalN/A

                        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                      11. associate-+l+N/A

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

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

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

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

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

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

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

                        Alternative 9: 80.2% accurate, 3.2× speedup?

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

                          \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                        2. Add Preprocessing
                        3. Taylor expanded in ux around 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. 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)} \]
                          2. associate-*l*N/A

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

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

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

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

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

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                          8. distribute-neg-inN/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\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)\right)} \]
                          9. distribute-lft-neg-inN/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                          10. metadata-evalN/A

                            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                          11. associate-+l+N/A

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

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

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

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

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

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

                              Alternative 10: 80.2% accurate, 3.2× speedup?

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

                                \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                              2. Add Preprocessing
                              3. Taylor expanded in ux around 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. 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)} \]
                                2. associate-*l*N/A

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

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

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

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

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

                                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                                8. distribute-neg-inN/A

                                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\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)\right)} \]
                                9. distribute-lft-neg-inN/A

                                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                                10. metadata-evalN/A

                                  \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                                11. associate-+l+N/A

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

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

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

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

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

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

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

                                    Alternative 11: 80.1% accurate, 4.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      Alternative 12: 75.8% accurate, 5.4× speedup?

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

                                        \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in ux around 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. 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)} \]
                                        2. associate-*l*N/A

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

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

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

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

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

                                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                                        8. distribute-neg-inN/A

                                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\color{blue}{\left(\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)\right)} \]
                                        9. distribute-lft-neg-inN/A

                                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                                        10. metadata-evalN/A

                                          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(ux \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)\right)} \]
                                        11. associate-+l+N/A

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

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

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

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

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

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

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

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

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

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

                                          Alternative 13: 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 54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              Alternative 14: 62.1% accurate, 9.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto \sqrt{ux \cdot 2} \]
                                                  2. Final simplification63.3%

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

                                                  Reproduce

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