UniformSampleCone 2

Percentage Accurate: 98.9% → 98.9%
Time: 5.9s
Alternatives: 17
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 17 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: 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) + ux \cdot \mathsf{fma}\left(-1, maxCos \cdot \left(ux \cdot zi\right), maxCos \cdot zi\right) \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))
    (* ux (fma -1.0 (* maxCos (* ux zi)) (* maxCos 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)) + (ux * fmaf(-1.0f, (maxCos * (ux * zi)), (maxCos * 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(ux * fma(Float32(-1.0), Float32(maxCos * Float32(ux * zi)), Float32(maxCos * 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) + ux \cdot \mathsf{fma}\left(-1, maxCos \cdot \left(ux \cdot zi\right), maxCos \cdot zi\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 \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) + \color{blue}{ux \cdot \left(-1 \cdot \left(maxCos \cdot \left(ux \cdot zi\right)\right) + maxCos \cdot zi\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

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

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

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

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

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

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

Alternative 2: 98.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\\ 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 (* maxCos (* ux (- 1.0 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 = maxCos * (ux * (1.0f - 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(maxCos * Float32(ux * Float32(Float32(1.0) - 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 = maxCos * (ux * (single(1.0) - 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 := maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\\
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}
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 \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\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 \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot \left(ux \cdot \color{blue}{\left(1 - ux\right)}\right)\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 \]
    3. lift--.f3298.9

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

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right) \cdot \left(maxCos \cdot \left(ux \cdot \color{blue}{\left(1 - ux\right)}\right)\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. lift--.f3298.9

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

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right) \cdot \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot \left(ux \cdot \color{blue}{\left(1 - ux\right)}\right)\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. lift--.f3298.9

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

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right) \cdot \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right) \cdot \left(maxCos \cdot \left(ux \cdot \color{blue}{\left(1 - ux\right)}\right)\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. lift--.f3298.9

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

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right) \cdot \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right) \cdot \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right)}\right) \cdot yi\right) + \left(maxCos \cdot \left(ux \cdot \color{blue}{\left(1 - ux\right)}\right)\right) \cdot zi \]
    3. lift--.f3298.9

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

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

Alternative 3: 98.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
\left(\cos t\_0 \cdot xi + \sin t\_0 \cdot yi\right) + ux \cdot \mathsf{fma}\left(-1, maxCos \cdot \left(ux \cdot zi\right), maxCos \cdot zi\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 \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) + \color{blue}{ux \cdot \left(-1 \cdot \left(maxCos \cdot \left(ux \cdot zi\right)\right) + maxCos \cdot zi\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 4: 98.7% accurate, 1.6× speedup?

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

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

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

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

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

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

      Alternative 5: 95.6% accurate, 1.7× speedup?

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

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

          \[\leadsto \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(\color{blue}{\left(uy \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right)} \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
        3. Step-by-step derivation
          1. lower-*.f32N/A

            \[\leadsto \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(\left(uy \cdot \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right) + {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          2. lower-fma.f32N/A

            \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \color{blue}{\mathsf{PI}\left(\right)}, {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          3. lift-PI.f32N/A

            \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          4. lower-*.f32N/A

            \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          5. lower-pow.f32N/A

            \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          6. lower-fma.f32N/A

            \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-4}{3}, {\mathsf{PI}\left(\right)}^{3}, {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
        4. Applied rewrites96.5%

          \[\leadsto \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(\color{blue}{\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \mathsf{fma}\left(-1.3333333333333333, {\pi}^{3}, {uy}^{2} \cdot \mathsf{fma}\left(-0.025396825396825397, {uy}^{2} \cdot {\pi}^{7}, 0.26666666666666666 \cdot {\pi}^{5}\right)\right)\right)\right)} \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
        5. Taylor expanded in ux around 0

          \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{1}\right) \cdot xi + \left(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-4}{3}, {\pi}^{3}, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-8}{315}, {uy}^{2} \cdot {\pi}^{7}, \frac{4}{15} \cdot {\pi}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
        6. Step-by-step derivation
          1. Applied rewrites96.3%

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

            \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot 1\right) \cdot xi + \left(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-4}{3}, {\pi}^{3}, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-8}{315}, {uy}^{2} \cdot {\pi}^{7}, \frac{4}{15} \cdot {\pi}^{5}\right)\right)\right)\right) \cdot \color{blue}{1}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          3. Step-by-step derivation
            1. Applied rewrites96.2%

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

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

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

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

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

            if 1.10000001e-4 < uy

            1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 6: 95.4% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

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

          Alternative 7: 89.9% accurate, 2.1× speedup?

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

            \[\leadsto \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(\color{blue}{\left(uy \cdot \left(2 \cdot \mathsf{PI}\left(\right) + {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right)} \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          3. Step-by-step derivation
            1. lower-*.f32N/A

              \[\leadsto \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(\left(uy \cdot \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right) + {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
            2. lower-fma.f32N/A

              \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \color{blue}{\mathsf{PI}\left(\right)}, {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
            3. lift-PI.f32N/A

              \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
            4. lower-*.f32N/A

              \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
            5. lower-pow.f32N/A

              \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \left(\frac{-4}{3} \cdot {\mathsf{PI}\left(\right)}^{3} + {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
            6. lower-fma.f32N/A

              \[\leadsto \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(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-4}{3}, {\mathsf{PI}\left(\right)}^{3}, {uy}^{2} \cdot \left(\frac{-8}{315} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{7}\right) + \frac{4}{15} \cdot {\mathsf{PI}\left(\right)}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          4. Applied rewrites96.5%

            \[\leadsto \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(\color{blue}{\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \mathsf{fma}\left(-1.3333333333333333, {\pi}^{3}, {uy}^{2} \cdot \mathsf{fma}\left(-0.025396825396825397, {uy}^{2} \cdot {\pi}^{7}, 0.26666666666666666 \cdot {\pi}^{5}\right)\right)\right)\right)} \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          5. Taylor expanded in ux around 0

            \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{1}\right) \cdot xi + \left(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-4}{3}, {\pi}^{3}, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-8}{315}, {uy}^{2} \cdot {\pi}^{7}, \frac{4}{15} \cdot {\pi}^{5}\right)\right)\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
          6. Step-by-step derivation
            1. Applied rewrites96.3%

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

              \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot 1\right) \cdot xi + \left(\left(uy \cdot \mathsf{fma}\left(2, \pi, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-4}{3}, {\pi}^{3}, {uy}^{2} \cdot \mathsf{fma}\left(\frac{-8}{315}, {uy}^{2} \cdot {\pi}^{7}, \frac{4}{15} \cdot {\pi}^{5}\right)\right)\right)\right) \cdot \color{blue}{1}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
            3. Step-by-step derivation
              1. Applied rewrites96.2%

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

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

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

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

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

              Alternative 8: 74.4% accurate, 2.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(uy \cdot \pi\right)\\ t_1 := ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\\ t_2 := \mathsf{fma}\left(maxCos, t\_1, xi \cdot \cos t\_0\right)\\ \mathbf{if}\;xi \leq -5.999999809593135 \cdot 10^{-21}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;xi \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, t\_1, yi \cdot \sin t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
              (FPCore (xi yi zi ux uy maxCos)
               :precision binary32
               (let* ((t_0 (* 2.0 (* uy PI)))
                      (t_1 (* ux (* zi (- 1.0 ux))))
                      (t_2 (fma maxCos t_1 (* xi (cos t_0)))))
                 (if (<= xi -5.999999809593135e-21)
                   t_2
                   (if (<= xi 1.999999967550318e-17)
                     (fma maxCos t_1 (* yi (sin t_0)))
                     t_2))))
              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 = ux * (zi * (1.0f - ux));
              	float t_2 = fmaf(maxCos, t_1, (xi * cosf(t_0)));
              	float tmp;
              	if (xi <= -5.999999809593135e-21f) {
              		tmp = t_2;
              	} else if (xi <= 1.999999967550318e-17f) {
              		tmp = fmaf(maxCos, t_1, (yi * sinf(t_0)));
              	} else {
              		tmp = t_2;
              	}
              	return tmp;
              }
              
              function code(xi, yi, zi, ux, uy, maxCos)
              	t_0 = Float32(Float32(2.0) * Float32(uy * Float32(pi)))
              	t_1 = Float32(ux * Float32(zi * Float32(Float32(1.0) - ux)))
              	t_2 = fma(maxCos, t_1, Float32(xi * cos(t_0)))
              	tmp = Float32(0.0)
              	if (xi <= Float32(-5.999999809593135e-21))
              		tmp = t_2;
              	elseif (xi <= Float32(1.999999967550318e-17))
              		tmp = fma(maxCos, t_1, Float32(yi * sin(t_0)));
              	else
              		tmp = t_2;
              	end
              	return tmp
              end
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
              t_1 := ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\\
              t_2 := \mathsf{fma}\left(maxCos, t\_1, xi \cdot \cos t\_0\right)\\
              \mathbf{if}\;xi \leq -5.999999809593135 \cdot 10^{-21}:\\
              \;\;\;\;t\_2\\
              
              \mathbf{elif}\;xi \leq 1.999999967550318 \cdot 10^{-17}:\\
              \;\;\;\;\mathsf{fma}\left(maxCos, t\_1, yi \cdot \sin t\_0\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_2\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if xi < -5.9999998e-21 or 1.99999997e-17 < xi

                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) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
                3. Step-by-step derivation
                  1. lower-fma.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -5.9999998e-21 < xi < 1.99999997e-17

                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 0

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) \]
                4. Applied rewrites44.8%

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \]
                  9. lift-*.f3244.7

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

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

              Alternative 9: 73.8% accurate, 2.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(uy \cdot \pi\right)\\ t_1 := \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \cos t\_0\right)\\ \mathbf{if}\;xi \leq -5.999999809593135 \cdot 10^{-21}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;xi \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), yi \cdot \sin t\_0\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 (fma maxCos (* ux zi) (* xi (cos t_0)))))
                 (if (<= xi -5.999999809593135e-21)
                   t_1
                   (if (<= xi 1.999999967550318e-17)
                     (fma maxCos (* ux (* zi (- 1.0 ux))) (* yi (sin t_0)))
                     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 = fmaf(maxCos, (ux * zi), (xi * cosf(t_0)));
              	float tmp;
              	if (xi <= -5.999999809593135e-21f) {
              		tmp = t_1;
              	} else if (xi <= 1.999999967550318e-17f) {
              		tmp = fmaf(maxCos, (ux * (zi * (1.0f - ux))), (yi * sinf(t_0)));
              	} 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 = fma(maxCos, Float32(ux * zi), Float32(xi * cos(t_0)))
              	tmp = Float32(0.0)
              	if (xi <= Float32(-5.999999809593135e-21))
              		tmp = t_1;
              	elseif (xi <= Float32(1.999999967550318e-17))
              		tmp = fma(maxCos, Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))), Float32(yi * sin(t_0)));
              	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 := \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \cos t\_0\right)\\
              \mathbf{if}\;xi \leq -5.999999809593135 \cdot 10^{-21}:\\
              \;\;\;\;t\_1\\
              
              \mathbf{elif}\;xi \leq 1.999999967550318 \cdot 10^{-17}:\\
              \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), yi \cdot \sin t\_0\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if xi < -5.9999998e-21 or 1.99999997e-17 < xi

                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) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
                3. Step-by-step derivation
                  1. lower-fma.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \]
                  7. lift-*.f3256.9

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

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

                if -5.9999998e-21 < xi < 1.99999997e-17

                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 0

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) \]
                4. Applied rewrites44.8%

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \]
                  9. lift-*.f3244.7

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

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

              Alternative 10: 72.0% accurate, 2.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(uy \cdot \pi\right)\\ t_1 := \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \cos t\_0\right)\\ \mathbf{if}\;xi \leq -5.999999809593135 \cdot 10^{-21}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;xi \leq 1.999999967550318 \cdot 10^{-17}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin t\_0\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 (fma maxCos (* ux zi) (* xi (cos t_0)))))
                 (if (<= xi -5.999999809593135e-21)
                   t_1
                   (if (<= xi 1.999999967550318e-17)
                     (fma maxCos (* ux zi) (* yi (sin t_0)))
                     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 = fmaf(maxCos, (ux * zi), (xi * cosf(t_0)));
              	float tmp;
              	if (xi <= -5.999999809593135e-21f) {
              		tmp = t_1;
              	} else if (xi <= 1.999999967550318e-17f) {
              		tmp = fmaf(maxCos, (ux * zi), (yi * sinf(t_0)));
              	} 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 = fma(maxCos, Float32(ux * zi), Float32(xi * cos(t_0)))
              	tmp = Float32(0.0)
              	if (xi <= Float32(-5.999999809593135e-21))
              		tmp = t_1;
              	elseif (xi <= Float32(1.999999967550318e-17))
              		tmp = fma(maxCos, Float32(ux * zi), Float32(yi * sin(t_0)));
              	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 := \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \cos t\_0\right)\\
              \mathbf{if}\;xi \leq -5.999999809593135 \cdot 10^{-21}:\\
              \;\;\;\;t\_1\\
              
              \mathbf{elif}\;xi \leq 1.999999967550318 \cdot 10^{-17}:\\
              \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin t\_0\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if xi < -5.9999998e-21 or 1.99999997e-17 < xi

                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) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
                3. Step-by-step derivation
                  1. lower-fma.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \]
                  7. lift-*.f3256.9

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

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

                if -5.9999998e-21 < xi < 1.99999997e-17

                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 0

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) \]
                4. Applied rewrites44.8%

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \]
                  7. lift-*.f3242.6

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

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

              Alternative 11: 64.5% accurate, 2.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\\ \mathbf{if}\;yi \leq -4.999999987376214 \cdot 10^{-7}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;yi \leq 1.99999996490334 \cdot 10^{-13}:\\ \;\;\;\;xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left({maxCos}^{2} \cdot \mathsf{fma}\left(-1, \frac{zi}{maxCos}, -0.5 \cdot xi\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
              (FPCore (xi yi zi ux uy maxCos)
               :precision binary32
               (let* ((t_0 (fma maxCos (* ux zi) (* yi (sin (* 2.0 (* uy PI)))))))
                 (if (<= yi -4.999999987376214e-7)
                   t_0
                   (if (<= yi 1.99999996490334e-13)
                     (+
                      xi
                      (*
                       ux
                       (fma
                        maxCos
                        zi
                        (* ux (* (pow maxCos 2.0) (fma -1.0 (/ zi maxCos) (* -0.5 xi)))))))
                     t_0))))
              float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
              	float t_0 = fmaf(maxCos, (ux * zi), (yi * sinf((2.0f * (uy * ((float) M_PI))))));
              	float tmp;
              	if (yi <= -4.999999987376214e-7f) {
              		tmp = t_0;
              	} else if (yi <= 1.99999996490334e-13f) {
              		tmp = xi + (ux * fmaf(maxCos, zi, (ux * (powf(maxCos, 2.0f) * fmaf(-1.0f, (zi / maxCos), (-0.5f * xi))))));
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              function code(xi, yi, zi, ux, uy, maxCos)
              	t_0 = fma(maxCos, Float32(ux * zi), Float32(yi * sin(Float32(Float32(2.0) * Float32(uy * Float32(pi))))))
              	tmp = Float32(0.0)
              	if (yi <= Float32(-4.999999987376214e-7))
              		tmp = t_0;
              	elseif (yi <= Float32(1.99999996490334e-13))
              		tmp = Float32(xi + Float32(ux * fma(maxCos, zi, Float32(ux * Float32((maxCos ^ Float32(2.0)) * fma(Float32(-1.0), Float32(zi / maxCos), Float32(Float32(-0.5) * xi)))))));
              	else
              		tmp = t_0;
              	end
              	return tmp
              end
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\\
              \mathbf{if}\;yi \leq -4.999999987376214 \cdot 10^{-7}:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;yi \leq 1.99999996490334 \cdot 10^{-13}:\\
              \;\;\;\;xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left({maxCos}^{2} \cdot \mathsf{fma}\left(-1, \frac{zi}{maxCos}, -0.5 \cdot xi\right)\right)\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_0\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if yi < -4.99999999e-7 or 1.99999996e-13 < yi

                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 0

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}\right) \]
                4. Applied rewrites44.8%

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \]
                  7. lift-*.f3242.6

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

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

                if -4.99999999e-7 < yi < 1.99999996e-13

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
                  9. lift-pow.f3251.8

                    \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
                7. Applied rewrites51.8%

                  \[\leadsto xi + \color{blue}{ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right)} \]
                8. Taylor expanded in maxCos around inf

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

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

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

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

                    \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left({maxCos}^{2} \cdot \mathsf{fma}\left(-1, \frac{zi}{maxCos}, \frac{-1}{2} \cdot xi\right)\right)\right) \]
                  5. lower-*.f3251.4

                    \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left({maxCos}^{2} \cdot \mathsf{fma}\left(-1, \frac{zi}{maxCos}, -0.5 \cdot xi\right)\right)\right) \]
                10. Applied rewrites51.4%

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left({maxCos}^{2} \cdot \mathsf{fma}\left(-1, \frac{zi}{maxCos}, -0.5 \cdot xi\right)\right)\right) \]
              3. Recombined 2 regimes into one program.
              4. Add Preprocessing

              Alternative 12: 51.8% accurate, 3.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
                9. lift-pow.f3251.8

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
              7. Applied rewrites51.8%

                \[\leadsto xi + \color{blue}{ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right)} \]
              8. Taylor expanded in maxCos around inf

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

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

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

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

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left({maxCos}^{2} \cdot \mathsf{fma}\left(-1, \frac{zi}{maxCos}, \frac{-1}{2} \cdot xi\right)\right)\right) \]
                5. lower-*.f3251.4

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left({maxCos}^{2} \cdot \mathsf{fma}\left(-1, \frac{zi}{maxCos}, -0.5 \cdot xi\right)\right)\right) \]
              10. Applied rewrites51.4%

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

              Alternative 13: 51.7% accurate, 3.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
                9. lift-pow.f3251.8

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
              7. Applied rewrites51.8%

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

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

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

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

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

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

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

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

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(\frac{-1}{2}, {maxCos}^{2} \cdot \left(ux \cdot xi\right), zi \cdot \left(maxCos + -1 \cdot \left(maxCos \cdot ux\right)\right)\right) \]
                8. lower-*.f3251.7

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(-0.5, {maxCos}^{2} \cdot \left(ux \cdot xi\right), zi \cdot \left(maxCos + -1 \cdot \left(maxCos \cdot ux\right)\right)\right) \]
              10. Applied rewrites51.7%

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

              Alternative 14: 51.7% accurate, 5.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
                9. lift-pow.f3251.8

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
              7. Applied rewrites51.8%

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

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

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

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

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left(maxCos \cdot \mathsf{fma}\left(-1, zi, \frac{-1}{2} \cdot \left(maxCos \cdot xi\right)\right)\right)\right) \]
                4. lower-*.f3251.8

                  \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left(maxCos \cdot \mathsf{fma}\left(-1, zi, -0.5 \cdot \left(maxCos \cdot xi\right)\right)\right)\right) \]
              10. Applied rewrites51.8%

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

              Alternative 15: 51.4% accurate, 10.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
                4. lift-*.f32N/A

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - \color{blue}{ux}\right)\right)\right) \]
                5. lift-*.f3251.7

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \color{blue}{\left(1 - ux\right)}\right)\right) \]
              7. Applied rewrites51.7%

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

              Alternative 16: 49.5% accurate, 16.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
                3. lift-*.f3249.5

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
              7. Applied rewrites49.5%

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

              Alternative 17: 12.4% accurate, 22.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
                3. lift-*.f3249.5

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
              7. Applied rewrites49.5%

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

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

                  \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
                2. lift-*.f3212.4

                  \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
              10. Applied rewrites12.4%

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

              Reproduce

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