UniformSampleCone 2

Percentage Accurate: 98.9% → 99.0%
Time: 11.8s
Alternatives: 25
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 25 alternatives:

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) \cdot maxCos\\
t_1 := t\_0 \cdot ux\\
t_2 := \sqrt{1 - t\_1 \cdot t\_1}\\
t_3 := \left(uy \cdot 2\right) \cdot \pi\\
\left(\left(\cos t\_3 \cdot t\_2\right) \cdot xi + \left(\sin t\_3 \cdot t\_2\right) \cdot yi\right) + t\_0 \cdot \left(zi \cdot ux\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. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. Add Preprocessing

Alternative 2: 98.8% accurate, 1.5× speedup?

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

\\
\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \mathsf{fma}\left(xi, \sin \left(\mathsf{fma}\left(uy + uy, -\pi, \frac{\pi}{2}\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\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. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Step-by-step derivation
    1. lift-cos.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 \pi\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\right) \]
    2. lift-*.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 \pi\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\right) \]
    3. lift-PI.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 \pi\right)\right)\right)\right) \]
    4. lift-*.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 \pi\right)\right)\right)\right) \]
    5. cos-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.7% accurate, 1.6× speedup?

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

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

    \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  2. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Applied rewrites98.7%

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

Alternative 4: 98.7% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 95.9% accurate, 1.6× speedup?

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

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

    \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  2. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Step-by-step derivation
    1. lift-cos.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 \pi\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\right) \]
    2. lift-*.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 \pi\right)\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\right) \]
    3. lift-PI.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 \pi\right)\right)\right)\right) \]
    4. lift-*.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 \pi\right)\right)\right)\right) \]
    5. cos-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\left(xi \cdot \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right) - 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)} \]
  10. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

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

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

Alternative 6: 95.9% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, zi, \cos \left(\pi \cdot \left(uy + uy\right)\right) \cdot xi + \sin \left(\pi \cdot \left(uy + uy\right)\right) \cdot yi\right) \]
    13. lift-*.f3295.9

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

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

Alternative 7: 95.9% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 8: 94.2% accurate, 1.9× speedup?

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

\\
\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 \left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right), -1.3333333333333333, \pi + \pi\right) \cdot uy\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. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Taylor expanded in uy around 0

    \[\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 \pi\right)\right), yi \cdot \left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
  8. Step-by-step derivation
    1. *-commutativeN/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 \pi\right)\right), yi \cdot \left(\left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)\right)\right) \]
    2. lower-*.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 \pi\right)\right), yi \cdot \left(\left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)\right)\right) \]
  9. Applied rewrites94.2%

    \[\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 \pi\right)\right), yi \cdot \left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right), -1.3333333333333333, \pi + \pi\right) \cdot uy\right)\right)\right) \]
  10. Add Preprocessing

Alternative 9: 92.8% accurate, 2.1× speedup?

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

\\
\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \mathsf{fma}\left(xi, \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 1\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\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. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 89.4% accurate, 2.8× speedup?

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

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

    \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  2. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Taylor expanded in uy around 0

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

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

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

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

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

Alternative 11: 86.8% accurate, 2.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
  7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

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

Alternative 12: 86.6% accurate, 3.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
  7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto xi + \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot yi\right) \cdot uy, -1.3333333333333333, \left(\left(\pi \cdot \pi\right) \cdot xi\right) \cdot -2\right), uy, yi \cdot \left(\pi + \pi\right)\right), uy, \left(zi \cdot ux\right) \cdot maxCos\right) \]
  12. Applied rewrites86.8%

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

Alternative 13: 85.9% accurate, 3.9× speedup?

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

\\
xi + \mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, \mathsf{fma}\left(-2 \cdot uy, \left(\pi \cdot \pi\right) \cdot xi, yi \cdot \left(\pi + \pi\right)\right) \cdot uy\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. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Applied rewrites98.7%

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

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

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

Alternative 14: 85.9% accurate, 4.0× speedup?

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

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

    \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  2. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Taylor expanded in uy around 0

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

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

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

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

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

Alternative 15: 83.4% accurate, 4.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
  7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 83.4% accurate, 4.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 83.4% accurate, 4.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
  7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 82.8% accurate, 4.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
  7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

      \[\leadsto xi + \mathsf{fma}\left(\mathsf{fma}\left(yi \cdot \pi, 2, \left(\left(\left(\pi \cdot \pi\right) \cdot xi\right) \cdot uy\right) \cdot -2\right), uy, \left(zi \cdot ux\right) \cdot maxCos\right) \]
    3. associate-*l*N/A

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

      \[\leadsto xi + \mathsf{fma}\left(\mathsf{fma}\left(yi \cdot \pi, 2, \left(\left(\pi \cdot \pi\right) \cdot \left(xi \cdot uy\right)\right) \cdot -2\right), uy, \left(zi \cdot ux\right) \cdot maxCos\right) \]
    5. lower-*.f3283.4

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

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

