UniformSampleCone, x

Percentage Accurate: 57.7% → 98.9%
Time: 43.5s
Alternatives: 8
Speedup: N/A×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 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.7% accurate, 1.0× speedup?

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

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

Alternative 1: 98.9% accurate, N/A× speedup?

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

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

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2\right) - 2 \cdot maxCos\right) \cdot ux} \]
    5. associate-*r*N/A

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\mathsf{fma}\left(-ux, {\left(maxCos - 1\right)}^{2}, 2\right) - 2 \cdot maxCos\right) \cdot ux} \]
    11. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\mathsf{fma}\left(-ux, {\left(maxCos - 1\right)}^{2}, 2\right) - maxCos \cdot 2\right) \cdot ux} \]
    12. lower-*.f3299.1

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

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

Alternative 2: 98.7% accurate, N/A× speedup?

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

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\frac{2 \cdot 1}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}} \]
    5. metadata-evalN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}} \]
    6. lower-/.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(2 \cdot \frac{maxCos}{ux} + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}} \]
    7. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(\frac{maxCos}{ux} \cdot 2 + {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}} \]
    8. lower-fma.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\frac{2}{ux} - \mathsf{fma}\left(\frac{maxCos}{ux}, 2, {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}} \]
    10. lower-pow.f32N/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\frac{2}{ux} - \mathsf{fma}\left(\frac{maxCos}{ux}, 2, {\left(maxCos - 1\right)}^{2}\right)\right) \cdot {ux}^{2}} \]
    12. unpow2N/A

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

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

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

