UniformSampleCone 2

Percentage Accurate: 98.9% → 99.0%
Time: 8.6s
Alternatives: 19
Speedup: 1.4×

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 19 alternatives:

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\ t_1 := \pi \cdot \left(2 \cdot uy\right)\\ t_2 := \sin \cos^{-1} t\_0\\ \mathsf{fma}\left(\sin t\_1 \cdot t\_2, yi, \cos t\_1 \cdot \left(t\_2 \cdot xi\right)\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 (* PI (* 2.0 uy)))
        (t_2 (sin (acos t_0))))
   (+ (fma (* (sin t_1) t_2) yi (* (cos t_1) (* t_2 xi))) (* 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) * (2.0f * uy);
	float t_2 = sinf(acosf(t_0));
	return fmaf((sinf(t_1) * t_2), yi, (cosf(t_1) * (t_2 * xi))) + (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(Float32(2.0) * uy))
	t_2 = sin(acos(t_0))
	return Float32(fma(Float32(sin(t_1) * t_2), yi, Float32(cos(t_1) * Float32(t_2 * xi))) + 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(2 \cdot uy\right)\\
t_2 := \sin \cos^{-1} t\_0\\
\mathsf{fma}\left(\sin t\_1 \cdot t\_2, yi, \cos t\_1 \cdot \left(t\_2 \cdot xi\right)\right) + t\_0 \cdot zi
\end{array}
\end{array}
Derivation
  1. Initial program 98.9%

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

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

Alternative 3: 98.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\ t_1 := \pi \cdot \left(2 \cdot uy\right)\\ t_2 := \sin \cos^{-1} 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 (* 2.0 uy)))
        (t_2 (sin (acos 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) * (2.0f * uy);
	float t_2 = sinf(acosf(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(Float32(2.0) * uy))
	t_2 = sin(acos(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(2 \cdot uy\right)\\
t_2 := \sin \cos^{-1} 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 98.9%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sin \cos^{-1} \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right), xi, \mathsf{fma}\left(\sin \left(\pi \cdot \left(2 \cdot uy\right)\right), \sin \cos^{-1} \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 4: 98.8% accurate, 1.5× speedup?

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

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

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

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

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

Alternative 5: 98.8% accurate, 2.2× speedup?

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

\\
\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \mathsf{fma}\left(\sin \left(\left(-\left(\pi \cdot uy\right) \cdot 2\right) + \frac{\pi}{2}\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)\right)
\end{array}
Derivation
  1. Initial program 98.9%

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
    6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \mathsf{fma}\left(\cos \left(\mathsf{neg}\left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)\right) \]
    10. associate-*r*N/A

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

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

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

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

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

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

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

Alternative 6: 98.8% accurate, 2.6× speedup?

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
    6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 98.7% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \pi \cdot \left(2 \cdot uy\right)\\ \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot 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 (* 2.0 uy))))
   (fma (* maxCos ux) (* (- 1.0 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) * (2.0f * uy);
	return fmaf((maxCos * ux), ((1.0f - 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(Float32(2.0) * uy))
	return fma(Float32(maxCos * ux), Float32(Float32(Float32(1.0) - ux) * zi), fma(cos(t_0), xi, Float32(sin(t_0) * yi)))
end
\begin{array}{l}

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

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
    6. lift--.f32N/A

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

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

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

Alternative 8: 97.6% accurate, 2.3× speedup?

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

\\
\begin{array}{l}
t_0 := \pi \cdot \left(2 \cdot uy\right)\\
t_1 := \cos t\_0\\
\mathbf{if}\;uy \leq 9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \mathsf{fma}\left(t\_1, xi, \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(t\_1, xi, \sin t\_0 \cdot yi\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 9.99999975e-5

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

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

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

        \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
      6. lift--.f32N/A

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

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

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

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

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

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

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

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

    if 9.99999975e-5 < 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}{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.4%

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

Alternative 9: 97.6% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\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. Split input into 2 regimes
  2. if uy < 9.60000034e-5

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

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

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

        \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
      6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

    if 9.60000034e-5 < 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}{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.5%

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

Alternative 10: 95.3% accurate, 3.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\pi \cdot uy\right) \cdot 2\\
\mathbf{if}\;uy \leq 9.600000339560211 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(yi, \frac{\sin t\_0}{xi}, \cos t\_0\right) \cdot xi\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 9.60000034e-5

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

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

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

        \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
      6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

    if 9.60000034e-5 < 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.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
    5. Taylor expanded in xi around inf

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

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

        \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right) \cdot xi \]
    7. Applied rewrites90.1%

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

Alternative 11: 95.3% accurate, 3.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\pi \cdot uy\right) \cdot 2\\
\mathbf{if}\;uy \leq 9.600000339560211 \cdot 10^{-5}:\\
\;\;\;\;xi + \mathsf{fma}\left(2, uy \cdot \left(yi \cdot \pi\right), maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(yi, \frac{\sin t\_0}{xi}, \cos t\_0\right) \cdot xi\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 9.60000034e-5

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

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

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

        \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
      6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.60000034e-5 < 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.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
    5. Taylor expanded in xi around inf

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

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

        \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right) \cdot xi \]
    7. Applied rewrites90.1%

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

Alternative 12: 93.4% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\pi \cdot uy\right) \cdot 2\\ \mathbf{if}\;uy \leq 3.9999998989515007 \cdot 10^{-5}:\\ \;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, 2, xi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(yi, \frac{\sin t\_0}{xi}, \cos t\_0\right) \cdot xi\\ \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* (* PI uy) 2.0)))
   (if (<= uy 3.9999998989515007e-5)
     (fma (* maxCos ux) zi (fma (* (* yi PI) uy) 2.0 xi))
     (* (fma yi (/ (sin t_0) xi) (cos t_0)) xi))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = (((float) M_PI) * uy) * 2.0f;
	float tmp;
	if (uy <= 3.9999998989515007e-5f) {
		tmp = fmaf((maxCos * ux), zi, fmaf(((yi * ((float) M_PI)) * uy), 2.0f, xi));
	} else {
		tmp = fmaf(yi, (sinf(t_0) / xi), cosf(t_0)) * xi;
	}
	return tmp;
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(pi) * uy) * Float32(2.0))
	tmp = Float32(0.0)
	if (uy <= Float32(3.9999998989515007e-5))
		tmp = fma(Float32(maxCos * ux), zi, fma(Float32(Float32(yi * Float32(pi)) * uy), Float32(2.0), xi));
	else
		tmp = Float32(fma(yi, Float32(sin(t_0) / xi), cos(t_0)) * xi);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\pi \cdot uy\right) \cdot 2\\
