UniformSampleCone 2

Percentage Accurate: 99.0% → 99.0%
Time: 17.1s
Alternatives: 22
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}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 22 alternatives:

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

Initial Program: 99.0% 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 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\ t_1 := \pi \cdot \left(uy + uy\right)\\ t_2 := \sqrt{1 - t\_0 \cdot t\_0}\\ \mathsf{fma}\left(\cos t\_1 \cdot t\_2, xi, \mathsf{fma}\left(\sin t\_1, t\_2 \cdot yi, t\_0 \cdot zi\right)\right) \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
        (t_1 (* PI (+ uy uy)))
        (t_2 (sqrt (- 1.0 (* t_0 t_0)))))
   (fma (* (cos t_1) t_2) xi (fma (sin t_1) (* t_2 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 = ((float) M_PI) * (uy + uy);
	float t_2 = sqrtf((1.0f - (t_0 * t_0)));
	return fmaf((cosf(t_1) * t_2), xi, fmaf(sinf(t_1), (t_2 * 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 = Float32(Float32(pi) * Float32(uy + uy))
	t_2 = sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0)))
	return fma(Float32(cos(t_1) * t_2), xi, fma(sin(t_1), Float32(t_2 * yi), Float32(t_0 * zi)))
end
\begin{array}{l}

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\pi \cdot \left(uy + uy\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)}, xi, \mathsf{fma}\left(\sin \left(\pi \cdot \left(uy + uy\right)\right), \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)} \cdot yi, \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\right)\right)} \]
  3. Add Preprocessing

Alternative 2: 98.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \mathsf{fma}\left(-0.5, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot \left(ux \cdot ux\right)\\ t_1 := \left(uy \cdot 2\right) \cdot \pi\\ \left(\left(\cos t\_1 \cdot t\_0\right) \cdot xi + \left(\sin t\_1 \cdot t\_0\right) \cdot yi\right) + \left(\left(\left(1 - ux\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
          (* (fma -0.5 (* maxCos maxCos) (* (* maxCos maxCos) ux)) (* ux ux))))
        (t_1 (* (* uy 2.0) PI)))
   (+
    (+ (* (* (cos t_1) t_0) xi) (* (* (sin t_1) t_0) yi))
    (* (* (* (- 1.0 ux) maxCos) ux) zi))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = 1.0f + (fmaf(-0.5f, (maxCos * maxCos), ((maxCos * maxCos) * ux)) * (ux * ux));
	float t_1 = (uy * 2.0f) * ((float) M_PI);
	return (((cosf(t_1) * t_0) * xi) + ((sinf(t_1) * t_0) * yi)) + ((((1.0f - ux) * maxCos) * ux) * zi);
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(1.0) + Float32(fma(Float32(-0.5), Float32(maxCos * maxCos), Float32(Float32(maxCos * maxCos) * ux)) * Float32(ux * ux)))
	t_1 = Float32(Float32(uy * Float32(2.0)) * Float32(pi))
	return Float32(Float32(Float32(Float32(cos(t_1) * t_0) * xi) + Float32(Float32(sin(t_1) * t_0) * yi)) + Float32(Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * ux) * zi))
end
\begin{array}{l}

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

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

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

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, {maxCos}^{2}, {maxCos}^{2} \cdot ux\right) \cdot {\color{blue}{ux}}^{2}\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 \]
    5. unpow2N/A

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, {maxCos}^{2} \cdot ux\right) \cdot {ux}^{2}\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 \]
    8. unpow2N/A

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot {ux}^{2}\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 \]
    10. unpow2N/A

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot \left(ux \cdot \color{blue}{ux}\right)\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 \]
    11. lower-*.f3298.9

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{\left(1 + \mathsf{fma}\left(-0.5, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot \left(ux \cdot ux\right)\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 \]
  5. Taylor expanded in ux around 0

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot \left(ux \cdot ux\right)\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, {maxCos}^{2} \cdot ux\right) \cdot {ux}^{2}\right)\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    8. unpow2N/A

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot \left(ux \cdot ux\right)\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot {ux}^{2}\right)\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    10. unpow2N/A

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot \left(ux \cdot ux\right)\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(1 + \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right) \cdot \left(ux \cdot \color{blue}{ux}\right)\right)\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    11. lower-*.f3298.8

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

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

