UniformSampleCone 2

Percentage Accurate: 98.9% → 99.0%
Time: 19.8s
Alternatives: 21
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 21 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 := maxCos \cdot \left(1 - ux\right)\\ t_1 := \sqrt{1 - \left(\left(t\_0 \cdot ux\right) \cdot ux\right) \cdot t\_0}\\ t_2 := \left(uy \cdot 2\right) \cdot \pi\\ \mathsf{fma}\left(\left(1 - ux\right) \cdot zi, maxCos \cdot ux, \mathsf{fma}\left(t\_1 \cdot yi, \sin t\_2, \cos t\_2 \cdot \left(xi \cdot t\_1\right)\right)\right) \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* maxCos (- 1.0 ux)))
        (t_1 (sqrt (- 1.0 (* (* (* t_0 ux) ux) t_0))))
        (t_2 (* (* uy 2.0) PI)))
   (fma
    (* (- 1.0 ux) zi)
    (* maxCos ux)
    (fma (* t_1 yi) (sin t_2) (* (cos t_2) (* xi t_1))))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = maxCos * (1.0f - ux);
	float t_1 = sqrtf((1.0f - (((t_0 * ux) * ux) * t_0)));
	float t_2 = (uy * 2.0f) * ((float) M_PI);
	return fmaf(((1.0f - ux) * zi), (maxCos * ux), fmaf((t_1 * yi), sinf(t_2), (cosf(t_2) * (xi * t_1))));
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(maxCos * Float32(Float32(1.0) - ux))
	t_1 = sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(t_0 * ux) * ux) * t_0)))
	t_2 = Float32(Float32(uy * Float32(2.0)) * Float32(pi))
	return fma(Float32(Float32(Float32(1.0) - ux) * zi), Float32(maxCos * ux), fma(Float32(t_1 * yi), sin(t_2), Float32(cos(t_2) * Float32(xi * t_1))))