Alternative 3: 95.9% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 - 2 \cdot maxCos\\ t_1 := ux \cdot t\_0\\ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(\sqrt{t\_1} + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{1}{t\_1}} \cdot {\left(maxCos - 1\right)}^{2}, \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.125, \sqrt{{t\_1}^{-3}} \cdot {\left(maxCos - 1\right)}^{4}, -0.0625 \cdot \left(\sqrt{\frac{1}{ux \cdot {t\_0}^{5}}} \cdot {\left(maxCos - 1\right)}^{6}\right)\right)\right)\right) \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (- 2.0 (* 2.0 maxCos))) (t_1 (* ux t_0)))
   (*
    (cos (* (* uy 2.0) PI))
    (+
     (sqrt t_1)
     (*
      (* ux ux)
      (fma
       -0.5
       (* (sqrt (/ 1.0 t_1)) (pow (- maxCos 1.0) 2.0))
       (*
        (* ux ux)
        (fma
         -0.125
         (* (sqrt (pow t_1 -3.0)) (pow (- maxCos 1.0) 4.0))
         (*
          -0.0625
          (*
           (sqrt (/ 1.0 (* ux (pow t_0 5.0))))
           (pow (- maxCos 1.0) 6.0)))))))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = 2.0f - (2.0f * maxCos);
	float t_1 = ux * t_0;
	return cosf(((uy * 2.0f) * ((float) M_PI))) * (sqrtf(t_1) + ((ux * ux) * fmaf(-0.5f, (sqrtf((1.0f / t_1)) * powf((maxCos - 1.0f), 2.0f)), ((ux * ux) * fmaf(-0.125f, (sqrtf(powf(t_1, -3.0f)) * powf((maxCos - 1.0f), 4.0f)), (-0.0625f * (sqrtf((1.0f / (ux * powf(t_0, 5.0f)))) * powf((maxCos - 1.0f), 6.0f))))))));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))
	t_1 = Float32(ux * t_0)
	return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * Float32(sqrt(t_1) + Float32(Float32(ux * ux) * fma(Float32(-0.5), Float32(sqrt(Float32(Float32(1.0) / t_1)) * (Float32(maxCos - Float32(1.0)) ^ Float32(2.0))), Float32(Float32(ux * ux) * fma(Float32(-0.125), Float32(sqrt((t_1 ^ Float32(-3.0))) * (Float32(maxCos - Float32(1.0)) ^ Float32(4.0))), Float32(Float32(-0.0625) * Float32(sqrt(Float32(Float32(1.0) / Float32(ux * (t_0 ^ Float32(5.0))))) * (Float32(maxCos - Float32(1.0)) ^ Float32(6.0))))))))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 2 - 2 \cdot maxCos\\
t_1 := ux \cdot t\_0\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(\sqrt{t\_1} + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{1}{t\_1}} \cdot {\left(maxCos - 1\right)}^{2}, \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.125, \sqrt{{t\_1}^{-3}} \cdot {\left(maxCos - 1\right)}^{4}, -0.0625 \cdot \left(\sqrt{\frac{1}{ux \cdot {t\_0}^{5}}} \cdot {\left(maxCos - 1\right)}^{6}\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 57.7%

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + 2\right) - 2 \cdot maxCos\right) \cdot ux} \]
    5. associate-*r*N/A

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

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

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\mathsf{fma}\left(-ux, {\left(maxCos - 1\right)}^{2}, 2\right) - 2 \cdot maxCos\right) \cdot ux} \]
    11. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\mathsf{fma}\left(-ux, {\left(maxCos - 1\right)}^{2}, 2\right) - maxCos \cdot 2\right) \cdot ux} \]
    12. lower-*.f3299.1

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{\left(\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} + {ux}^{2} \cdot \left(\frac{-1}{2} \cdot \left(\sqrt{\frac{1}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \cdot {\left(maxCos - 1\right)}^{2}\right) + {ux}^{2} \cdot \left(\frac{-1}{8} \cdot \left(\sqrt{\frac{1}{{ux}^{3} \cdot {\left(2 - 2 \cdot maxCos\right)}^{3}}} \cdot {\left(maxCos - 1\right)}^{4}\right) + \frac{-1}{16} \cdot \left(\sqrt{\frac{1}{ux \cdot {\left(2 - 2 \cdot maxCos\right)}^{5}}} \cdot {\left(maxCos - 1\right)}^{6}\right)\right)\right)\right)} \]
  7. Applied rewrites95.7%

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{\mathsf{fma}\left(\sqrt{ux}, \sqrt{2 - 2 \cdot maxCos}, \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{1}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \cdot {\left(maxCos - 1\right)}^{2}, \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{1}{{\left(ux \cdot \left(2 - 2 \cdot maxCos\right)\right)}^{3}}} \cdot {\left(maxCos - 1\right)}^{4}, -0.0625 \cdot \left(\sqrt{\frac{1}{ux \cdot {\left(2 - 2 \cdot maxCos\right)}^{5}}} \cdot {\left(maxCos - 1\right)}^{6}\right)\right)\right)\right)} \]
  8. Applied rewrites95.9%

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} + \color{blue}{\left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{1}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \cdot {\left(maxCos - 1\right)}^{2}, \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.125, \sqrt{{\left(ux \cdot \left(2 - 2 \cdot maxCos\right)\right)}^{-3}} \cdot {\left(maxCos - 1\right)}^{4}, -0.0625 \cdot \left(\sqrt{\frac{1}{ux \cdot {\left(2 - 2 \cdot maxCos\right)}^{5}}} \cdot {\left(maxCos - 1\right)}^{6}\right)\right)\right)}\right) \]
  9. Add Preprocessing