Alternative 3: 98.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(uy \cdot 2\right) \cdot \pi\\ \left(\left(\cos t\_0 \cdot 1\right) \cdot xi + \left(\sin t\_0 \cdot 1\right) \cdot yi\right) + \left(\left(\left(1 - ux\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)))
   (+
    (+ (* (* (cos t_0) 1.0) xi) (* (* (sin t_0) 1.0) yi))
    (* (* (* (- 1.0 ux) 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);
	return (((cosf(t_0) * 1.0f) * xi) + ((sinf(t_0) * 1.0f) * yi)) + ((((1.0f - ux) * maxCos) * ux) * zi);
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(uy * Float32(2.0)) * Float32(pi))
	return Float32(Float32(Float32(Float32(cos(t_0) * Float32(1.0)) * xi) + Float32(Float32(sin(t_0) * Float32(1.0)) * yi)) + Float32(Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * ux) * zi))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	t_0 = (uy * single(2.0)) * single(pi);
	tmp = (((cos(t_0) * single(1.0)) * xi) + ((sin(t_0) * single(1.0)) * yi)) + ((((single(1.0) - ux) * maxCos) * ux) * zi);
end
\begin{array}{l}

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{1}\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. Taylor expanded in ux around 0

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

        \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot 1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{1}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      2. Add Preprocessing

      Alternative 4: 96.1% accurate, 1.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \pi \cdot \left(uy + uy\right)\\ \mathbf{if}\;uy \leq 0.0006500000017695129:\\ \;\;\;\;xi + \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), uy \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)\\ \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 (* PI (+ uy uy))))
         (if (<= uy 0.0006500000017695129)
           (+
            xi
            (fma
             maxCos
             (* ux (* zi (- 1.0 ux)))
             (* uy (fma -2.0 (* uy (* xi (* PI PI))) (* 2.0 (* yi PI))))))
           (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 = ((float) M_PI) * (uy + uy);
      	float tmp;
      	if (uy <= 0.0006500000017695129f) {
      		tmp = xi + fmaf(maxCos, (ux * (zi * (1.0f - ux))), (uy * fmaf(-2.0f, (uy * (xi * (((float) M_PI) * ((float) M_PI)))), (2.0f * (yi * ((float) M_PI))))));
      	} 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(pi) * Float32(uy + uy))
      	tmp = Float32(0.0)
      	if (uy <= Float32(0.0006500000017695129))
      		tmp = Float32(xi + fma(maxCos, Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))), Float32(uy * fma(Float32(-2.0), Float32(uy * Float32(xi * Float32(Float32(pi) * Float32(pi)))), Float32(Float32(2.0) * Float32(yi * Float32(pi)))))));
      	else
      		tmp = fma(cos(t_0), xi, Float32(sin(t_0) * yi));
      	end
      	return tmp
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \pi \cdot \left(uy + uy\right)\\
      \mathbf{if}\;uy \leq 0.0006500000017695129:\\
      \;\;\;\;xi + \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), uy \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)\\
      
      \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 uy < 6.50000002e-4

        1. Initial program 99.3%

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

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

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

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

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

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

        if 6.50000002e-4 < uy

        1. Initial program 98.3%

          \[\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. Taylor expanded in ux around 0

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

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

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

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

      Alternative 5: 95.9% accurate, 1.7× speedup?

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

        \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      2. 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)} \]
      3. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(maxCos \cdot ux\right) \cdot zi + \left(\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)\right) \]
        2. lower-fma.f32N/A

          \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \color{blue}{zi}, 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) \]
        3. lower-*.f32N/A

          \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, zi, 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. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, zi, \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) \]
        5. lower-fma.f32N/A

          \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, zi, \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)\right) \]
      4. Applied rewrites95.9%

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

      Alternative 6: 90.2% accurate, 2.1× speedup?

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

        \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      2. 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)} + \left(\frac{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}{xi} + \frac{yi \cdot \left(\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)}{xi}\right)\right)} \]
      3. Applied rewrites98.8%

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

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

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

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

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

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

          \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \left(\frac{maxCos \cdot \left(ux \cdot zi\right)}{xi} + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right)\right) \cdot xi \]
        6. div-add-revN/A

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

          \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right) \cdot xi \]
      6. Applied rewrites95.7%

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

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

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

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

          \[\leadsto \left(\left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi}\right) \cdot xi \]
        4. unpow2N/A

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

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

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

          \[\leadsto \left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi}\right) \cdot xi \]
        8. lift-PI.f32N/A

          \[\leadsto \left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi}\right) \cdot xi \]
        9. lift-PI.f3290.2

          \[\leadsto \left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \pi\right)\right)\right) + \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi}\right) \cdot xi \]
      9. Applied rewrites90.2%

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

      Alternative 7: 89.2% accurate, 2.5× speedup?

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

        1. Initial program 99.3%

          \[\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. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
        3. Applied rewrites97.5%

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

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

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

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

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

        if 0.00700000022 < uy

        1. Initial program 97.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. 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)} + \left(\frac{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}{xi} + \frac{yi \cdot \left(\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)}{xi}\right)\right)} \]
        3. Applied rewrites97.7%

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

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

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

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

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

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

            \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \left(\frac{maxCos \cdot \left(ux \cdot zi\right)}{xi} + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right)\right) \cdot xi \]
          6. div-add-revN/A

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

            \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right) \cdot xi \]
        6. Applied rewrites94.6%

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

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

            \[\leadsto \left(1 + \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi}\right) \cdot xi \]
        9. Recombined 2 regimes into one program.
        10. Add Preprocessing

        Alternative 8: 87.9% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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

                if 0.180000007 < uy

                1. Initial program 96.4%

                  \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                2. 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)} + \left(\frac{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}{xi} + \frac{yi \cdot \left(\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)}{xi}\right)\right)} \]
                3. Applied rewrites96.1%

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

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

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

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

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

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

                    \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \left(\frac{maxCos \cdot \left(ux \cdot zi\right)}{xi} + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right)\right) \cdot xi \]
                  6. div-add-revN/A

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

                    \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right) \cdot xi \]
                6. Applied rewrites92.8%

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

                  \[\leadsto \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi} \cdot xi \]
                8. Step-by-step derivation
                  1. lift-*.f32N/A

                    \[\leadsto \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi} \cdot xi \]
                  2. lift-PI.f32N/A

                    \[\leadsto \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi} \cdot xi \]
                  3. lift-*.f32N/A

                    \[\leadsto \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi} \cdot xi \]
                  4. lift-sin.f32N/A

                    \[\leadsto \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi} \cdot xi \]
                  5. lift-*.f32N/A

                    \[\leadsto \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi} \cdot xi \]
                  6. lift-fma.f32N/A

                    \[\leadsto \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi} \cdot xi \]
                  7. lift-*.f32N/A

                    \[\leadsto \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi} \cdot xi \]
                  8. lift-/.f3247.8

                    \[\leadsto \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi} \cdot xi \]
                9. Applied rewrites47.8%

                  \[\leadsto \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi} \cdot xi \]
              4. Recombined 2 regimes into one program.
              5. Add Preprocessing

              Alternative 9: 87.3% accurate, 2.4× speedup?

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

                \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
              2. 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)} + \left(\frac{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}{xi} + \frac{yi \cdot \left(\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)}{xi}\right)\right)} \]
              3. Applied rewrites98.8%

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

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

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

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

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

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

                  \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \left(\frac{maxCos \cdot \left(ux \cdot zi\right)}{xi} + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right)\right) \cdot xi \]
                6. div-add-revN/A

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

                  \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right) \cdot xi \]
              6. Applied rewrites95.7%

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

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

                  \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)}{xi}\right) \cdot xi \]
                2. lift-PI.f32N/A

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

                  \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \frac{\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)}{xi}\right) \cdot xi \]
              9. Applied rewrites87.3%

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

              Alternative 10: 86.0% accurate, 3.2× speedup?

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

                \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
              2. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
              3. Applied rewrites86.1%

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

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

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

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

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

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

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

                    Alternative 11: 86.0% accurate, 3.9× speedup?

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

                      \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                    2. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                    3. Applied rewrites86.1%

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

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

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

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

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

                    Alternative 12: 83.3% accurate, 4.1× speedup?

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

                      \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                    2. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                    3. Applied rewrites86.1%

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

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

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

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

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

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                    6. Applied rewrites83.3%

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

                      \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \left(-2 \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right) + 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{uy}\right)\right)\right) \]
                    8. Step-by-step derivation
                      1. lower-*.f32N/A

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

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \mathsf{fma}\left(-2, xi \cdot {\mathsf{PI}\left(\right)}^{2}, 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{uy}\right)\right)\right) \]
                      3. pow2N/A

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{uy}\right)\right)\right) \]
                      4. lift-*.f32N/A

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{uy}\right)\right)\right) \]
                      5. lift-PI.f32N/A

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \mathsf{PI}\left(\right)\right), 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{uy}\right)\right)\right) \]
                      6. lift-PI.f32N/A

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{uy}\right)\right)\right) \]
                      7. lift-*.f32N/A

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

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

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{uy}\right)\right)\right) \]
                      10. lift-*.f32N/A

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{uy}\right)\right)\right) \]
                      11. lift-PI.f3283.3

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), 2 \cdot \frac{yi \cdot \pi}{uy}\right)\right)\right) \]
                    9. Applied rewrites83.3%

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

                    Alternative 13: 83.3% accurate, 4.2× speedup?

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

                      \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                    2. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                    3. Applied rewrites86.1%

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

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

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

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

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

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                    6. Applied rewrites83.3%

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

                      \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, -2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                    8. Step-by-step derivation
                      1. lower-fma.f32N/A

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

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(-2, {uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right), 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                      3. unpow2N/A

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

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(-2, \left(uy \cdot uy\right) \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right), 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                      5. pow2N/A

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

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

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

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

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

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

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(-2, \left(uy \cdot uy\right) \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                      12. lift-*.f32N/A

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(-2, \left(uy \cdot uy\right) \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
                      13. lift-PI.f3283.3

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(-2, \left(uy \cdot uy\right) \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right)\right) \]
                    9. Applied rewrites83.3%

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

                    Alternative 14: 83.3% accurate, 4.5× speedup?

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

                      \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                    2. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                    3. Applied rewrites86.1%

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

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

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

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

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

                        \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                    6. Applied rewrites83.3%

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

                    Alternative 15: 81.9% accurate, 4.9× speedup?

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

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

                      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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 \]
                    3. Step-by-step derivation
                      1. associate-*r*N/A

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

                        \[\leadsto \left(\left(uy \cdot 2\right) \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                      3. lift-*.f32N/A

                        \[\leadsto \left(\left(uy \cdot 2\right) \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                      4. lower-fma.f32N/A

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

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

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

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

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

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

                        Alternative 16: 81.9% accurate, 5.9× speedup?

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

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

                          \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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 \]
                        3. Step-by-step derivation
                          1. associate-*r*N/A

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

                            \[\leadsto \left(\left(uy \cdot 2\right) \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          3. lift-*.f32N/A

                            \[\leadsto \left(\left(uy \cdot 2\right) \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          4. lower-fma.f32N/A

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

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

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

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

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

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

                            \[\leadsto \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          5. lift-PI.f3281.9

                            \[\leadsto \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                        7. Applied rewrites81.9%

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

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

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

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

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

                            \[\leadsto \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          6. fp-cancel-sign-sub-invN/A

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

                            \[\leadsto \left(xi - \left(\mathsf{neg}\left(2\right)\right) \cdot \color{blue}{\left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          8. metadata-evalN/A

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

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

                            \[\leadsto \left(xi - -2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          11. lift-PI.f32N/A

                            \[\leadsto \left(xi - -2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          12. lift-*.f3281.9

                            \[\leadsto \left(xi - -2 \cdot \left(uy \cdot \left(yi \cdot \color{blue}{\pi}\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                        9. Applied rewrites81.9%

                          \[\leadsto \left(xi - \color{blue}{-2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                        10. Add Preprocessing

                        Alternative 17: 79.3% accurate, 7.4× speedup?

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

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

                          \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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 \]
                        3. Step-by-step derivation
                          1. associate-*r*N/A

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

                            \[\leadsto \left(\left(uy \cdot 2\right) \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          3. lift-*.f32N/A

                            \[\leadsto \left(\left(uy \cdot 2\right) \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          4. lower-fma.f32N/A

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

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

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

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

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

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

                            \[\leadsto \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          5. lift-PI.f3281.9

                            \[\leadsto \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                        7. Applied rewrites81.9%

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

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

                            \[\leadsto \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right) + \left(\color{blue}{maxCos} \cdot ux\right) \cdot zi \]
                          2. Add Preprocessing

                          Alternative 18: 79.3% accurate, 7.6× speedup?

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

                            \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          2. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                          3. Applied rewrites86.1%

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

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

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

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

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

                              \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                          6. Applied rewrites83.3%

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

                            \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                          8. Step-by-step derivation
                            1. lift-*.f32N/A

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

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

                              \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(2 \cdot \left(yi \cdot \pi\right)\right)\right) \]
                          9. Applied rewrites79.3%

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

                          Alternative 19: 74.5% accurate, 12.4× speedup?

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

                            \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          2. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                          3. Applied rewrites86.1%

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

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

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

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

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

                              \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                          6. Applied rewrites83.3%

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

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

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

                              \[\leadsto xi + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right) \]
                            3. lift-*.f32N/A

                              \[\leadsto xi + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right) \]
                            4. lift-PI.f3274.5

                              \[\leadsto xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) \]
                          9. Applied rewrites74.5%

                            \[\leadsto xi + 2 \cdot \left(uy \cdot \color{blue}{\left(yi \cdot \pi\right)}\right) \]
                          10. Add Preprocessing

                          Alternative 20: 59.7% accurate, 8.9× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\\ \mathbf{if}\;yi \leq -9.999999717180685 \cdot 10^{-10}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;yi \leq 5.500000072890775 \cdot 10^{-14}:\\ \;\;\;\;xi + maxCos \cdot \left(ux \cdot zi\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                          (FPCore (xi yi zi ux uy maxCos)
                           :precision binary32
                           (let* ((t_0 (* 2.0 (* uy (* yi PI)))))
                             (if (<= yi -9.999999717180685e-10)
                               t_0
                               (if (<= yi 5.500000072890775e-14) (+ xi (* maxCos (* ux zi))) t_0))))
                          float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                          	float t_0 = 2.0f * (uy * (yi * ((float) M_PI)));
                          	float tmp;
                          	if (yi <= -9.999999717180685e-10f) {
                          		tmp = t_0;
                          	} else if (yi <= 5.500000072890775e-14f) {
                          		tmp = xi + (maxCos * (ux * zi));
                          	} else {
                          		tmp = t_0;
                          	}
                          	return tmp;
                          }
                          
                          function code(xi, yi, zi, ux, uy, maxCos)
                          	t_0 = Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi))))
                          	tmp = Float32(0.0)
                          	if (yi <= Float32(-9.999999717180685e-10))
                          		tmp = t_0;
                          	elseif (yi <= Float32(5.500000072890775e-14))
                          		tmp = Float32(xi + Float32(maxCos * Float32(ux * zi)));
                          	else
                          		tmp = t_0;
                          	end
                          	return tmp
                          end
                          
                          function tmp_2 = code(xi, yi, zi, ux, uy, maxCos)
                          	t_0 = single(2.0) * (uy * (yi * single(pi)));
                          	tmp = single(0.0);
                          	if (yi <= single(-9.999999717180685e-10))
                          		tmp = t_0;
                          	elseif (yi <= single(5.500000072890775e-14))
                          		tmp = xi + (maxCos * (ux * zi));
                          	else
                          		tmp = t_0;
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          t_0 := 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\\
                          \mathbf{if}\;yi \leq -9.999999717180685 \cdot 10^{-10}:\\
                          \;\;\;\;t\_0\\
                          
                          \mathbf{elif}\;yi \leq 5.500000072890775 \cdot 10^{-14}:\\
                          \;\;\;\;xi + maxCos \cdot \left(ux \cdot zi\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;t\_0\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if yi < -9.99999972e-10 or 5.50000007e-14 < yi

                            1. Initial program 98.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. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                            3. Applied rewrites83.1%

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

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

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

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

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

                                \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                            6. Applied rewrites82.2%

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

                              \[\leadsto 2 \cdot \left(uy \cdot \color{blue}{\left(yi \cdot \mathsf{PI}\left(\right)\right)}\right) \]
                            8. Step-by-step derivation
                              1. lower-*.f32N/A

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

                                \[\leadsto 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right) \]
                              3. lift-*.f32N/A

                                \[\leadsto 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right) \]
                              4. lift-PI.f3254.1

                                \[\leadsto 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) \]
                            9. Applied rewrites54.1%

                              \[\leadsto 2 \cdot \left(uy \cdot \color{blue}{\left(yi \cdot \pi\right)}\right) \]

                            if -9.99999972e-10 < yi < 5.50000007e-14

                            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. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                            3. Applied rewrites87.8%

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

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

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

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

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

                                \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                            6. Applied rewrites84.0%

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

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

                                \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
                              2. lift-*.f3262.8

                                \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
                            9. Applied rewrites62.8%

                              \[\leadsto xi + maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
                          3. Recombined 2 regimes into one program.
                          4. Add Preprocessing

                          Alternative 21: 50.0% accurate, 16.4× speedup?

                          \[\begin{array}{l} \\ xi + maxCos \cdot \left(ux \cdot zi\right) \end{array} \]
                          (FPCore (xi yi zi ux uy maxCos)
                           :precision binary32
                           (+ xi (* maxCos (* ux zi))))
                          float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                          	return xi + (maxCos * (ux * zi));
                          }
                          
                          module fmin_fmax_functions
                              implicit none
                              private
                              public fmax
                              public fmin
                          
                              interface fmax
                                  module procedure fmax88
                                  module procedure fmax44
                                  module procedure fmax84
                                  module procedure fmax48
                              end interface
                              interface fmin
                                  module procedure fmin88
                                  module procedure fmin44
                                  module procedure fmin84
                                  module procedure fmin48
                              end interface
                          contains
                              real(8) function fmax88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmax44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmax84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmax48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                              end function
                              real(8) function fmin88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmin44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmin84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmin48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                              end function
                          end module
                          
                          real(4) function code(xi, yi, zi, ux, uy, maxcos)
                          use fmin_fmax_functions
                              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 = xi + (maxcos * (ux * zi))
                          end function
                          
                          function code(xi, yi, zi, ux, uy, maxCos)
                          	return Float32(xi + Float32(maxCos * Float32(ux * zi)))
                          end
                          
                          function tmp = code(xi, yi, zi, ux, uy, maxCos)
                          	tmp = xi + (maxCos * (ux * zi));
                          end
                          
                          \begin{array}{l}
                          
                          \\
                          xi + maxCos \cdot \left(ux \cdot zi\right)
                          \end{array}
                          
                          Derivation
                          1. Initial program 99.0%

                            \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          2. 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(uy \cdot \left(xi \cdot \left({\mathsf{PI}\left(\right)}^{2} \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)\right)\right) + 2 \cdot \left(yi \cdot \left(\mathsf{PI}\left(\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)} \]
                          3. Applied rewrites86.1%

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

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

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

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

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

                              \[\leadsto xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
                          6. Applied rewrites83.3%

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

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

                              \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
                            2. lift-*.f3250.0

                              \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
                          9. Applied rewrites50.0%

                            \[\leadsto xi + maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
                          10. Add Preprocessing

                          Alternative 22: 46.0% accurate, 39.1× speedup?

                          \[\begin{array}{l} \\ 1 \cdot xi \end{array} \]
                          (FPCore (xi yi zi ux uy maxCos) :precision binary32 (* 1.0 xi))
                          float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                          	return 1.0f * xi;
                          }
                          
                          module fmin_fmax_functions
                              implicit none
                              private
                              public fmax
                              public fmin
                          
                              interface fmax
                                  module procedure fmax88
                                  module procedure fmax44
                                  module procedure fmax84
                                  module procedure fmax48
                              end interface
                              interface fmin
                                  module procedure fmin88
                                  module procedure fmin44
                                  module procedure fmin84
                                  module procedure fmin48
                              end interface
                          contains
                              real(8) function fmax88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmax44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmax84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmax48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                              end function
                              real(8) function fmin88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmin44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmin84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmin48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                              end function
                          end module
                          
                          real(4) function code(xi, yi, zi, ux, uy, maxcos)
                          use fmin_fmax_functions
                              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 = 1.0e0 * xi
                          end function
                          
                          function code(xi, yi, zi, ux, uy, maxCos)
                          	return Float32(Float32(1.0) * xi)
                          end
                          
                          function tmp = code(xi, yi, zi, ux, uy, maxCos)
                          	tmp = single(1.0) * xi;
                          end
                          
                          \begin{array}{l}
                          
                          \\
                          1 \cdot xi
                          \end{array}
                          
                          Derivation
                          1. Initial program 99.0%

                            \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
                          2. 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)} + \left(\frac{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}{xi} + \frac{yi \cdot \left(\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right)}{xi}\right)\right)} \]
                          3. Applied rewrites98.8%

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

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

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

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

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

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

                              \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \left(\frac{maxCos \cdot \left(ux \cdot zi\right)}{xi} + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right)\right) \cdot xi \]
                            6. div-add-revN/A

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

                              \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \frac{maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right) \cdot xi \]
                          6. Applied rewrites95.7%

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

                            \[\leadsto \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi \]
                          8. Step-by-step derivation
                            1. lift-*.f32N/A

                              \[\leadsto \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi \]
                            2. lift-PI.f32N/A

                              \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot xi \]
                            3. lift-*.f32N/A

                              \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot xi \]
                            4. lift-cos.f3253.2

                              \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot xi \]
                          9. Applied rewrites53.2%

                            \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot xi \]
                          10. Taylor expanded in uy around 0

                            \[\leadsto 1 \cdot xi \]
                          11. Step-by-step derivation
                            1. Applied rewrites46.0%

                              \[\leadsto 1 \cdot xi \]
                            2. Add Preprocessing

                            Reproduce

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