\mathbf{if}\;uy \leq 3.9999998989515007 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, 2, xi\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(yi, \frac{\sin t\_0}{xi}, \cos t\_0\right) \cdot xi\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 3.9999999e-5

    1. Initial program 99.4%

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

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

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

        \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
      6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 3.9999999e-5 < uy

      1. Initial program 98.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 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(2 \cdot uy\right)\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
      5. Taylor expanded in xi around inf

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

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

          \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{xi}\right) \cdot xi \]
      7. Applied rewrites90.2%

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

    Alternative 13: 93.3% accurate, 3.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \pi \cdot \left(2 \cdot uy\right)\\ \mathbf{if}\;uy \leq 3.9999998989515007 \cdot 10^{-5}:\\ \;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, 2, xi\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 (* 2.0 uy))))
       (if (<= uy 3.9999998989515007e-5)
         (fma (* maxCos ux) zi (fma (* (* yi PI) uy) 2.0 xi))
         (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) * (2.0f * uy);
    	float tmp;
    	if (uy <= 3.9999998989515007e-5f) {
    		tmp = fmaf((maxCos * ux), zi, fmaf(((yi * ((float) M_PI)) * uy), 2.0f, xi));
    	} 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(Float32(2.0) * uy))
    	tmp = Float32(0.0)
    	if (uy <= Float32(3.9999998989515007e-5))
    		tmp = fma(Float32(maxCos * ux), zi, fma(Float32(Float32(yi * Float32(pi)) * uy), Float32(2.0), xi));
    	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(2 \cdot uy\right)\\
    \mathbf{if}\;uy \leq 3.9999998989515007 \cdot 10^{-5}:\\
    \;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, 2, xi\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 < 3.9999999e-5

      1. Initial program 99.4%

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

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

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

          \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
        6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 3.9999999e-5 < uy

        1. Initial program 98.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 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(2 \cdot uy\right)\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 14: 85.4% accurate, 3.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \leq 3.9999998989515007 \cdot 10^{-5}:\\ \;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, 2, xi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot yi\right)\\ \end{array} \end{array} \]
      (FPCore (xi yi zi ux uy maxCos)
       :precision binary32
       (if (<= uy 3.9999998989515007e-5)
         (fma (* maxCos ux) zi (fma (* (* yi PI) uy) 2.0 xi))
         (fma (cos (* PI (* 2.0 uy))) xi (* (* (* PI uy) 2.0) yi))))
      float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
      	float tmp;
      	if (uy <= 3.9999998989515007e-5f) {
      		tmp = fmaf((maxCos * ux), zi, fmaf(((yi * ((float) M_PI)) * uy), 2.0f, xi));
      	} else {
      		tmp = fmaf(cosf((((float) M_PI) * (2.0f * uy))), xi, (((((float) M_PI) * uy) * 2.0f) * yi));
      	}
      	return tmp;
      }
      
      function code(xi, yi, zi, ux, uy, maxCos)
      	tmp = Float32(0.0)
      	if (uy <= Float32(3.9999998989515007e-5))
      		tmp = fma(Float32(maxCos * ux), zi, fma(Float32(Float32(yi * Float32(pi)) * uy), Float32(2.0), xi));
      	else
      		tmp = fma(cos(Float32(Float32(pi) * Float32(Float32(2.0) * uy))), xi, Float32(Float32(Float32(Float32(pi) * uy) * Float32(2.0)) * yi));
      	end
      	return tmp
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;uy \leq 3.9999998989515007 \cdot 10^{-5}:\\
      \;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, 2, xi\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot yi\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if uy < 3.9999999e-5

        1. Initial program 99.4%

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

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

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

            \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
          6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 3.9999999e-5 < uy

          1. Initial program 98.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 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(2 \cdot uy\right)\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
          5. Taylor expanded in uy around 0

            \[\leadsto \mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
          6. Step-by-step derivation
            1. *-commutativeN/A

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

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

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

              \[\leadsto \mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) \]
            5. lift-PI.f3272.9

              \[\leadsto \mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot yi\right) \]
          7. Applied rewrites72.9%

            \[\leadsto \mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \left(\left(\pi \cdot uy\right) \cdot 2\right) \cdot yi\right) \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 15: 79.3% accurate, 5.0× speedup?

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

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

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

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

            \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
          6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 16: 77.0% accurate, 5.4× speedup?

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

            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 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.3%

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, xi\right) \]
              7. lift-PI.f3283.9

                \[\leadsto \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, 2, xi\right) \]
            7. Applied rewrites83.9%

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

            if 0.0179999992 < uy

            1. Initial program 97.5%

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

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

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

                \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
              6. lift--.f32N/A

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

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

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

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

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

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

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

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

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

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

          Alternative 17: 74.3% accurate, 8.1× speedup?

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, xi\right) \]
            7. lift-PI.f3274.3

              \[\leadsto \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, 2, xi\right) \]
          7. Applied rewrites74.3%

            \[\leadsto \mathsf{fma}\left(\left(yi \cdot \pi\right) \cdot uy, \color{blue}{2}, xi\right) \]
          8. Add Preprocessing

          Alternative 18: 50.2% accurate, 10.8× speedup?

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

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

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

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

              \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
            6. lift--.f32N/A

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

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

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

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

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

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

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

              Alternative 19: 45.9% accurate, 65.0× speedup?

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \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) \]
                6. lift--.f32N/A

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

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

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

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

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

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

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

                  \[\leadsto xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
                5. lift-PI.f3253.1

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

                \[\leadsto xi \cdot \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
              8. Taylor expanded in uy around 0

                \[\leadsto xi \]
              9. Step-by-step derivation
                1. cos-245.9

                  \[\leadsto xi \]
              10. Applied rewrites45.9%

                \[\leadsto xi \]
              11. Add Preprocessing

              Reproduce

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