Alternative 4: 95.9% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 - 2 \cdot maxCos\\ t_1 := ux \cdot t\_0\\ t_2 := \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \mathsf{fma}\left(\sqrt{t\_1}, t\_2, \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{1}{t\_1}} \cdot \left({\left(maxCos - 1\right)}^{2} \cdot t\_2\right), \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{1}{{t\_1}^{3}}} \cdot \left({\left(maxCos - 1\right)}^{4} \cdot t\_2\right), -0.0625 \cdot \left(\sqrt{\frac{1}{ux \cdot {t\_0}^{5}}} \cdot \left({\left(maxCos - 1\right)}^{6} \cdot t\_2\right)\right)\right)\right)\right) \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (- 2.0 (* 2.0 maxCos)))
        (t_1 (* ux t_0))
        (t_2 (cos (* 2.0 (* uy PI)))))
   (fma
    (sqrt t_1)
    t_2
    (*
     (* ux ux)
     (fma
      -0.5
      (* (sqrt (/ 1.0 t_1)) (* (pow (- maxCos 1.0) 2.0) t_2))
      (*
       (* ux ux)
       (fma
        -0.125
        (* (sqrt (/ 1.0 (pow t_1 3.0))) (* (pow (- maxCos 1.0) 4.0) t_2))
        (*
         -0.0625
         (*
          (sqrt (/ 1.0 (* ux (pow t_0 5.0))))
          (* (pow (- maxCos 1.0) 6.0) t_2))))))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = 2.0f - (2.0f * maxCos);
	float t_1 = ux * t_0;
	float t_2 = cosf((2.0f * (uy * ((float) M_PI))));
	return fmaf(sqrtf(t_1), t_2, ((ux * ux) * fmaf(-0.5f, (sqrtf((1.0f / t_1)) * (powf((maxCos - 1.0f), 2.0f) * t_2)), ((ux * ux) * fmaf(-0.125f, (sqrtf((1.0f / powf(t_1, 3.0f))) * (powf((maxCos - 1.0f), 4.0f) * t_2)), (-0.0625f * (sqrtf((1.0f / (ux * powf(t_0, 5.0f)))) * (powf((maxCos - 1.0f), 6.0f) * t_2))))))));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))
	t_1 = Float32(ux * t_0)
	t_2 = cos(Float32(Float32(2.0) * Float32(uy * Float32(pi))))
	return fma(sqrt(t_1), t_2, Float32(Float32(ux * ux) * fma(Float32(-0.5), Float32(sqrt(Float32(Float32(1.0) / t_1)) * Float32((Float32(maxCos - Float32(1.0)) ^ Float32(2.0)) * t_2)), Float32(Float32(ux * ux) * fma(Float32(-0.125), Float32(sqrt(Float32(Float32(1.0) / (t_1 ^ Float32(3.0)))) * Float32((Float32(maxCos - Float32(1.0)) ^ Float32(4.0)) * t_2)), Float32(Float32(-0.0625) * Float32(sqrt(Float32(Float32(1.0) / Float32(ux * (t_0 ^ Float32(5.0))))) * Float32((Float32(maxCos - Float32(1.0)) ^ Float32(6.0)) * t_2))))))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 2 - 2 \cdot maxCos\\
t_1 := ux \cdot t\_0\\
t_2 := \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\\
\mathsf{fma}\left(\sqrt{t\_1}, t\_2, \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{1}{t\_1}} \cdot \left({\left(maxCos - 1\right)}^{2} \cdot t\_2\right), \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{1}{{t\_1}^{3}}} \cdot \left({\left(maxCos - 1\right)}^{4} \cdot t\_2\right), -0.0625 \cdot \left(\sqrt{\frac{1}{ux \cdot {t\_0}^{5}}} \cdot \left({\left(maxCos - 1\right)}^{6} \cdot t\_2\right)\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 57.7%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-cos.f32N/A

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

      \[\leadsto \cos \left(\color{blue}{\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)} \]
    3. lift-PI.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \color{blue}{\mathsf{PI}\left(\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. lift-*.f32N/A

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

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

      \[\leadsto \cos \color{blue}{\left(2 \cdot \left(uy \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)} \]
    7. cos-2N/A

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

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

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

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

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

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

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

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

      \[\leadsto \left(\cos \left(\pi \cdot uy\right) \cdot \cos \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} - \sin \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(uy \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)} \]
    16. lower-*.f32N/A

      \[\leadsto \left(\cos \left(\pi \cdot uy\right) \cdot \cos \color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} - \sin \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(uy \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)} \]
    17. lift-PI.f32N/A

      \[\leadsto \left(\cos \left(\pi \cdot uy\right) \cdot \cos \left(\color{blue}{\pi} \cdot uy\right) - \sin \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(uy \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)} \]
    18. lower-*.f32N/A

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

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

    \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \cdot \left({\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)}^{2} - {\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)}^{2}\right) + {ux}^{2} \cdot \left(\frac{-1}{2} \cdot \left(\sqrt{\frac{1}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \cdot \left({\left(maxCos - 1\right)}^{2} \cdot \left({\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)}^{2} - {\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)}^{2}\right)\right)\right) + {ux}^{2} \cdot \left(\frac{-1}{8} \cdot \left(\sqrt{\frac{1}{{ux}^{3} \cdot {\left(2 - 2 \cdot maxCos\right)}^{3}}} \cdot \left({\left(maxCos - 1\right)}^{4} \cdot \left({\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)}^{2} - {\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)}^{2}\right)\right)\right) + \frac{-1}{16} \cdot \left(\sqrt{\frac{1}{ux \cdot {\left(2 - 2 \cdot maxCos\right)}^{5}}} \cdot \left({\left(maxCos - 1\right)}^{6} \cdot \left({\cos \left(uy \cdot \mathsf{PI}\left(\right)\right)}^{2} - {\sin \left(uy \cdot \mathsf{PI}\left(\right)\right)}^{2}\right)\right)\right)\right)\right)} \]
  6. Applied rewrites95.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{1}{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \cdot \left({\left(maxCos - 1\right)}^{2} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right), \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.125, \sqrt{\frac{1}{{\left(ux \cdot \left(2 - 2 \cdot maxCos\right)\right)}^{3}}} \cdot \left({\left(maxCos - 1\right)}^{4} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right), -0.0625 \cdot \left(\sqrt{\frac{1}{ux \cdot {\left(2 - 2 \cdot maxCos\right)}^{5}}} \cdot \left({\left(maxCos - 1\right)}^{6} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\right)\right)\right)\right)} \]
  7. Add Preprocessing