Alternative 19: 81.7% accurate, 6.2× speedup?

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

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

    \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  2. Step-by-step derivation
    1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
    2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
    3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
    4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
    7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
    8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
    9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
  3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
  4. 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)} \]
  5. 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) \]
  6. 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)} \]
  7. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

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

Alternative 20: 79.2% accurate, 7.8× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(zi \cdot ux, maxCos, \left(uy + uy\right) \cdot \left(yi \cdot \pi\right)\right) + xi \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (+ (fma (* zi ux) maxCos (* (+ uy uy) (* yi PI))) xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	return fmaf((zi * ux), maxCos, ((uy + uy) * (yi * ((float) M_PI)))) + xi;
}
function code(xi, yi, zi, ux, uy, maxCos)
	return Float32(fma(Float32(zi * ux), maxCos, Float32(Float32(uy + uy) * Float32(yi * Float32(pi)))) + xi)
end
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
  7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 21: 61.4% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(uy + uy, yi \cdot \pi, \left(zi \cdot ux\right) \cdot maxCos\right)\\ \mathbf{if}\;yi \leq -5.000000058430487 \cdot 10^{-8}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;yi \leq 4.999999980020986 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (fma (+ uy uy) (* yi PI) (* (* zi ux) maxCos))))
   (if (<= yi -5.000000058430487e-8)
     t_0
     (if (<= yi 4.999999980020986e-13)
       (fma (* (* zi (- 1.0 ux)) ux) maxCos xi)
       t_0))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = fmaf((uy + uy), (yi * ((float) M_PI)), ((zi * ux) * maxCos));
	float tmp;
	if (yi <= -5.000000058430487e-8f) {
		tmp = t_0;
	} else if (yi <= 4.999999980020986e-13f) {
		tmp = fmaf(((zi * (1.0f - ux)) * ux), maxCos, xi);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = fma(Float32(uy + uy), Float32(yi * Float32(pi)), Float32(Float32(zi * ux) * maxCos))
	tmp = Float32(0.0)
	if (yi <= Float32(-5.000000058430487e-8))
		tmp = t_0;
	elseif (yi <= Float32(4.999999980020986e-13))
		tmp = fma(Float32(Float32(zi * Float32(Float32(1.0) - ux)) * ux), maxCos, xi);
	else
		tmp = t_0;
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(uy + uy, yi \cdot \pi, \left(zi \cdot ux\right) \cdot maxCos\right)\\
\mathbf{if}\;yi \leq -5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;yi \leq 4.999999980020986 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if yi < -5.00000006e-8 or 4.99999998e-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 ux around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
    7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot uy\right) \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + maxCos \cdot \left(ux \cdot zi\right) \]
      2. count-2-revN/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(uy + uy, yi \cdot \pi, \left(zi \cdot ux\right) \cdot maxCos\right) \]
      10. lift-*.f3236.0

        \[\leadsto \mathsf{fma}\left(uy + uy, yi \cdot \pi, \left(zi \cdot ux\right) \cdot maxCos\right) \]
    13. Applied rewrites36.0%

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

    if -5.00000006e-8 < yi < 4.99999998e-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. Step-by-step derivation
      1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
      2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
      3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
      4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
      6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
      7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
      8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
      9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
      10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
    4. 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)} \]
    5. 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) \]
    6. 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)} \]
    7. Taylor expanded in uy around 0

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

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

        \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot maxCos + xi \]
      3. lower-fma.f32N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right) \]
      7. lift-*.f3251.6

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

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

