UniformSampleCone, x

Percentage Accurate: 57.0% → 99.0%
Time: 14.1s
Alternatives: 24
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 24 alternatives:

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

Initial Program: 57.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

    Alternative 2: 74.1% accurate, 0.8× speedup?

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

      1. Initial program 38.8%

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

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

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

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

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

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

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

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

          \[\leadsto \sqrt{1 - \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right) \cdot \left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)} \]
        10. lower-fma.f3231.6

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

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

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

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

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

          if 0.0199999996 < (*.f32 (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))))

          1. Initial program 88.9%

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \sqrt{1 - \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right) \cdot \left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)} \]
            10. lower-fma.f3278.7

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

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

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

              \[\leadsto \sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)} \]
          8. Recombined 2 regimes into one program.
          9. Final simplification73.8%

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

          Alternative 3: 74.1% accurate, 0.8× speedup?

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

            1. Initial program 38.8%

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

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

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

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

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

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

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

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

                \[\leadsto \sqrt{1 - \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right) \cdot \left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)} \]
              10. lower-fma.f3231.6

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

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

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

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

              if 0.0199999996 < (*.f32 (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))))

              1. Initial program 88.9%

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \sqrt{1 - \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right) \cdot \left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)} \]
                10. lower-fma.f3278.7

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

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

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

                  \[\leadsto \sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)} \]
              8. Recombined 2 regimes into one program.
              9. Final simplification73.8%

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

              Alternative 4: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

                Alternative 5: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 6: 98.3% accurate, 1.0× speedup?

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

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

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

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

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

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

                  Alternative 7: 97.6% accurate, 1.1× speedup?

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

                    1. Initial program 55.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      1. Initial program 54.8%

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

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

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

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

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

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

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

                      Alternative 8: 97.7% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

                          Alternative 9: 75.1% accurate, 2.1× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(maxCos, ux, 1\right) - ux\\ t_1 := maxCos \cdot ux + \left(1 - ux\right)\\ \mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.00039999998989515007:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2 \cdot maxCos, ux, ux \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 - t\_0 \cdot t\_0}\\ \end{array} \end{array} \]
                          (FPCore (ux uy maxCos)
                           :precision binary32
                           (let* ((t_0 (- (fma maxCos ux 1.0) ux)) (t_1 (+ (* maxCos ux) (- 1.0 ux))))
                             (if (<= (- 1.0 (* t_1 t_1)) 0.00039999998989515007)
                               (sqrt (fma (* -2.0 maxCos) ux (* ux 2.0)))
                               (sqrt (- 1.0 (* t_0 t_0))))))
                          float code(float ux, float uy, float maxCos) {
                          	float t_0 = fmaf(maxCos, ux, 1.0f) - ux;
                          	float t_1 = (maxCos * ux) + (1.0f - ux);
                          	float tmp;
                          	if ((1.0f - (t_1 * t_1)) <= 0.00039999998989515007f) {
                          		tmp = sqrtf(fmaf((-2.0f * maxCos), ux, (ux * 2.0f)));
                          	} else {
                          		tmp = sqrtf((1.0f - (t_0 * t_0)));
                          	}
                          	return tmp;
                          }
                          
                          function code(ux, uy, maxCos)
                          	t_0 = Float32(fma(maxCos, ux, Float32(1.0)) - ux)
                          	t_1 = Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux))
                          	tmp = Float32(0.0)
                          	if (Float32(Float32(1.0) - Float32(t_1 * t_1)) <= Float32(0.00039999998989515007))
                          		tmp = sqrt(fma(Float32(Float32(-2.0) * maxCos), ux, Float32(ux * Float32(2.0))));
                          	else
                          		tmp = sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0)));
                          	end
                          	return tmp
                          end
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          t_0 := \mathsf{fma}\left(maxCos, ux, 1\right) - ux\\
                          t_1 := maxCos \cdot ux + \left(1 - ux\right)\\
                          \mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.00039999998989515007:\\
                          \;\;\;\;\sqrt{\mathsf{fma}\left(-2 \cdot maxCos, ux, ux \cdot 2\right)}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\sqrt{1 - t\_0 \cdot t\_0}\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) < 3.9999999e-4

                            1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \sqrt{1 - \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right) \cdot \left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)} \]
                              10. lower-fma.f3233.0

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

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

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

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

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

                                if 3.9999999e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))

                                1. Initial program 88.1%

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

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

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

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

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

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

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

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

                                    \[\leadsto \sqrt{1 - \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right) \cdot \left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)} \]
                                  10. lower-fma.f3271.3

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

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

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

                              Alternative 10: 88.2% accurate, 2.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  Alternative 11: 88.2% accurate, 2.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 12: 88.2% accurate, 2.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      Alternative 13: 88.2% accurate, 2.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 14: 88.2% accurate, 2.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 15: 87.6% accurate, 2.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right), -2, 1\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)}} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites87.0%

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

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

                                              Alternative 16: 87.6% accurate, 2.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                Alternative 17: 86.7% accurate, 2.8× speedup?

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

                                                  1. Initial program 56.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 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      if 9.99999975e-6 < maxCos

                                                      1. Initial program 48.5%

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

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

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

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

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

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

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

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

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

                                                        Alternative 18: 75.2% accurate, 3.0× speedup?

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

                                                          1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                            if 0.999849975 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))

                                                            1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

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

                                                                \[\leadsto \sqrt{1 - \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right) \cdot \left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)} \]
                                                              10. lower-fma.f3232.3

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

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

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

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

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

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

                                                              Alternative 19: 86.7% accurate, 3.1× speedup?

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

                                                                1. Initial program 56.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 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                    if 9.99999975e-6 < maxCos

                                                                    1. Initial program 48.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                    Alternative 20: 86.7% accurate, 3.1× speedup?

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

                                                                      1. Initial program 56.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 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        if 9.99999975e-6 < maxCos

                                                                        1. Initial program 48.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        Alternative 21: 79.9% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                          Alternative 22: 64.9% accurate, 7.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            Alternative 23: 62.2% accurate, 9.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                Alternative 24: 6.6% accurate, 11.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                  \[\leadsto \sqrt{1 - 1} \]
                                                                                7. Step-by-step derivation
                                                                                  1. Applied rewrites6.6%

                                                                                    \[\leadsto \sqrt{1 - 1} \]
                                                                                  2. Add Preprocessing

                                                                                  Reproduce

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