Alternative 5: 90.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)\\ \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot t\_0\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, -0.5, t\_0 \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (cos (* PI (* 2.0 uy)))))
   (fma
    (*
     (* (pow (- maxCos 1.0) 2.0) t_0)
     (sqrt (/ (pow ux 3.0) (fma -2.0 maxCos 2.0))))
    -0.5
    (* t_0 (sqrt (* (fma -2.0 maxCos 2.0) ux))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = cosf((((float) M_PI) * (2.0f * uy)));
	return fmaf(((powf((maxCos - 1.0f), 2.0f) * t_0) * sqrtf((powf(ux, 3.0f) / fmaf(-2.0f, maxCos, 2.0f)))), -0.5f, (t_0 * sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux))));
}
function code(ux, uy, maxCos)
	t_0 = cos(Float32(Float32(pi) * Float32(Float32(2.0) * uy)))
	return fma(Float32(Float32((Float32(maxCos - Float32(1.0)) ^ Float32(2.0)) * t_0) * sqrt(Float32((ux ^ Float32(3.0)) / fma(Float32(-2.0), maxCos, Float32(2.0))))), Float32(-0.5), Float32(t_0 * sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)\\
\mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot t\_0\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, -0.5, t\_0 \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 57.7%

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

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

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

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

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

Alternative 6: 89.5% accurate, N/A× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \pi \cdot \pi, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.08888888888888889, \left(uy \cdot uy\right) \cdot {\pi}^{6}, 0.6666666666666666 \cdot {\pi}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, -0.5, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (fma
  (*
   (*
    (pow (- maxCos 1.0) 2.0)
    (+
     1.0
     (*
      (* uy uy)
      (fma
       -2.0
       (* PI PI)
       (*
        (* uy uy)
        (fma
         -0.08888888888888889
         (* (* uy uy) (pow PI 6.0))
         (* 0.6666666666666666 (pow PI 4.0))))))))
   (sqrt (/ (pow ux 3.0) (fma -2.0 maxCos 2.0))))
  -0.5
  (*
   (sin (fma PI (* 2.0 uy) (/ PI 2.0)))
   (sqrt (* (fma -2.0 maxCos 2.0) ux)))))
