UniformSampleCone 2

Percentage Accurate: 98.9% → 99.0%
Time: 9.3s
Alternatives: 15
Speedup: 1.0×

Specification

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

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 alternatives:

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \pi \cdot \left(uy + uy\right)\\
t_2 := \sqrt{1 - t\_0 \cdot t\_0}\\
\mathsf{fma}\left(\cos t\_1 \cdot t\_2, xi, \mathsf{fma}\left(\sin t\_1, t\_2 \cdot yi, t\_0 \cdot zi\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 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(uy + uy\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}, xi, \mathsf{fma}\left(\sin \left(\pi \cdot \left(uy + uy\right)\right), \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot yi, \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\right)\right)} \]
  3. Add Preprocessing

Alternative 2: 98.8% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \pi \cdot \left(uy + 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 (+ uy 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) * (uy + 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(uy + 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(uy + 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(uy + uy\right)\right), xi, \sin \left(\pi \cdot \left(uy + uy\right)\right) \cdot yi\right)\right)} \]
  5. Add Preprocessing

Alternative 3: 97.4% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 0.023

    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. Applied rewrites99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 0.023 < uy

        1. Initial program 97.7%

          \[\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(uy + uy\right)\right), xi, \sin \left(\pi \cdot \left(uy + uy\right)\right) \cdot yi\right)} \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 4: 97.2% accurate, 1.7× speedup?

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

        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. Applied rewrites99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if 0.023 < uy

            1. Initial program 97.7%

              \[\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(uy + uy\right)\right), xi, \sin \left(\pi \cdot \left(uy + uy\right)\right) \cdot yi\right)} \]
          4. Recombined 2 regimes into one program.
          5. Add Preprocessing

          Alternative 5: 95.9% accurate, 1.7× speedup?

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

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

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

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

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

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

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

          Alternative 6: 92.9% accurate, 1.9× speedup?

          \[\begin{array}{l} \\ \mathsf{fma}\left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot 1, xi, \mathsf{fma}\left(\sin \left(\pi \cdot \left(uy + uy\right)\right), 1 \cdot yi, \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\right)\right) \end{array} \]
          (FPCore (xi yi zi ux uy maxCos)
           :precision binary32
           (fma
            (* (+ 1.0 (* -2.0 (* (* uy uy) (* PI PI)))) 1.0)
            xi
            (fma (sin (* PI (+ uy uy))) (* 1.0 yi) (* (* (* (- 1.0 ux) maxCos) ux) zi))))
          float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
          	return fmaf(((1.0f + (-2.0f * ((uy * uy) * (((float) M_PI) * ((float) M_PI))))) * 1.0f), xi, fmaf(sinf((((float) M_PI) * (uy + uy))), (1.0f * yi), ((((1.0f - ux) * maxCos) * ux) * zi)));
          }
          
          function code(xi, yi, zi, ux, uy, maxCos)
          	return fma(Float32(Float32(Float32(1.0) + Float32(Float32(-2.0) * Float32(Float32(uy * uy) * Float32(Float32(pi) * Float32(pi))))) * Float32(1.0)), xi, fma(sin(Float32(Float32(pi) * Float32(uy + uy))), Float32(Float32(1.0) * yi), Float32(Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * ux) * zi)))
          end
          
          \begin{array}{l}
          
          \\
          \mathsf{fma}\left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot 1, xi, \mathsf{fma}\left(\sin \left(\pi \cdot \left(uy + uy\right)\right), 1 \cdot yi, \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\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. Applied rewrites99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 7: 91.8% accurate, 2.0× speedup?

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

                1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

                    if 2.09999998e-17 < yi

                    1. Initial program 98.7%

                      \[\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.7%

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

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

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

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

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

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

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

                        Alternative 8: 88.5% accurate, 2.4× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(uy \cdot \pi\right)\\ t_1 := \left(1 + \frac{yi \cdot \sin t\_0}{xi}\right) \cdot xi\\ \mathbf{if}\;yi \leq -1.999999936531045 \cdot 10^{-20}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;yi \leq 1.000000031374395 \cdot 10^{-22}:\\ \;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \cos t\_0 \cdot xi\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                        (FPCore (xi yi zi ux uy maxCos)
                         :precision binary32
                         (let* ((t_0 (* 2.0 (* uy PI))) (t_1 (* (+ 1.0 (/ (* yi (sin t_0)) xi)) xi)))
                           (if (<= yi -1.999999936531045e-20)
                             t_1
                             (if (<= yi 1.000000031374395e-22)
                               (fma (* maxCos ux) (* (- 1.0 ux) zi) (* (cos t_0) xi))
                               t_1))))
                        float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                        	float t_0 = 2.0f * (uy * ((float) M_PI));
                        	float t_1 = (1.0f + ((yi * sinf(t_0)) / xi)) * xi;
                        	float tmp;
                        	if (yi <= -1.999999936531045e-20f) {
                        		tmp = t_1;
                        	} else if (yi <= 1.000000031374395e-22f) {
                        		tmp = fmaf((maxCos * ux), ((1.0f - ux) * zi), (cosf(t_0) * xi));
                        	} else {
                        		tmp = t_1;
                        	}
                        	return tmp;
                        }
                        
                        function code(xi, yi, zi, ux, uy, maxCos)
                        	t_0 = Float32(Float32(2.0) * Float32(uy * Float32(pi)))
                        	t_1 = Float32(Float32(Float32(1.0) + Float32(Float32(yi * sin(t_0)) / xi)) * xi)
                        	tmp = Float32(0.0)
                        	if (yi <= Float32(-1.999999936531045e-20))
                        		tmp = t_1;
                        	elseif (yi <= Float32(1.000000031374395e-22))
                        		tmp = fma(Float32(maxCos * ux), Float32(Float32(Float32(1.0) - ux) * zi), Float32(cos(t_0) * xi));
                        	else
                        		tmp = t_1;
                        	end
                        	return tmp
                        end
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
                        t_1 := \left(1 + \frac{yi \cdot \sin t\_0}{xi}\right) \cdot xi\\
                        \mathbf{if}\;yi \leq -1.999999936531045 \cdot 10^{-20}:\\
                        \;\;\;\;t\_1\\
                        
                        \mathbf{elif}\;yi \leq 1.000000031374395 \cdot 10^{-22}:\\
                        \;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \cos t\_0 \cdot xi\right)\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;t\_1\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if yi < -1.99999994e-20 or 1.00000003e-22 < yi

                          1. Initial program 98.8%

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

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

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

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

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

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

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

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

                            \[\leadsto \left(1 + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi}\right) \cdot xi \]
                          8. Step-by-step derivation
                            1. Applied rewrites85.9%

                              \[\leadsto \left(1 + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi}\right) \cdot xi \]

                            if -1.99999994e-20 < yi < 1.00000003e-22

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

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

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

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

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

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

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

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

                              \[\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\right) \]
                            6. Step-by-step derivation
                              1. lower-cos.f32N/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\right) \]
                              2. lower-*.f32N/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\right) \]
                              3. lower-*.f32N/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\right) \]
                              4. lift-PI.f3286.3

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

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

                          Alternative 9: 86.1% accurate, 2.3× speedup?

                          \[\begin{array}{l} \\ \mathsf{fma}\left(1 \cdot 1, xi, \mathsf{fma}\left(\sin \left(\pi \cdot \left(uy + uy\right)\right), 1 \cdot yi, \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\right)\right) \end{array} \]
                          (FPCore (xi yi zi ux uy maxCos)
                           :precision binary32
                           (fma
                            (* 1.0 1.0)
                            xi
                            (fma (sin (* PI (+ uy uy))) (* 1.0 yi) (* (* (* (- 1.0 ux) maxCos) ux) zi))))
                          float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                          	return fmaf((1.0f * 1.0f), xi, fmaf(sinf((((float) M_PI) * (uy + uy))), (1.0f * yi), ((((1.0f - ux) * maxCos) * ux) * zi)));
                          }
                          
                          function code(xi, yi, zi, ux, uy, maxCos)
                          	return fma(Float32(Float32(1.0) * Float32(1.0)), xi, fma(sin(Float32(Float32(pi) * Float32(uy + uy))), Float32(Float32(1.0) * yi), Float32(Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * ux) * zi)))
                          end
                          
                          \begin{array}{l}
                          
                          \\
                          \mathsf{fma}\left(1 \cdot 1, xi, \mathsf{fma}\left(\sin \left(\pi \cdot \left(uy + uy\right)\right), 1 \cdot yi, \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\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. Applied rewrites99.0%

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

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

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

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

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

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

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

                                Alternative 10: 84.5% accurate, 2.3× speedup?

                                \[\begin{array}{l} \\ \left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \pi\right)\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi}\right) \cdot xi \end{array} \]
                                (FPCore (xi yi zi ux uy maxCos)
                                 :precision binary32
                                 (*
                                  (+
                                   (+ 1.0 (* -2.0 (* (* uy uy) (* PI PI))))
                                   (/ (* yi (sin (* 2.0 (* uy PI)))) xi))
                                  xi))
                                float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                	return ((1.0f + (-2.0f * ((uy * uy) * (((float) M_PI) * ((float) M_PI))))) + ((yi * sinf((2.0f * (uy * ((float) M_PI))))) / xi)) * xi;
                                }
                                
                                function code(xi, yi, zi, ux, uy, maxCos)
                                	return Float32(Float32(Float32(Float32(1.0) + Float32(Float32(-2.0) * Float32(Float32(uy * uy) * Float32(Float32(pi) * Float32(pi))))) + Float32(Float32(yi * sin(Float32(Float32(2.0) * Float32(uy * Float32(pi))))) / xi)) * xi)
                                end
                                
                                function tmp = code(xi, yi, zi, ux, uy, maxCos)
                                	tmp = ((single(1.0) + (single(-2.0) * ((uy * uy) * (single(pi) * single(pi))))) + ((yi * sin((single(2.0) * (uy * single(pi))))) / xi)) * xi;
                                end
                                
                                \begin{array}{l}
                                
                                \\
                                \left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \pi\right)\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi}\right) \cdot 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 xi around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi}\right) \cdot xi \]
                                  9. lift-PI.f3284.5

                                    \[\leadsto \left(\left(1 + -2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(\pi \cdot \pi\right)\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{xi}\right) \cdot xi \]
                                9. Applied rewrites84.5%

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

                                Alternative 11: 80.5% accurate, 3.1× speedup?

                                \[\begin{array}{l} \\ \left(1 + uy \cdot \mathsf{fma}\left(2, \frac{yi \cdot \pi}{xi}, uy \cdot \mathsf{fma}\left(-2, \pi \cdot \pi, -1.3333333333333333 \cdot \frac{uy \cdot \left(yi \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)\right)}{xi}\right)\right)\right) \cdot xi \end{array} \]
                                (FPCore (xi yi zi ux uy maxCos)
                                 :precision binary32
                                 (*
                                  (+
                                   1.0
                                   (*
                                    uy
                                    (fma
                                     2.0
                                     (/ (* yi PI) xi)
                                     (*
                                      uy
                                      (fma
                                       -2.0
                                       (* PI PI)
                                       (* -1.3333333333333333 (/ (* uy (* yi (* (* PI PI) PI))) xi)))))))
                                  xi))
                                float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                	return (1.0f + (uy * fmaf(2.0f, ((yi * ((float) M_PI)) / xi), (uy * fmaf(-2.0f, (((float) M_PI) * ((float) M_PI)), (-1.3333333333333333f * ((uy * (yi * ((((float) M_PI) * ((float) M_PI)) * ((float) M_PI)))) / xi))))))) * xi;
                                }
                                
                                function code(xi, yi, zi, ux, uy, maxCos)
                                	return Float32(Float32(Float32(1.0) + Float32(uy * fma(Float32(2.0), Float32(Float32(yi * Float32(pi)) / xi), Float32(uy * fma(Float32(-2.0), Float32(Float32(pi) * Float32(pi)), Float32(Float32(-1.3333333333333333) * Float32(Float32(uy * Float32(yi * Float32(Float32(Float32(pi) * Float32(pi)) * Float32(pi)))) / xi))))))) * xi)
                                end
                                
                                \begin{array}{l}
                                
                                \\
                                \left(1 + uy \cdot \mathsf{fma}\left(2, \frac{yi \cdot \pi}{xi}, uy \cdot \mathsf{fma}\left(-2, \pi \cdot \pi, -1.3333333333333333 \cdot \frac{uy \cdot \left(yi \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)\right)}{xi}\right)\right)\right) \cdot 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 xi around inf

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(1 + uy \cdot \mathsf{fma}\left(2, \frac{yi \cdot \mathsf{PI}\left(\right)}{xi}, uy \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{-4}{3} \cdot \frac{uy \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)}{xi}\right)\right)\right) \cdot xi \]
                                  6. lift-PI.f32N/A

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

                                    \[\leadsto \left(1 + uy \cdot \mathsf{fma}\left(2, \frac{yi \cdot \pi}{xi}, uy \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{-4}{3} \cdot \frac{uy \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)}{xi}\right)\right)\right) \cdot xi \]
                                9. Applied rewrites80.5%

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

                                Alternative 12: 77.2% accurate, 5.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(1 + uy \cdot \mathsf{fma}\left(-2, uy \cdot \left(\pi \cdot \pi\right), 2 \cdot \frac{yi \cdot \mathsf{PI}\left(\right)}{xi}\right)\right) \cdot xi \]
                                  12. lift-PI.f3277.2

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

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

                                Alternative 13: 73.9% accurate, 8.1× speedup?

                                \[\begin{array}{l} \\ \left(1 + 2 \cdot \frac{uy \cdot \left(yi \cdot \pi\right)}{xi}\right) \cdot xi \end{array} \]
                                (FPCore (xi yi zi ux uy maxCos)
                                 :precision binary32
                                 (* (+ 1.0 (* 2.0 (/ (* uy (* yi PI)) xi))) xi))
                                float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                	return (1.0f + (2.0f * ((uy * (yi * ((float) M_PI))) / xi))) * xi;
                                }
                                
                                function code(xi, yi, zi, ux, uy, maxCos)
                                	return Float32(Float32(Float32(1.0) + Float32(Float32(2.0) * Float32(Float32(uy * Float32(yi * Float32(pi))) / xi))) * xi)
                                end
                                
                                function tmp = code(xi, yi, zi, ux, uy, maxCos)
                                	tmp = (single(1.0) + (single(2.0) * ((uy * (yi * single(pi))) / xi))) * xi;
                                end
                                
                                \begin{array}{l}
                                
                                \\
                                \left(1 + 2 \cdot \frac{uy \cdot \left(yi \cdot \pi\right)}{xi}\right) \cdot 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 xi around inf

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(1 + 2 \cdot \frac{uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)}{xi}\right) \cdot xi \]
                                  6. lift-PI.f3273.9

                                    \[\leadsto \left(1 + 2 \cdot \frac{uy \cdot \left(yi \cdot \pi\right)}{xi}\right) \cdot xi \]
                                9. Applied rewrites73.9%

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

                                Alternative 14: 51.5% accurate, 8.9× speedup?

                                \[\begin{array}{l} \\ \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, 1 \cdot xi\right) \end{array} \]
                                (FPCore (xi yi zi ux uy maxCos)
                                 :precision binary32
                                 (fma (* maxCos ux) (* (- 1.0 ux) zi) (* 1.0 xi)))
                                float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
                                	return fmaf((maxCos * ux), ((1.0f - ux) * zi), (1.0f * xi));
                                }
                                
                                function code(xi, yi, zi, ux, uy, maxCos)
                                	return fma(Float32(maxCos * ux), Float32(Float32(Float32(1.0) - ux) * zi), Float32(Float32(1.0) * xi))
                                end
                                
                                \begin{array}{l}
                                
                                \\
                                \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, 1 \cdot 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 yi around 0

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

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

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

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

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

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

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

                                  \[\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\right) \]
                                6. Step-by-step derivation
                                  1. lower-cos.f32N/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\right) \]
                                  2. lower-*.f32N/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\right) \]
                                  3. lower-*.f32N/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\right) \]
                                  4. lift-PI.f3259.2

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

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

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

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

                                  Alternative 15: 45.3% accurate, 39.1× speedup?

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

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

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

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

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

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

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

                                    \[\leadsto 1 \cdot xi \]
                                  8. Step-by-step derivation
                                    1. Applied rewrites45.3%

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

                                    Reproduce

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