UniformSampleCone 2

Percentage Accurate: 98.9% → 99.0%
Time: 22.3s
Alternatives: 18
Speedup: 1.0×

Specification

?
\[\left(\left(\left(\left(\left(-10000 \leq xi \land xi \leq 10000\right) \land \left(-10000 \leq yi \land yi \leq 10000\right)\right) \land \left(-10000 \leq zi \land zi \leq 10000\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq ux \land ux \leq 1\right)\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(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\ t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\ t_2 := \left(uy \cdot 2\right) \cdot \pi\\ \left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
        (t_1 (sqrt (- 1.0 (* t_0 t_0))))
        (t_2 (* (* uy 2.0) PI)))
   (+ (+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi)) (* t_0 zi))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = ((1.0f - ux) * maxCos) * ux;
	float t_1 = sqrtf((1.0f - (t_0 * t_0)));
	float t_2 = (uy * 2.0f) * ((float) M_PI);
	return (((cosf(t_2) * t_1) * xi) + ((sinf(t_2) * t_1) * yi)) + (t_0 * zi);
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * ux)
	t_1 = sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0)))
	t_2 = Float32(Float32(uy * Float32(2.0)) * Float32(pi))
	return Float32(Float32(Float32(Float32(cos(t_2) * t_1) * xi) + Float32(Float32(sin(t_2) * t_1) * yi)) + Float32(t_0 * zi))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	t_0 = ((single(1.0) - ux) * maxCos) * ux;
	t_1 = sqrt((single(1.0) - (t_0 * t_0)));
	t_2 = (uy * single(2.0)) * single(pi);
	tmp = (((cos(t_2) * t_1) * xi) + ((sin(t_2) * t_1) * yi)) + (t_0 * zi);
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \pi\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\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 18 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: 98.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \pi\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}