float code(float ux, float uy, float maxCos) {
	return fmaf(((powf((maxCos - 1.0f), 2.0f) * (1.0f + ((uy * uy) * fmaf(-2.0f, (((float) M_PI) * ((float) M_PI)), ((uy * uy) * fmaf(-0.08888888888888889f, ((uy * uy) * powf(((float) M_PI), 6.0f)), (0.6666666666666666f * powf(((float) M_PI), 4.0f)))))))) * sqrtf((powf(ux, 3.0f) / fmaf(-2.0f, maxCos, 2.0f)))), -0.5f, (sinf(fmaf(((float) M_PI), (2.0f * uy), (((float) M_PI) / 2.0f))) * sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux))));
}
function code(ux, uy, maxCos)
	return fma(Float32(Float32((Float32(maxCos - Float32(1.0)) ^ Float32(2.0)) * Float32(Float32(1.0) + Float32(Float32(uy * uy) * fma(Float32(-2.0), Float32(Float32(pi) * Float32(pi)), Float32(Float32(uy * uy) * fma(Float32(-0.08888888888888889), Float32(Float32(uy * uy) * (Float32(pi) ^ Float32(6.0))), Float32(Float32(0.6666666666666666) * (Float32(pi) ^ Float32(4.0))))))))) * sqrt(Float32((ux ^ Float32(3.0)) / fma(Float32(-2.0), maxCos, Float32(2.0))))), Float32(-0.5), Float32(sin(fma(Float32(pi), Float32(Float32(2.0) * uy), Float32(Float32(pi) / Float32(2.0)))) * sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux))))
end
\begin{array}{l}

