UniformSampleCone, y

Percentage Accurate: 57.1% → 98.2%
Time: 14.1s
Alternatives: 22
Speedup: 4.2×

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\\ \sin \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))))
   (* (sin (* (* 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 sinf(((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(sin(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 = sin(((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\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 22 alternatives:

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

Initial Program: 57.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \sin \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))))
   (* (sin (* (* 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 sinf(((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(sin(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 = sin(((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\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Alternative 1: 98.2% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

    Alternative 2: 96.9% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.014999999664723873:\\ \;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333, \left(\pi \cdot \pi\right) \cdot \pi, \pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, maxCos - 1, \frac{\mathsf{fma}\left(maxCos, -2, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot \sin \left(\pi \cdot \left(2 \cdot uy\right)\right)\\ \end{array} \end{array} \]
    (FPCore (ux uy maxCos)
     :precision binary32
     (if (<= (* 2.0 uy) 0.014999999664723873)
       (*
        (* (fma (* (* uy uy) -1.3333333333333333) (* (* PI PI) PI) (* PI 2.0)) uy)
        (sqrt
         (*
          (fma (- 1.0 maxCos) (- maxCos 1.0) (/ (fma maxCos -2.0 2.0) ux))
          (* ux ux))))
       (* (sqrt (* (* (- (/ 2.0 ux) 1.0) ux) ux)) (sin (* PI (* 2.0 uy))))))
    float code(float ux, float uy, float maxCos) {
    	float tmp;
    	if ((2.0f * uy) <= 0.014999999664723873f) {
    		tmp = (fmaf(((uy * uy) * -1.3333333333333333f), ((((float) M_PI) * ((float) M_PI)) * ((float) M_PI)), (((float) M_PI) * 2.0f)) * uy) * sqrtf((fmaf((1.0f - maxCos), (maxCos - 1.0f), (fmaf(maxCos, -2.0f, 2.0f) / ux)) * (ux * ux)));
    	} else {
    		tmp = sqrtf(((((2.0f / ux) - 1.0f) * ux) * ux)) * sinf((((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.014999999664723873))
    		tmp = Float32(Float32(fma(Float32(Float32(uy * uy) * Float32(-1.3333333333333333)), Float32(Float32(Float32(pi) * Float32(pi)) * Float32(pi)), Float32(Float32(pi) * Float32(2.0))) * uy) * sqrt(Float32(fma(Float32(Float32(1.0) - maxCos), Float32(maxCos - Float32(1.0)), Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) / ux)) * Float32(ux * ux))));
    	else
    		tmp = Float32(sqrt(Float32(Float32(Float32(Float32(Float32(2.0) / ux) - Float32(1.0)) * ux) * ux)) * sin(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.014999999664723873:\\
    \;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333, \left(\pi \cdot \pi\right) \cdot \pi, \pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, maxCos - 1, \frac{\mathsf{fma}\left(maxCos, -2, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot \sin \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.0149999997

      1. Initial program 55.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 55.5%

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

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

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

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

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

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

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

            \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \]
        4. Recombined 2 regimes into one program.
        5. Final simplification97.2%

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

        Alternative 3: 96.9% accurate, 1.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.014999999664723873:\\ \;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333, \left(\pi \cdot \pi\right) \cdot \pi, \pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, maxCos - 1, \frac{\mathsf{fma}\left(maxCos, -2, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot \sin \left(\pi \cdot \left(2 \cdot uy\right)\right)\\ \end{array} \end{array} \]
        (FPCore (ux uy maxCos)
         :precision binary32
         (if (<= (* 2.0 uy) 0.014999999664723873)
           (*
            (* (fma (* (* uy uy) -1.3333333333333333) (* (* PI PI) PI) (* PI 2.0)) uy)
            (sqrt
             (*
              (fma (- 1.0 maxCos) (- maxCos 1.0) (/ (fma maxCos -2.0 2.0) ux))
              (* ux ux))))
           (* (sqrt (* (- (/ 2.0 ux) 1.0) (* ux ux))) (sin (* PI (* 2.0 uy))))))
        float code(float ux, float uy, float maxCos) {
        	float tmp;
        	if ((2.0f * uy) <= 0.014999999664723873f) {
        		tmp = (fmaf(((uy * uy) * -1.3333333333333333f), ((((float) M_PI) * ((float) M_PI)) * ((float) M_PI)), (((float) M_PI) * 2.0f)) * uy) * sqrtf((fmaf((1.0f - maxCos), (maxCos - 1.0f), (fmaf(maxCos, -2.0f, 2.0f) / ux)) * (ux * ux)));
        	} else {
        		tmp = sqrtf((((2.0f / ux) - 1.0f) * (ux * ux))) * sinf((((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.014999999664723873))
        		tmp = Float32(Float32(fma(Float32(Float32(uy * uy) * Float32(-1.3333333333333333)), Float32(Float32(Float32(pi) * Float32(pi)) * Float32(pi)), Float32(Float32(pi) * Float32(2.0))) * uy) * sqrt(Float32(fma(Float32(Float32(1.0) - maxCos), Float32(maxCos - Float32(1.0)), Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) / ux)) * Float32(ux * ux))));
        	else
        		tmp = Float32(sqrt(Float32(Float32(Float32(Float32(2.0) / ux) - Float32(1.0)) * Float32(ux * ux))) * sin(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.014999999664723873:\\
        \;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333, \left(\pi \cdot \pi\right) \cdot \pi, \pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, maxCos - 1, \frac{\mathsf{fma}\left(maxCos, -2, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot \sin \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.0149999997

          1. Initial program 55.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 55.5%

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

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

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

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

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

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

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

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

          Alternative 4: 98.3% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

              Alternative 5: 98.3% accurate, 1.0× 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 \sin \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) (fma maxCos -2.0 2.0)) ux))
                (sin (* PI (* 2.0 uy)))))
              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)) * sinf((((float) M_PI) * (2.0f * uy)));
              }
              
              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)) * sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))))
              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 \sin \left(\pi \cdot \left(2 \cdot uy\right)\right)
              \end{array}
              
              Derivation
              1. Initial program 55.2%

                \[\sin \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 \sin \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 \sin \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 \sin \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 rewrites98.3%

                \[\leadsto \sin \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. Final simplification98.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 \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \]
              7. Add Preprocessing

              Alternative 6: 94.2% accurate, 1.0× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.0560000017285347:\\ \;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333, \left(\pi \cdot \pi\right) \cdot \pi, \pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, maxCos - 1, \frac{\mathsf{fma}\left(maxCos, -2, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(4 - \left(\left(maxCos + 2\right) + maxCos\right)\right) \cdot ux} \cdot \sin \left(\pi \cdot \left(2 \cdot uy\right)\right)\\ \end{array} \end{array} \]
              (FPCore (ux uy maxCos)
               :precision binary32
               (if (<= (* 2.0 uy) 0.0560000017285347)
                 (*
                  (* (fma (* (* uy uy) -1.3333333333333333) (* (* PI PI) PI) (* PI 2.0)) uy)
                  (sqrt
                   (*
                    (fma (- 1.0 maxCos) (- maxCos 1.0) (/ (fma maxCos -2.0 2.0) ux))
                    (* ux ux))))
                 (*
                  (sqrt (* (- 4.0 (+ (+ maxCos 2.0) maxCos)) ux))
                  (sin (* PI (* 2.0 uy))))))
              float code(float ux, float uy, float maxCos) {
              	float tmp;
              	if ((2.0f * uy) <= 0.0560000017285347f) {
              		tmp = (fmaf(((uy * uy) * -1.3333333333333333f), ((((float) M_PI) * ((float) M_PI)) * ((float) M_PI)), (((float) M_PI) * 2.0f)) * uy) * sqrtf((fmaf((1.0f - maxCos), (maxCos - 1.0f), (fmaf(maxCos, -2.0f, 2.0f) / ux)) * (ux * ux)));
              	} else {
              		tmp = sqrtf(((4.0f - ((maxCos + 2.0f) + maxCos)) * ux)) * sinf((((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.0560000017285347))
              		tmp = Float32(Float32(fma(Float32(Float32(uy * uy) * Float32(-1.3333333333333333)), Float32(Float32(Float32(pi) * Float32(pi)) * Float32(pi)), Float32(Float32(pi) * Float32(2.0))) * uy) * sqrt(Float32(fma(Float32(Float32(1.0) - maxCos), Float32(maxCos - Float32(1.0)), Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) / ux)) * Float32(ux * ux))));
              	else
              		tmp = Float32(sqrt(Float32(Float32(Float32(4.0) - Float32(Float32(maxCos + Float32(2.0)) + maxCos)) * ux)) * sin(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.0560000017285347:\\
              \;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333, \left(\pi \cdot \pi\right) \cdot \pi, \pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, maxCos - 1, \frac{\mathsf{fma}\left(maxCos, -2, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)}\\
              
              \mathbf{else}:\\
              \;\;\;\;\sqrt{\left(4 - \left(\left(maxCos + 2\right) + maxCos\right)\right) \cdot ux} \cdot \sin \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.0560000017

                1. Initial program 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                1. Initial program 56.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(4 - \left(maxCos - \left(\color{blue}{\left(\mathsf{neg}\left(maxCos\right)\right)} - 2\right)\right)\right) \cdot ux} \]
                  9. lower-neg.f3277.1

                    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(4 - \left(maxCos - \left(\color{blue}{\left(-maxCos\right)} - 2\right)\right)\right) \cdot ux} \]
                7. Applied rewrites77.1%

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

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

              Alternative 7: 94.2% accurate, 1.1× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.0560000017285347:\\ \;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333, \left(\pi \cdot \pi\right) \cdot \pi, \pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, maxCos - 1, \frac{\mathsf{fma}\left(maxCos, -2, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot \sin \left(\pi \cdot \left(2 \cdot uy\right)\right)\\ \end{array} \end{array} \]
              (FPCore (ux uy maxCos)
               :precision binary32
               (if (<= (* 2.0 uy) 0.0560000017285347)
                 (*
                  (* (fma (* (* uy uy) -1.3333333333333333) (* (* PI PI) PI) (* PI 2.0)) uy)
                  (sqrt
                   (*
                    (fma (- 1.0 maxCos) (- maxCos 1.0) (/ (fma maxCos -2.0 2.0) ux))
                    (* ux ux))))
                 (* (sqrt (* (fma maxCos -2.0 2.0) ux)) (sin (* PI (* 2.0 uy))))))
              float code(float ux, float uy, float maxCos) {
              	float tmp;
              	if ((2.0f * uy) <= 0.0560000017285347f) {
              		tmp = (fmaf(((uy * uy) * -1.3333333333333333f), ((((float) M_PI) * ((float) M_PI)) * ((float) M_PI)), (((float) M_PI) * 2.0f)) * uy) * sqrtf((fmaf((1.0f - maxCos), (maxCos - 1.0f), (fmaf(maxCos, -2.0f, 2.0f) / ux)) * (ux * ux)));
              	} else {
              		tmp = sqrtf((fmaf(maxCos, -2.0f, 2.0f) * ux)) * sinf((((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.0560000017285347))
              		tmp = Float32(Float32(fma(Float32(Float32(uy * uy) * Float32(-1.3333333333333333)), Float32(Float32(Float32(pi) * Float32(pi)) * Float32(pi)), Float32(Float32(pi) * Float32(2.0))) * uy) * sqrt(Float32(fma(Float32(Float32(1.0) - maxCos), Float32(maxCos - Float32(1.0)), Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) / ux)) * Float32(ux * ux))));
              	else
              		tmp = Float32(sqrt(Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) * ux)) * sin(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.0560000017285347:\\
              \;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333, \left(\pi \cdot \pi\right) \cdot \pi, \pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(1 - maxCos, maxCos - 1, \frac{\mathsf{fma}\left(maxCos, -2, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)}\\
              
              \mathbf{else}:\\
              \;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot \sin \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.0560000017

                1. Initial program 54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                1. Initial program 56.2%

                  \[\sin \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 \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
                4. Step-by-step derivation
                  1. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

              Alternative 8: 88.9% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 9: 76.8% accurate, 1.8× speedup?

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

                1. Initial program 35.7%

                  \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                4. Step-by-step derivation
                  1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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.2%

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

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

                  if 3.00000014e-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 87.6%

                    \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                  4. Step-by-step derivation
                    1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites73.2%

                    \[\leadsto \color{blue}{\left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites73.7%

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

                    \[\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.0003000000142492354:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \left(\left(\pi \cdot 2\right) \cdot uy\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux, ux - \mathsf{fma}\left(maxCos, ux, 1\right), 1\right)} \cdot \left(\left(\pi \cdot 2\right) \cdot uy\right)\\ \end{array} \]
                  9. Add Preprocessing

                  Alternative 10: 89.0% accurate, 1.9× speedup?

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

                    \[\sin \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}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

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

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

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

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

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

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

                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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)}} \]
                  7. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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 \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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}} \]
                    3. lower--.f32N/A

                      \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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} \]
                    4. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 11: 89.0% accurate, 2.0× speedup?

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

                    \[\sin \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}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

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

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

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

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

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

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

                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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)}} \]
                  7. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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 \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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}} \]
                    3. lower--.f32N/A

                      \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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} \]
                    4. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 12: 76.7% accurate, 2.3× speedup?

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

                    1. Initial program 88.1%

                      \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                    4. Step-by-step derivation
                      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites73.2%

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

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

                    1. Initial program 36.3%

                      \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                    4. Step-by-step derivation
                      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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.9%

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

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

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

                    Alternative 13: 76.7% accurate, 2.3× speedup?

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

                      1. Initial program 88.1%

                        \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                      4. Step-by-step derivation
                        1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites73.2%

                        \[\leadsto \color{blue}{\left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites73.2%

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

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

                        1. Initial program 36.3%

                          \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                        4. Step-by-step derivation
                          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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.9%

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

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

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

                        Alternative 14: 76.7% accurate, 2.3× speedup?

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

                          1. Initial program 88.1%

                            \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                          4. Step-by-step derivation
                            1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites73.2%

                            \[\leadsto \color{blue}{\left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites73.2%

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

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

                            1. Initial program 36.3%

                              \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                            4. Step-by-step derivation
                              1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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.9%

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

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

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

                            Alternative 15: 88.5% accurate, 2.3× speedup?

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

                              \[\sin \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}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                            4. Step-by-step derivation
                              1. *-commutativeN/A

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

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

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

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

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

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

                              \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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)}} \]
                            7. Step-by-step derivation
                              1. *-commutativeN/A

                                \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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 \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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}} \]
                              3. lower--.f32N/A

                                \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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} \]
                              4. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              Alternative 16: 87.6% accurate, 2.4× speedup?

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

                                1. Initial program 56.1%

                                  \[\sin \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}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                4. Step-by-step derivation
                                  1. *-commutativeN/A

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

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

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

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

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

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

                                  \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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)}} \]
                                7. Step-by-step derivation
                                  1. *-commutativeN/A

                                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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 \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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}} \]
                                  3. lower--.f32N/A

                                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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} \]
                                  4. mul-1-negN/A

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\right) \cdot \sqrt{\left(\left(2 - \left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right) \cdot ux\right) - \color{blue}{maxCos \cdot 2}\right) \cdot ux} \]
                                  14. lower-*.f3288.0

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

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

                                  \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux} \]
                                10. Step-by-step derivation
                                  1. Applied rewrites87.8%

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

                                  if 9.99999975e-6 < maxCos

                                  1. Initial program 48.7%

                                    \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                                  4. Step-by-step derivation
                                    1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites42.8%

                                    \[\leadsto \color{blue}{\left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \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 rewrites83.9%

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

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

                                  Alternative 17: 87.9% accurate, 2.5× speedup?

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

                                    \[\sin \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}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                  4. Step-by-step derivation
                                    1. *-commutativeN/A

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

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

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

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

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

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

                                    \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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)}} \]
                                  7. Step-by-step derivation
                                    1. *-commutativeN/A

                                      \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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 \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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}} \]
                                    3. lower--.f32N/A

                                      \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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} \]
                                    4. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 18: 75.7% accurate, 2.7× speedup?

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

                                      1. Initial program 88.1%

                                        \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                                      4. Step-by-step derivation
                                        1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites73.2%

                                        \[\leadsto \color{blue}{\left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - {\left(1 - ux\right)}^{2}} \]
                                      7. Step-by-step derivation
                                        1. Applied rewrites70.9%

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

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

                                        1. Initial program 36.3%

                                          \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                                        4. Step-by-step derivation
                                          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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.9%

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

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

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

                                        Alternative 19: 83.9% accurate, 2.8× speedup?

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

                                          \[\sin \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}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
                                        4. Step-by-step derivation
                                          1. *-commutativeN/A

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

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

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

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

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

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

                                          \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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)}} \]
                                        7. Step-by-step derivation
                                          1. *-commutativeN/A

                                            \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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 \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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}} \]
                                          3. lower--.f32N/A

                                            \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\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} \]
                                          4. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \frac{-4}{3}, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 2\right)\right) \cdot uy\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux} \]
                                        10. Step-by-step derivation
                                          1. Applied rewrites83.1%

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

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

                                          Alternative 20: 66.1% accurate, 4.2× speedup?

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

                                            \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                                          4. Step-by-step derivation
                                            1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites48.2%

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

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

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

                                            Alternative 21: 66.1% accurate, 4.2× speedup?

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

                                              \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                                            4. Step-by-step derivation
                                              1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites48.2%

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

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

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

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

                                                Alternative 22: 7.1% accurate, 5.4× speedup?

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

                                                  \[\sin \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}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
                                                4. Step-by-step derivation
                                                  1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 rewrites48.2%

                                                  \[\leadsto \color{blue}{\left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \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 \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - 1} \]
                                                7. Step-by-step derivation
                                                  1. Applied rewrites7.1%

                                                    \[\leadsto \left(\left(\pi \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - 1} \]
                                                  2. Final simplification7.1%

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

                                                  Reproduce

                                                  ?
                                                  herbie shell --seed 2024235 
                                                  (FPCore (ux uy maxCos)
                                                    :name "UniformSampleCone, y"
                                                    :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)))
                                                    (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))