Alternative 22: 61.1% accurate, 7.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(uy + uy\right) \cdot \left(yi \cdot \pi\right)\\ \mathbf{if}\;yi \leq -5.000000058430487 \cdot 10^{-8}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;yi \leq 4.999999980020986 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* (+ uy uy) (* yi PI))))
   (if (<= yi -5.000000058430487e-8)
     t_0
     (if (<= yi 4.999999980020986e-13)
       (fma (* (* zi (- 1.0 ux)) ux) maxCos xi)
       t_0))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = (uy + uy) * (yi * ((float) M_PI));
	float tmp;
	if (yi <= -5.000000058430487e-8f) {
		tmp = t_0;
	} else if (yi <= 4.999999980020986e-13f) {
		tmp = fmaf(((zi * (1.0f - ux)) * ux), maxCos, xi);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(uy + uy) * Float32(yi * Float32(pi)))
	tmp = Float32(0.0)
	if (yi <= Float32(-5.000000058430487e-8))
		tmp = t_0;
	elseif (yi <= Float32(4.999999980020986e-13))
		tmp = fma(Float32(Float32(zi * Float32(Float32(1.0) - ux)) * ux), maxCos, xi);
	else
		tmp = t_0;
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(uy + uy\right) \cdot \left(yi \cdot \pi\right)\\
\mathbf{if}\;yi \leq -5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;yi \leq 4.999999980020986 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if yi < -5.00000006e-8 or 4.99999998e-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 ux around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
    7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot uy\right) \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) \]
      2. count-2-revN/A

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

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

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

        \[\leadsto \left(uy + uy\right) \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) \]
      6. lift-PI.f3232.4

        \[\leadsto \left(uy + uy\right) \cdot \left(yi \cdot \pi\right) \]
    13. Applied rewrites32.4%

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

    if -5.00000006e-8 < yi < 4.99999998e-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. Step-by-step derivation
      1. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi} \]
      2. lift-*.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) + \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)} \cdot zi \]
      3. lift-*.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) + \left(\color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot ux\right) \cdot zi \]
      4. lift--.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) + \left(\left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      5. associate-*l*N/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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
      6. 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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(ux \cdot zi\right)} \]
      7. lift--.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) + \left(\color{blue}{\left(1 - ux\right)} \cdot maxCos\right) \cdot \left(ux \cdot zi\right) \]
      8. lift-*.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) + \color{blue}{\left(\left(1 - ux\right) \cdot maxCos\right)} \cdot \left(ux \cdot zi\right) \]
      9. *-commutativeN/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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
      10. lower-*.f3299.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) + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \color{blue}{\left(zi \cdot ux\right)} \]
    3. Applied rewrites99.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}{\left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(zi \cdot ux\right)} \]
    4. 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)} \]
    5. 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) \]
    6. 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)} \]
    7. Taylor expanded in uy around 0

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

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

        \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot maxCos + xi \]
      3. lower-fma.f32N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right) \]
      7. lift-*.f3251.6

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

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

Alternative 23: 59.2% accurate, 9.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(uy + uy\right) \cdot \left(yi \cdot \pi\right)\\ \mathbf{if}\;yi \leq -5.000000058430487 \cdot 10^{-8}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;yi \leq 4.999999980020986 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(zi \cdot ux, maxCos, xi\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* (+ uy uy) (* yi PI))))
   (if (<= yi -5.000000058430487e-8)
     t_0
     (if (<= yi 4.999999980020986e-13) (fma (* zi ux) maxCos xi) t_0))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = (uy + uy) * (yi * ((float) M_PI));
	float tmp;
	if (yi <= -5.000000058430487e-8f) {
		tmp = t_0;
	} else if (yi <= 4.999999980020986e-13f) {
		tmp = fmaf((zi * ux), maxCos, xi);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(uy + uy) * Float32(yi * Float32(pi)))
	tmp = Float32(0.0)
	if (yi <= Float32(-5.000000058430487e-8))
		tmp = t_0;
	elseif (yi <= Float32(4.999999980020986e-13))
		tmp = fma(Float32(zi * ux), maxCos, xi);
	else
		tmp = t_0;
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(uy + uy\right) \cdot \left(yi \cdot \pi\right)\\
\mathbf{if}\;yi \leq -5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;yi \leq 4.999999980020986 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(zi \cdot ux, maxCos, xi\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if yi < -5.00000006e-8 or 4.99999998e-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 ux around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
    7. Applied rewrites11.8%

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot uy\right) \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) \]
      2. count-2-revN/A

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

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

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

        \[\leadsto \left(uy + uy\right) \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) \]
      6. lift-PI.f3232.4

        \[\leadsto \left(uy + uy\right) \cdot \left(yi \cdot \pi\right) \]
    13. Applied rewrites32.4%

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

    if -5.00000006e-8 < yi < 4.99999998e-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 ux around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
    7. Applied rewrites11.8%

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

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

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + xi \]
      2. *-commutativeN/A

        \[\leadsto \left(ux \cdot zi\right) \cdot maxCos + xi \]
      3. lower-fma.f32N/A

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

        \[\leadsto \mathsf{fma}\left(zi \cdot ux, maxCos, xi\right) \]
      5. lower-*.f3249.6

        \[\leadsto \mathsf{fma}\left(zi \cdot ux, maxCos, xi\right) \]
    10. Applied rewrites49.6%

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

Alternative 24: 49.6% accurate, 17.3× speedup?

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

\\
\mathsf{fma}\left(zi \cdot ux, maxCos, xi\right)
\end{array}
Derivation
  1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
  7. Applied rewrites11.8%

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + xi \]
    2. *-commutativeN/A

      \[\leadsto \left(ux \cdot zi\right) \cdot maxCos + xi \]
    3. lower-fma.f32N/A

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

      \[\leadsto \mathsf{fma}\left(zi \cdot ux, maxCos, xi\right) \]
    5. lower-*.f3249.6

      \[\leadsto \mathsf{fma}\left(zi \cdot ux, maxCos, xi\right) \]
  10. Applied rewrites49.6%

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

Alternative 25: 11.8% 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 ux around 0

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

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

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

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

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

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

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
  7. Applied rewrites11.8%

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

Reproduce

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