\\
\mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \pi \cdot \pi, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.08888888888888889, \left(uy \cdot uy\right) \cdot {\pi}^{6}, 0.6666666666666666 \cdot {\pi}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, -0.5, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right)
\end{array}
Derivation
  1. Initial program 57.7%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    5. sin-+PI/2-revN/A

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

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

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), 2 \cdot uy, \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    8. lift-PI.f32N/A

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

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

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    11. lift-PI.f3290.3

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, -0.5, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
  7. Applied rewrites90.3%

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

    \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + {uy}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + {uy}^{2} \cdot \left(\frac{-4}{45} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
  9. Step-by-step derivation
    1. sin-+PI/2-revN/A

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

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

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + {uy}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + {uy}^{2} \cdot \left(\frac{-4}{45} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    4. pow2N/A

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + {uy}^{2} \cdot \left(\frac{-4}{45} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    5. lift-*.f32N/A

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

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, {\mathsf{PI}\left(\right)}^{2}, {uy}^{2} \cdot \left(\frac{-4}{45} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    7. pow2N/A

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), {uy}^{2} \cdot \left(\frac{-4}{45} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    8. lift-*.f32N/A

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), {uy}^{2} \cdot \left(\frac{-4}{45} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    9. lift-PI.f32N/A

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \pi \cdot \mathsf{PI}\left(\right), {uy}^{2} \cdot \left(\frac{-4}{45} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
    10. lift-PI.f32N/A

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

      \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \pi \cdot \pi, {uy}^{2} \cdot \left(\frac{-4}{45} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
  10. Applied rewrites89.7%

    \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot \left(1 + \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \pi \cdot \pi, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.08888888888888889, \left(uy \cdot uy\right) \cdot {\pi}^{6}, 0.6666666666666666 \cdot {\pi}^{4}\right)\right)\right)\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, -0.5, \sin \left(\mathsf{fma}\left(\pi, 2 \cdot uy, \frac{\pi}{2}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
  11. Add Preprocessing

Alternative 7: 88.4% accurate, N/A× speedup?

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(\left({\left(maxCos - 1\right)}^{2} \cdot 1\right) \cdot \sqrt{\frac{{ux}^{3}}{\mathsf{fma}\left(-2, maxCos, 2\right)}}, \frac{-1}{2}, \cos \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \]
  7. Step-by-step derivation
    1. Applied rewrites88.1%

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

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

    Alternative 8: 85.7% accurate, N/A× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(maxCos - 1\right)}^{2}\\ t_1 := 2 + -2 \cdot maxCos\\ t_2 := \sqrt{ux \cdot t\_1}\\ t_3 := \sqrt{\frac{{ux}^{3}}{t\_1}}\\ t\_2 + \mathsf{fma}\left(-0.5, t\_3 \cdot t\_0, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, t\_2 \cdot \left(\pi \cdot \pi\right), \mathsf{fma}\left(t\_3, {\left(\pi \cdot \left(maxCos - 1\right)\right)}^{2}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.3333333333333333, t\_3 \cdot \left({\pi}^{4} \cdot t\_0\right), \mathsf{fma}\left(0.6666666666666666, t\_2 \cdot {\pi}^{4}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.08888888888888889, t\_2 \cdot {\pi}^{6}, 0.044444444444444446 \cdot \left(t\_3 \cdot \left({\pi}^{6} \cdot t\_0\right)\right)\right)\right)\right)\right)\right)\right) \end{array} \end{array} \]
    (FPCore (ux uy maxCos)
     :precision binary32
     (let* ((t_0 (pow (- maxCos 1.0) 2.0))
            (t_1 (+ 2.0 (* -2.0 maxCos)))
            (t_2 (sqrt (* ux t_1)))
            (t_3 (sqrt (/ (pow ux 3.0) t_1))))
       (+
        t_2
        (fma
         -0.5
         (* t_3 t_0)
         (*
          (* uy uy)
          (fma
           -2.0
           (* t_2 (* PI PI))
           (fma
            t_3
            (pow (* PI (- maxCos 1.0)) 2.0)
            (*
             (* uy uy)
             (fma
              -0.3333333333333333
              (* t_3 (* (pow PI 4.0) t_0))
              (fma
               0.6666666666666666
               (* t_2 (pow PI 4.0))
               (*
                (* uy uy)
                (fma
                 -0.08888888888888889
                 (* t_2 (pow PI 6.0))
                 (* 0.044444444444444446 (* t_3 (* (pow PI 6.0) t_0)))))))))))))))
    float code(float ux, float uy, float maxCos) {
    	float t_0 = powf((maxCos - 1.0f), 2.0f);
    	float t_1 = 2.0f + (-2.0f * maxCos);
    	float t_2 = sqrtf((ux * t_1));
    	float t_3 = sqrtf((powf(ux, 3.0f) / t_1));
    	return t_2 + fmaf(-0.5f, (t_3 * t_0), ((uy * uy) * fmaf(-2.0f, (t_2 * (((float) M_PI) * ((float) M_PI))), fmaf(t_3, powf((((float) M_PI) * (maxCos - 1.0f)), 2.0f), ((uy * uy) * fmaf(-0.3333333333333333f, (t_3 * (powf(((float) M_PI), 4.0f) * t_0)), fmaf(0.6666666666666666f, (t_2 * powf(((float) M_PI), 4.0f)), ((uy * uy) * fmaf(-0.08888888888888889f, (t_2 * powf(((float) M_PI), 6.0f)), (0.044444444444444446f * (t_3 * (powf(((float) M_PI), 6.0f) * t_0))))))))))));
    }
    
    function code(ux, uy, maxCos)
    	t_0 = Float32(maxCos - Float32(1.0)) ^ Float32(2.0)
    	t_1 = Float32(Float32(2.0) + Float32(Float32(-2.0) * maxCos))
    	t_2 = sqrt(Float32(ux * t_1))
    	t_3 = sqrt(Float32((ux ^ Float32(3.0)) / t_1))
    	return Float32(t_2 + fma(Float32(-0.5), Float32(t_3 * t_0), Float32(Float32(uy * uy) * fma(Float32(-2.0), Float32(t_2 * Float32(Float32(pi) * Float32(pi))), fma(t_3, (Float32(Float32(pi) * Float32(maxCos - Float32(1.0))) ^ Float32(2.0)), Float32(Float32(uy * uy) * fma(Float32(-0.3333333333333333), Float32(t_3 * Float32((Float32(pi) ^ Float32(4.0)) * t_0)), fma(Float32(0.6666666666666666), Float32(t_2 * (Float32(pi) ^ Float32(4.0))), Float32(Float32(uy * uy) * fma(Float32(-0.08888888888888889), Float32(t_2 * (Float32(pi) ^ Float32(6.0))), Float32(Float32(0.044444444444444446) * Float32(t_3 * Float32((Float32(pi) ^ Float32(6.0)) * t_0)))))))))))))
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := {\left(maxCos - 1\right)}^{2}\\
    t_1 := 2 + -2 \cdot maxCos\\
    t_2 := \sqrt{ux \cdot t\_1}\\
    t_3 := \sqrt{\frac{{ux}^{3}}{t\_1}}\\
    t\_2 + \mathsf{fma}\left(-0.5, t\_3 \cdot t\_0, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, t\_2 \cdot \left(\pi \cdot \pi\right), \mathsf{fma}\left(t\_3, {\left(\pi \cdot \left(maxCos - 1\right)\right)}^{2}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.3333333333333333, t\_3 \cdot \left({\pi}^{4} \cdot t\_0\right), \mathsf{fma}\left(0.6666666666666666, t\_2 \cdot {\pi}^{4}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.08888888888888889, t\_2 \cdot {\pi}^{6}, 0.044444444444444446 \cdot \left(t\_3 \cdot \left({\pi}^{6} \cdot t\_0\right)\right)\right)\right)\right)\right)\right)\right)
    \end{array}
    \end{array}
    
    Derivation
    1. Initial program 57.7%

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sqrt{ux}, \color{blue}{\sqrt{2 + -2 \cdot maxCos}}, \mathsf{fma}\left(-0.5, \sqrt{\frac{{ux}^{3}}{2 + -2 \cdot maxCos}} \cdot {\left(maxCos - 1\right)}^{2}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot \left(\pi \cdot \pi\right), \mathsf{fma}\left(\sqrt{\frac{{ux}^{3}}{2 + -2 \cdot maxCos}}, {\left(\pi \cdot \left(maxCos - 1\right)\right)}^{2}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.3333333333333333, \sqrt{\frac{{ux}^{3}}{2 + -2 \cdot maxCos}} \cdot \left({\pi}^{4} \cdot {\left(maxCos - 1\right)}^{2}\right), \mathsf{fma}\left(0.6666666666666666, \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot {\pi}^{4}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.08888888888888889, \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot {\pi}^{6}, 0.044444444444444446 \cdot \left(\sqrt{\frac{{ux}^{3}}{2 + -2 \cdot maxCos}} \cdot \left({\pi}^{6} \cdot {\left(maxCos - 1\right)}^{2}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Applied rewrites85.6%

      \[\leadsto \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right)} + \mathsf{fma}\left(-0.5, \color{blue}{\sqrt{\frac{{ux}^{3}}{2 + -2 \cdot maxCos}} \cdot {\left(maxCos - 1\right)}^{2}}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot \left(\pi \cdot \pi\right), \mathsf{fma}\left(\sqrt{\frac{{ux}^{3}}{2 + -2 \cdot maxCos}}, {\left(\pi \cdot \left(maxCos - 1\right)\right)}^{2}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.3333333333333333, \sqrt{\frac{{ux}^{3}}{2 + -2 \cdot maxCos}} \cdot \left({\pi}^{4} \cdot {\left(maxCos - 1\right)}^{2}\right), \mathsf{fma}\left(0.6666666666666666, \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot {\pi}^{4}, \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-0.08888888888888889, \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right)} \cdot {\pi}^{6}, 0.044444444444444446 \cdot \left(\sqrt{\frac{{ux}^{3}}{2 + -2 \cdot maxCos}} \cdot \left({\pi}^{6} \cdot {\left(maxCos - 1\right)}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
    9. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025057 
    (FPCore (ux uy maxCos)
      :name "UniformSampleCone, x"
      :precision binary32
      :pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
      (* (cos (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))