Alternative 1: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(uy \cdot \pi\right)\\ t_1 := \left(1 - ux\right) \cdot maxCos\\ t_2 := \sqrt{\mathsf{fma}\left(ux \cdot ux, t\_1 \cdot \left(maxCos \cdot \left(ux + -1\right)\right), 1\right)}\\ \mathsf{fma}\left(zi \cdot t\_1, ux, \mathsf{fma}\left(\cos t\_0, t\_2 \cdot xi, t\_2 \cdot \left(\sin t\_0 \cdot yi\right)\right)\right) \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* 2.0 (* uy PI)))
        (t_1 (* (- 1.0 ux) maxCos))
        (t_2 (sqrt (fma (* ux ux) (* t_1 (* maxCos (+ ux -1.0))) 1.0))))
   (fma (* zi t_1) ux (fma (cos t_0) (* t_2 xi) (* t_2 (* (sin t_0) yi))))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = 2.0f * (uy * ((float) M_PI));
	float t_1 = (1.0f - ux) * maxCos;
	float t_2 = sqrtf(fmaf((ux * ux), (t_1 * (maxCos * (ux + -1.0f))), 1.0f));
	return fmaf((zi * t_1), ux, fmaf(cosf(t_0), (t_2 * xi), (t_2 * (sinf(t_0) * yi))));
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(2.0) * Float32(uy * Float32(pi)))
	t_1 = Float32(Float32(Float32(1.0) - ux) * maxCos)
	t_2 = sqrt(fma(Float32(ux * ux), Float32(t_1 * Float32(maxCos * Float32(ux + Float32(-1.0)))), Float32(1.0)))
	return fma(Float32(zi * t_1), ux, fma(cos(t_0), Float32(t_2 * xi), Float32(t_2 * Float32(sin(t_0) * yi))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
t_1 := \left(1 - ux\right) \cdot maxCos\\
t_2 := \sqrt{\mathsf{fma}\left(ux \cdot ux, t\_1 \cdot \left(maxCos \cdot \left(ux + -1\right)\right), 1\right)}\\
\mathsf{fma}\left(zi \cdot t\_1, ux, \mathsf{fma}\left(\cos t\_0, t\_2 \cdot xi, t\_2 \cdot \left(\sin t\_0 \cdot yi\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

Alternative 2: 98.5% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
xi \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(\sin t\_0, \frac{yi}{xi}, \cos t\_0\right)\right) + zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.0%

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

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

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

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

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

    \[\leadsto \color{blue}{xi \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(-\left(1 - ux\right) \cdot \left(1 - ux\right)\right), 1\right)} \cdot \mathsf{fma}\left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right), \frac{yi}{xi}, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\right)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  6. Final simplification98.9%

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

Alternative 3: 98.3% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + xi \cdot \left(\mathsf{fma}\left(\sin t\_0, \frac{yi}{xi}, \cos t\_0\right) \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, ux \cdot \left(-ux\right), 1\right)}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

    Alternative 4: 98.2% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(uy \cdot \pi\right)\\ \mathsf{fma}\left(1 - ux, maxCos \cdot \left(zi \cdot ux\right), xi \cdot \mathsf{fma}\left(\sin t\_0, \frac{yi}{xi}, \cos t\_0\right)\right) \end{array} \end{array} \]
    (FPCore (xi yi zi ux uy maxCos)
     :precision binary32
     (let* ((t_0 (* 2.0 (* uy PI))))
       (fma
        (- 1.0 ux)
        (* maxCos (* zi ux))
        (* xi (fma (sin t_0) (/ yi xi) (cos t_0))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	float t_0 = 2.0f * (uy * ((float) M_PI));
    	return fmaf((1.0f - ux), (maxCos * (zi * ux)), (xi * fmaf(sinf(t_0), (yi / xi), cosf(t_0))));
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	t_0 = Float32(Float32(2.0) * Float32(uy * Float32(pi)))
    	return fma(Float32(Float32(1.0) - ux), Float32(maxCos * Float32(zi * ux)), Float32(xi * fma(sin(t_0), Float32(yi / xi), cos(t_0))))
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
    \mathsf{fma}\left(1 - ux, maxCos \cdot \left(zi \cdot ux\right), xi \cdot \mathsf{fma}\left(\sin t\_0, \frac{yi}{xi}, \cos t\_0\right)\right)
    \end{array}
    \end{array}
    
    Derivation
    1. Initial program 99.0%

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{xi \cdot \mathsf{fma}\left(yi, \frac{\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
      3. Applied rewrites98.7%

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

        \[\leadsto \mathsf{fma}\left(1 - ux, maxCos \cdot \left(zi \cdot ux\right), xi \cdot \mathsf{fma}\left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right), \frac{yi}{xi}, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\right) \]
      5. Add Preprocessing

      Alternative 5: 97.1% accurate, 1.5× speedup?

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

        1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 97.5%

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

          \[\leadsto \color{blue}{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \]
        4. Step-by-step derivation
          1. lower-fma.f32N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
          2. lower-cos.f32N/A

            \[\leadsto \mathsf{fma}\left(xi, \color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
          3. lower-*.f32N/A

            \[\leadsto \mathsf{fma}\left(xi, \cos \color{blue}{\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
          4. lower-*.f32N/A

            \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
          5. lower-PI.f32N/A

            \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
          6. lower-*.f32N/A

            \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
          7. lower-sin.f32N/A

            \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), yi \cdot \color{blue}{\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
          8. lower-*.f32N/A

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

            \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), yi \cdot \sin \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
          10. lower-PI.f3294.4

            \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \color{blue}{\pi}\right)\right)\right) \]
        5. Applied rewrites94.4%

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

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

      Alternative 6: 95.8% accurate, 1.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(uy \cdot \pi\right)\\ \mathsf{fma}\left(xi, \cos t\_0, \mathsf{fma}\left(yi, \sin t\_0, maxCos \cdot \left(zi \cdot ux\right)\right)\right) \end{array} \end{array} \]
      (FPCore (xi yi zi ux uy maxCos)
       :precision binary32
       (let* ((t_0 (* 2.0 (* uy PI))))
         (fma xi (cos t_0) (fma yi (sin t_0) (* maxCos (* zi ux))))))
      float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
      	float t_0 = 2.0f * (uy * ((float) M_PI));
      	return fmaf(xi, cosf(t_0), fmaf(yi, sinf(t_0), (maxCos * (zi * ux))));
      }
      
      function code(xi, yi, zi, ux, uy, maxCos)
      	t_0 = Float32(Float32(2.0) * Float32(uy * Float32(pi)))
      	return fma(xi, cos(t_0), fma(yi, sin(t_0), Float32(maxCos * Float32(zi * ux))))
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
      \mathsf{fma}\left(xi, \cos t\_0, \mathsf{fma}\left(yi, \sin t\_0, maxCos \cdot \left(zi \cdot ux\right)\right)\right)
      \end{array}
      \end{array}
      
      Derivation
      1. Initial program 99.0%

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

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

          \[\leadsto \color{blue}{\left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + maxCos \cdot \left(ux \cdot zi\right)} \]
        2. associate-+l+N/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right)} \]
        4. lower-cos.f32N/A

          \[\leadsto \mathsf{fma}\left(xi, \color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right) \]
        5. lower-*.f32N/A

          \[\leadsto \mathsf{fma}\left(xi, \cos \color{blue}{\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right) \]
        6. lower-*.f32N/A

          \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right) \]
        7. lower-PI.f32N/A

          \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right) \]
        8. lower-fma.f32N/A

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{maxCos \cdot \left(ux \cdot zi\right)}\right)\right) \]
        14. lower-*.f3296.1

          \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \pi\right)\right), maxCos \cdot \color{blue}{\left(ux \cdot zi\right)}\right)\right) \]
      5. Applied rewrites96.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \pi\right)\right), maxCos \cdot \left(ux \cdot zi\right)\right)\right)} \]
      6. Final simplification96.1%

        \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \pi\right)\right), maxCos \cdot \left(zi \cdot ux\right)\right)\right) \]
      7. Add Preprocessing

      Alternative 7: 93.8% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

          \[\leadsto xi \cdot \mathsf{fma}\left(yi, \frac{uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)}{xi}, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
        3. Step-by-step derivation
          1. Applied rewrites92.4%

            \[\leadsto xi \cdot \mathsf{fma}\left(yi, \frac{uy \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(uy \cdot uy\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \pi\right)}{xi}, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          2. Final simplification92.4%

            \[\leadsto zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + xi \cdot \mathsf{fma}\left(yi, \frac{uy \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(uy \cdot uy\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \pi\right)}{xi}, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \]
          3. Add Preprocessing

          Alternative 8: 91.3% accurate, 2.3× speedup?

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

            1. Initial program 99.4%

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

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

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

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

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

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

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

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

                \[\leadsto \left(xi + uy \cdot \color{blue}{\left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + uy \cdot \left(-2 \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{-4}{3} \cdot \left(uy \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
              3. Step-by-step derivation
                1. Applied rewrites94.8%

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

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

                1. Initial program 94.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(zi \cdot \left(\left(1 - ux\right) \cdot maxCos\right), ux, yi \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot 1\right)\right) \]
                10. Recombined 2 regimes into one program.
                11. Final simplification92.5%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.3499999940395355:\\ \;\;\;\;zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(zi \cdot \left(\left(1 - ux\right) \cdot maxCos\right), ux, yi \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot 1\right)\right)\\ \end{array} \]
                12. Add Preprocessing

                Alternative 9: 91.3% accurate, 2.4× speedup?

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

                  1. Initial program 99.4%

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

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

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

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

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

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

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

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

                      \[\leadsto \left(xi + uy \cdot \color{blue}{\left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + uy \cdot \left(-2 \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{-4}{3} \cdot \left(uy \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                    3. Step-by-step derivation
                      1. Applied rewrites94.8%

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

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

                      1. Initial program 94.5%

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

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

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

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

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

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

                        \[\leadsto xi \cdot \color{blue}{\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                      7. Step-by-step derivation
                        1. Applied rewrites94.3%

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

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

                            \[\leadsto yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                        4. Recombined 2 regimes into one program.
                        5. Final simplification92.5%

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

                        Alternative 10: 90.9% accurate, 2.8× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.3499999940395355:\\ \;\;\;\;zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\\ \end{array} \end{array} \]
                        (FPCore (xi yi zi ux uy maxCos)
                         :precision binary32
                         (if (<= (* 2.0 uy) 0.3499999940395355)
                           (+
                            (* zi (* ux (* (- 1.0 ux) maxCos)))
                            (fma
                             uy
                             (fma
                              2.0
                              (* PI yi)
                              (*
                               uy
                               (fma
                                -2.0
                                (* xi (* PI PI))
                                (* -1.3333333333333333 (* (* PI (* PI PI)) (* uy yi))))))
                             xi))
                           (* (sin (* 2.0 (* uy PI))) yi)))
                        float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                        	float tmp;
                        	if ((2.0f * uy) <= 0.3499999940395355f) {
                        		tmp = (zi * (ux * ((1.0f - ux) * maxCos))) + fmaf(uy, fmaf(2.0f, (((float) M_PI) * yi), (uy * fmaf(-2.0f, (xi * (((float) M_PI) * ((float) M_PI))), (-1.3333333333333333f * ((((float) M_PI) * (((float) M_PI) * ((float) M_PI))) * (uy * yi)))))), xi);
                        	} else {
                        		tmp = sinf((2.0f * (uy * ((float) M_PI)))) * yi;
                        	}
                        	return tmp;
                        }
                        
                        function code(xi, yi, zi, ux, uy, maxCos)
                        	tmp = Float32(0.0)
                        	if (Float32(Float32(2.0) * uy) <= Float32(0.3499999940395355))
                        		tmp = Float32(Float32(zi * Float32(ux * Float32(Float32(Float32(1.0) - ux) * maxCos))) + fma(uy, fma(Float32(2.0), Float32(Float32(pi) * yi), Float32(uy * fma(Float32(-2.0), Float32(xi * Float32(Float32(pi) * Float32(pi))), Float32(Float32(-1.3333333333333333) * Float32(Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi))) * Float32(uy * yi)))))), xi));
                        	else
                        		tmp = Float32(sin(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * yi);
                        	end
                        	return tmp
                        end
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;2 \cdot uy \leq 0.3499999940395355:\\
                        \;\;\;\;zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (*.f32 uy #s(literal 2 binary32)) < 0.349999994

                          1. Initial program 99.4%

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

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

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

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

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

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

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

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

                              \[\leadsto \left(xi + uy \cdot \color{blue}{\left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + uy \cdot \left(-2 \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{-4}{3} \cdot \left(uy \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                            3. Step-by-step derivation
                              1. Applied rewrites94.8%

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

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

                              1. Initial program 94.5%

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

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

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

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

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

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

                                  \[\leadsto yi \cdot \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
                              8. Recombined 2 regimes into one program.
                              9. Final simplification92.4%

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

                              Alternative 11: 89.4% accurate, 4.2× speedup?

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \left(xi + uy \cdot \color{blue}{\left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + uy \cdot \left(-2 \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \frac{-4}{3} \cdot \left(uy \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                                3. Step-by-step derivation
                                  1. Applied rewrites88.7%

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

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

                                  Alternative 12: 85.9% accurate, 6.0× speedup?

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \left(xi + uy \cdot \color{blue}{\left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites84.6%

                                        \[\leadsto \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, \color{blue}{uy \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right)}, 2 \cdot \left(\pi \cdot yi\right)\right), xi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                                      2. Final simplification84.6%

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

                                      Alternative 13: 81.7% accurate, 9.3× speedup?

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \left(xi + 2 \cdot \color{blue}{\left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites80.6%

                                            \[\leadsto \mathsf{fma}\left(2, uy \cdot \color{blue}{\left(\pi \cdot yi\right)}, xi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                                          2. Final simplification80.6%

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

                                          Alternative 14: 52.1% accurate, 13.1× speedup?

                                          \[\begin{array}{l} \\ zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + xi \cdot 1 \end{array} \]
                                          (FPCore (xi yi zi ux uy maxCos)
                                           :precision binary32
                                           (+ (* zi (* ux (* (- 1.0 ux) maxCos))) (* xi 1.0)))
                                          float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                          	return (zi * (ux * ((1.0f - ux) * maxCos))) + (xi * 1.0f);
                                          }
                                          
                                          real(4) function code(xi, yi, zi, ux, uy, maxcos)
                                              real(4), intent (in) :: xi
                                              real(4), intent (in) :: yi
                                              real(4), intent (in) :: zi
                                              real(4), intent (in) :: ux
                                              real(4), intent (in) :: uy
                                              real(4), intent (in) :: maxcos
                                              code = (zi * (ux * ((1.0e0 - ux) * maxcos))) + (xi * 1.0e0)
                                          end function
                                          
                                          function code(xi, yi, zi, ux, uy, maxCos)
                                          	return Float32(Float32(zi * Float32(ux * Float32(Float32(Float32(1.0) - ux) * maxCos))) + Float32(xi * Float32(1.0)))
                                          end
                                          
                                          function tmp = code(xi, yi, zi, ux, uy, maxCos)
                                          	tmp = (zi * (ux * ((single(1.0) - ux) * maxCos))) + (xi * single(1.0));
                                          end
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + xi \cdot 1
                                          \end{array}
                                          
                                          Derivation
                                          1. Initial program 99.0%

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

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

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

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

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

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

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

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

                                              \[\leadsto xi \cdot 1 + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites53.6%

                                                \[\leadsto xi \cdot 1 + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                                              2. Final simplification53.6%

                                                \[\leadsto zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + xi \cdot 1 \]
                                              3. Add Preprocessing

                                              Alternative 15: 52.1% accurate, 17.7× speedup?

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

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

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

                                                  \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
                                                2. associate-*r*N/A

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

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

                                                  \[\leadsto maxCos \cdot \left(\color{blue}{\left(ux \cdot zi\right)} \cdot \left(1 - ux\right)\right) \]
                                                5. lower--.f3212.5

                                                  \[\leadsto maxCos \cdot \left(\left(ux \cdot zi\right) \cdot \color{blue}{\left(1 - ux\right)}\right) \]
                                              5. Applied rewrites12.5%

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

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

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

                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(xi, \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)} \]
                                              8. Applied rewrites53.6%

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

                                                \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
                                              10. Step-by-step derivation
                                                1. Applied rewrites53.6%

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

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

                                                Alternative 16: 50.1% accurate, 29.4× speedup?

                                                \[\begin{array}{l} \\ \mathsf{fma}\left(maxCos, zi \cdot ux, xi\right) \end{array} \]
                                                (FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma maxCos (* zi ux) xi))
                                                float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                                	return fmaf(maxCos, (zi * ux), xi);
                                                }
                                                
                                                function code(xi, yi, zi, ux, uy, maxCos)
                                                	return fma(maxCos, Float32(zi * ux), xi)
                                                end
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \mathsf{fma}\left(maxCos, zi \cdot ux, xi\right)
                                                \end{array}
                                                
                                                Derivation
                                                1. Initial program 99.0%

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

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

                                                    \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
                                                  2. associate-*r*N/A

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

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

                                                    \[\leadsto maxCos \cdot \left(\color{blue}{\left(ux \cdot zi\right)} \cdot \left(1 - ux\right)\right) \]
                                                  5. lower--.f3212.5

                                                    \[\leadsto maxCos \cdot \left(\left(ux \cdot zi\right) \cdot \color{blue}{\left(1 - ux\right)}\right) \]
                                                5. Applied rewrites12.5%

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

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

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

                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(xi, \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)} \]
                                                8. Applied rewrites53.6%

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

                                                  \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot zi\right)} \]
                                                10. Step-by-step derivation
                                                  1. Applied rewrites51.6%

                                                    \[\leadsto \mathsf{fma}\left(maxCos, \color{blue}{ux \cdot zi}, xi\right) \]
                                                  2. Final simplification51.6%

                                                    \[\leadsto \mathsf{fma}\left(maxCos, zi \cdot ux, xi\right) \]
                                                  3. Add Preprocessing

                                                  Alternative 17: 12.1% accurate, 32.1× speedup?

                                                  \[\begin{array}{l} \\ maxCos \cdot \left(zi \cdot ux\right) \end{array} \]
                                                  (FPCore (xi yi zi ux uy maxCos) :precision binary32 (* maxCos (* zi ux)))
                                                  float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                                  	return maxCos * (zi * ux);
                                                  }
                                                  
                                                  real(4) function code(xi, yi, zi, ux, uy, maxcos)
                                                      real(4), intent (in) :: xi
                                                      real(4), intent (in) :: yi
                                                      real(4), intent (in) :: zi
                                                      real(4), intent (in) :: ux
                                                      real(4), intent (in) :: uy
                                                      real(4), intent (in) :: maxcos
                                                      code = maxcos * (zi * ux)
                                                  end function
                                                  
                                                  function code(xi, yi, zi, ux, uy, maxCos)
                                                  	return Float32(maxCos * Float32(zi * ux))
                                                  end
                                                  
                                                  function tmp = code(xi, yi, zi, ux, uy, maxCos)
                                                  	tmp = maxCos * (zi * ux);
                                                  end
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  maxCos \cdot \left(zi \cdot ux\right)
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Initial program 99.0%

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

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

                                                      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
                                                    2. associate-*r*N/A

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

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

                                                      \[\leadsto maxCos \cdot \left(\color{blue}{\left(ux \cdot zi\right)} \cdot \left(1 - ux\right)\right) \]
                                                    5. lower--.f3212.5

                                                      \[\leadsto maxCos \cdot \left(\left(ux \cdot zi\right) \cdot \color{blue}{\left(1 - ux\right)}\right) \]
                                                  5. Applied rewrites12.5%

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

                                                    \[\leadsto maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
                                                  7. Step-by-step derivation
                                                    1. Applied rewrites11.2%

                                                      \[\leadsto maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
                                                    2. Final simplification11.2%

                                                      \[\leadsto maxCos \cdot \left(zi \cdot ux\right) \]
                                                    3. Add Preprocessing

                                                    Alternative 18: 12.1% accurate, 32.1× speedup?

                                                    \[\begin{array}{l} \\ zi \cdot \left(ux \cdot maxCos\right) \end{array} \]
                                                    (FPCore (xi yi zi ux uy maxCos) :precision binary32 (* zi (* ux maxCos)))
                                                    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                                    	return zi * (ux * maxCos);
                                                    }
                                                    
                                                    real(4) function code(xi, yi, zi, ux, uy, maxcos)
                                                        real(4), intent (in) :: xi
                                                        real(4), intent (in) :: yi
                                                        real(4), intent (in) :: zi
                                                        real(4), intent (in) :: ux
                                                        real(4), intent (in) :: uy
                                                        real(4), intent (in) :: maxcos
                                                        code = zi * (ux * maxcos)
                                                    end function
                                                    
                                                    function code(xi, yi, zi, ux, uy, maxCos)
                                                    	return Float32(zi * Float32(ux * maxCos))
                                                    end
                                                    
                                                    function tmp = code(xi, yi, zi, ux, uy, maxCos)
                                                    	tmp = zi * (ux * maxCos);
                                                    end
                                                    
                                                    \begin{array}{l}
                                                    
                                                    \\
                                                    zi \cdot \left(ux \cdot maxCos\right)
                                                    \end{array}
                                                    
                                                    Derivation
                                                    1. Initial program 99.0%

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

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

                                                        \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
                                                      2. associate-*r*N/A

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

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

                                                        \[\leadsto maxCos \cdot \left(\color{blue}{\left(ux \cdot zi\right)} \cdot \left(1 - ux\right)\right) \]
                                                      5. lower--.f3212.5

                                                        \[\leadsto maxCos \cdot \left(\left(ux \cdot zi\right) \cdot \color{blue}{\left(1 - ux\right)}\right) \]
                                                    5. Applied rewrites12.5%

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

                                                      \[\leadsto maxCos \cdot \color{blue}{\left(ux \cdot zi\right)} \]
                                                    7. Step-by-step derivation
                                                      1. Applied rewrites11.2%

                                                        \[\leadsto \left(maxCos \cdot ux\right) \cdot \color{blue}{zi} \]
                                                      2. Final simplification11.2%

                                                        \[\leadsto zi \cdot \left(ux \cdot maxCos\right) \]
                                                      3. Add Preprocessing

                                                      Reproduce

                                                      ?
                                                      herbie shell --seed 2024237 
                                                      (FPCore (xi yi zi ux uy maxCos)
                                                        :name "UniformSampleCone 2"
                                                        :precision binary32
                                                        :pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0)) (and (<= -10000.0 yi) (<= yi 10000.0))) (and (<= -10000.0 zi) (<= zi 10000.0))) (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) maxCos) ux) (* (* (- 1.0 ux) maxCos) ux))))) xi) (* (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (* (* (- 1.0 ux) maxCos) ux) (* (* (- 1.0 ux) maxCos) ux))))) yi)) (* (* (* (- 1.0 ux) maxCos) ux) zi)))