end
\begin{array}{l}

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

    \[\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. lift-*.f32N/A

      \[\leadsto zi \cdot \left(\color{blue}{\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) \]
    7. associate-*l*N/A

      \[\leadsto zi \cdot \color{blue}{\left(\left(1 - ux\right) \cdot \left(maxCos \cdot ux\right)\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) \]
    8. associate-*r*N/A

      \[\leadsto \color{blue}{\left(zi \cdot \left(1 - ux\right)\right) \cdot \left(maxCos \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) \]
  4. Applied rewrites99.0%

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

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

Alternative 2: 98.6% accurate, 1.1× speedup?

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

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

    \[\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. *-commutativeN/A

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

      \[\leadsto \color{blue}{\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) \cdot xi} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  5. Applied rewrites98.0%

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

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

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

    Alternative 3: 98.7% accurate, 1.4× speedup?

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

      \[\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 maxCos around 0

      \[\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)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi} + yi \cdot \sin \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 \]
      2. lower-fma.f32N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}, xi, yi \cdot \sin \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 \]
      4. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(\cos \color{blue}{\left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)}, xi, yi \cdot \sin \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 \]
      6. *-commutativeN/A

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

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

        \[\leadsto \mathsf{fma}\left(\cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot uy\right) \cdot 2\right), xi, yi \cdot \sin \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 \]
      9. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

    Alternative 4: 98.7% accurate, 1.4× speedup?

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

      \[\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 maxCos around 0

      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\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 \left(zi \cdot \left(1 - ux\right)\right)\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 \left(zi \cdot \left(1 - ux\right)\right)\right)\right)} \]
      3. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 97.5% accurate, 1.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(uy \cdot \pi\right) \cdot 2\\ t_1 := \left(1 - ux\right) \cdot ux\\ t_2 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(t\_1 \cdot t\_1\right)}\\ \mathbf{if}\;uy \cdot 2 \leq 0.019500000402331352:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-1.3333333333333333, \left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot yi\right) \cdot uy, \left(\left(\pi \cdot \pi\right) \cdot xi\right) \cdot -2\right) \cdot t\_2, uy, \left(\left(\pi \cdot yi\right) \cdot 2\right) \cdot t\_2\right), uy, t\_2 \cdot xi\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\cos t\_0, xi, \sin t\_0 \cdot yi\right)\\ \end{array} \end{array} \]
    (FPCore (xi yi zi ux uy maxCos)
     :precision binary32
     (let* ((t_0 (* (* uy PI) 2.0))
            (t_1 (* (- 1.0 ux) ux))
            (t_2 (sqrt (- 1.0 (* (* maxCos maxCos) (* t_1 t_1))))))
       (if (<= (* uy 2.0) 0.019500000402331352)
         (-
          (fma
           (fma
            (*
             (fma
              -1.3333333333333333
              (* (* (* (* PI PI) PI) yi) uy)
              (* (* (* PI PI) xi) -2.0))
             t_2)
            uy
            (* (* (* PI yi) 2.0) t_2))
           uy
           (* t_2 xi))
          (* (* (* (- ux 1.0) maxCos) ux) zi))
         (fma (cos t_0) xi (* (sin t_0) yi)))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	float t_0 = (uy * ((float) M_PI)) * 2.0f;
    	float t_1 = (1.0f - ux) * ux;
    	float t_2 = sqrtf((1.0f - ((maxCos * maxCos) * (t_1 * t_1))));
    	float tmp;
    	if ((uy * 2.0f) <= 0.019500000402331352f) {
    		tmp = fmaf(fmaf((fmaf(-1.3333333333333333f, ((((((float) M_PI) * ((float) M_PI)) * ((float) M_PI)) * yi) * uy), (((((float) M_PI) * ((float) M_PI)) * xi) * -2.0f)) * t_2), uy, (((((float) M_PI) * yi) * 2.0f) * t_2)), uy, (t_2 * xi)) - ((((ux - 1.0f) * maxCos) * ux) * zi);
    	} else {
    		tmp = fmaf(cosf(t_0), xi, (sinf(t_0) * yi));
    	}
    	return tmp;
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	t_0 = Float32(Float32(uy * Float32(pi)) * Float32(2.0))
    	t_1 = Float32(Float32(Float32(1.0) - ux) * ux)
    	t_2 = sqrt(Float32(Float32(1.0) - Float32(Float32(maxCos * maxCos) * Float32(t_1 * t_1))))
    	tmp = Float32(0.0)
    	if (Float32(uy * Float32(2.0)) <= Float32(0.019500000402331352))
    		tmp = Float32(fma(fma(Float32(fma(Float32(-1.3333333333333333), Float32(Float32(Float32(Float32(Float32(pi) * Float32(pi)) * Float32(pi)) * yi) * uy), Float32(Float32(Float32(Float32(pi) * Float32(pi)) * xi) * Float32(-2.0))) * t_2), uy, Float32(Float32(Float32(Float32(pi) * yi) * Float32(2.0)) * t_2)), uy, Float32(t_2 * xi)) - Float32(Float32(Float32(Float32(ux - Float32(1.0)) * maxCos) * ux) * zi));
    	else
    		tmp = fma(cos(t_0), xi, Float32(sin(t_0) * yi));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \left(uy \cdot \pi\right) \cdot 2\\
    t_1 := \left(1 - ux\right) \cdot ux\\
    t_2 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(t\_1 \cdot t\_1\right)}\\
    \mathbf{if}\;uy \cdot 2 \leq 0.019500000402331352:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-1.3333333333333333, \left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot yi\right) \cdot uy, \left(\left(\pi \cdot \pi\right) \cdot xi\right) \cdot -2\right) \cdot t\_2, uy, \left(\left(\pi \cdot yi\right) \cdot 2\right) \cdot t\_2\right), uy, t\_2 \cdot xi\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(\cos t\_0, xi, \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.0195000004

      1. Initial program 99.2%

        \[\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 uy around 0

        \[\leadsto \color{blue}{\left(uy \cdot \left(2 \cdot \left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) + uy \cdot \left(-2 \cdot \left(\left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) + \frac{-4}{3} \cdot \left(\left(uy \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\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. Applied rewrites99.4%

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

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

      1. Initial program 97.8%

        \[\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 maxCos 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 6: 97.5% accurate, 1.5× speedup?

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

      1. Initial program 99.2%

        \[\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 uy around 0

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

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

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

      1. Initial program 97.8%

        \[\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 maxCos 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 95.7% accurate, 1.5× speedup?

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

      \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 89.6% accurate, 1.6× speedup?

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

      \[\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. *-commutativeN/A

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

        \[\leadsto \color{blue}{\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) \cdot xi} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. Applied rewrites98.0%

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

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

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

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

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

        Alternative 9: 89.4% accurate, 1.7× speedup?

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

          \[\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. *-commutativeN/A

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

            \[\leadsto \color{blue}{\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) \cdot xi} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
        5. Applied rewrites98.0%

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

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

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

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

          Alternative 10: 89.2% accurate, 2.0× speedup?

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

            \[\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. *-commutativeN/A

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

              \[\leadsto \color{blue}{\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) \cdot xi} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          5. Applied rewrites98.0%

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

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

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

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

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

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

              Alternative 11: 88.5% accurate, 2.3× speedup?

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

                \[\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. *-commutativeN/A

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

                  \[\leadsto \color{blue}{\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) \cdot xi} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
              5. Applied rewrites98.0%

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

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

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

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

                Alternative 12: 85.5% accurate, 2.3× speedup?

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

                  \[\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 uy around 0

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

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

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

                Alternative 13: 84.1% accurate, 2.8× speedup?

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

                  1. Initial program 99.1%

                    \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto 2 \cdot \left(\left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) + \color{blue}{\left(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)\right)} \]
                      2. associate-+r+N/A

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

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

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

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

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

                    1. Initial program 97.1%

                      \[\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 0

                      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \cos \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}{\left(xi \cdot \cos \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)} + 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 \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \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)} \]
                    5. Applied rewrites52.4%

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

                      \[\leadsto xi \cdot \color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                    7. Step-by-step derivation
                      1. Applied rewrites52.0%

                        \[\leadsto \cos \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot \color{blue}{xi} \]
                    8. Recombined 2 regimes into one program.
                    9. Final simplification85.6%

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

                    Alternative 14: 84.9% accurate, 3.0× speedup?

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

                      \[\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. *-commutativeN/A

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

                        \[\leadsto \color{blue}{\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) \cdot xi} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                    5. Applied rewrites98.0%

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

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

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

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

                      Alternative 15: 81.5% accurate, 4.2× speedup?

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

                        \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto 2 \cdot \left(\left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) + \color{blue}{\left(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)\right)} \]
                          2. associate-+r+N/A

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

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

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

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

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

                        Alternative 16: 81.5% accurate, 4.2× speedup?

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

                          \[\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 uy around 0

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

                            \[\leadsto 2 \cdot \left(\left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) + \color{blue}{\left(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)\right)} \]
                          2. associate-+r+N/A

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

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

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

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

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

                        Alternative 17: 54.5% accurate, 4.5× speedup?

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

                          \[\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 0

                          \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \cos \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}{\left(xi \cdot \cos \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)} + 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 \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \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)} \]
                        5. Applied rewrites54.7%

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

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

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

                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi, xi\right), \sqrt{1 - {ux}^{2} \cdot \left(maxCos \cdot maxCos\right)}, \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos\right) \]
                          3. Step-by-step derivation
                            1. Applied rewrites50.6%

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

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

                            Alternative 18: 54.5% accurate, 5.8× speedup?

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

                              \[\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 0

                              \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \cos \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}{\left(xi \cdot \cos \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)} + 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 \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \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)} \]
                            5. Applied rewrites54.7%

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

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

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

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

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

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

                                Alternative 19: 54.5% accurate, 5.8× speedup?

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

                                  \[\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 0

                                  \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \cos \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}{\left(xi \cdot \cos \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)} + 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 \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \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)} \]
                                5. Applied rewrites54.7%

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

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

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

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

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

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

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

                                      Alternative 20: 13.6% accurate, 18.6× speedup?

                                      \[\begin{array}{l} \\ \left(maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot zi\right) \end{array} \]
                                      (FPCore (xi yi zi ux uy maxCos)
                                       :precision binary32
                                       (* (* maxCos ux) (* (- 1.0 ux) zi)))
                                      float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                      	return (maxCos * ux) * ((1.0f - ux) * zi);
                                      }
                                      
                                      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 * ux) * ((1.0e0 - ux) * zi)
                                      end function
                                      
                                      function code(xi, yi, zi, ux, uy, maxCos)
                                      	return Float32(Float32(maxCos * ux) * Float32(Float32(Float32(1.0) - ux) * zi))
                                      end
                                      
                                      function tmp = code(xi, yi, zi, ux, uy, maxCos)
                                      	tmp = (maxCos * ux) * ((single(1.0) - ux) * zi);
                                      end
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \left(maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot zi\right)
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 98.9%

                                        \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                                        Alternative 21: 12.1% accurate, 32.1× speedup?

                                        \[\begin{array}{l} \\ \left(ux \cdot zi\right) \cdot maxCos \end{array} \]
                                        (FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* ux zi) maxCos))
                                        float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                        	return (ux * zi) * 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 = (ux * zi) * maxcos
                                        end function
                                        
                                        function code(xi, yi, zi, ux, uy, maxCos)
                                        	return Float32(Float32(ux * zi) * maxCos)
                                        end
                                        
                                        function tmp = code(xi, yi, zi, ux, uy, maxCos)
                                        	tmp = (ux * zi) * maxCos;
                                        end
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \left(ux \cdot zi\right) \cdot maxCos
                                        \end{array}
                                        
                                        Derivation
                                        1. Initial program 98.9%

                                          \[\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. *-commutativeN/A

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

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

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

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

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

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

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

                                          \[\leadsto \left(ux \cdot zi\right) \cdot maxCos \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites10.5%

                                            \[\leadsto \left(zi \cdot ux\right) \cdot maxCos \]
                                          2. Final simplification10.5%

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

                                          Reproduce

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