UniformSampleCone 2

Percentage Accurate: 98.9% → 98.9%
Time: 23.0s
Alternatives: 28
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}

Sampling outcomes in binary32 precision:

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

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.9% accurate, 1.0× speedup?

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

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

    \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  2. Add Preprocessing
  3. Final simplification98.7%

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

Alternative 2: 98.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + yi \cdot \sin \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. lower-PI.f3298.6

      \[\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 + yi \cdot \sin \left(2 \cdot \left(uy \cdot \color{blue}{\pi}\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  5. Applied rewrites98.6%

    \[\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 + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  6. Final simplification98.6%

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

Alternative 3: 98.4% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 0.00949999969

    1. Initial program 99.2%

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

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

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

    if 0.00949999969 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 97.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.009499999694526196:\\ \;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \left(\pi \cdot yi\right), uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, uy \cdot \left(yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right), -2 \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\right), \mathsf{fma}\left(xi, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)}, maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot zi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \pi\right)\right), zi \cdot \left(ux \cdot maxCos\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.8% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.5% accurate, 1.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 0.0450000018

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0450000018 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 96.8%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. lower-cos.f32N/A

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

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

        \[\leadsto \mathsf{fma}\left(xi, \cos \left(2 \cdot \color{blue}{\left(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-PI.f32N/A

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.04500000178813934:\\ \;\;\;\;\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)}, \mathsf{fma}\left(uy, yi \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(uy \cdot uy\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \pi\right), xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right), \left(ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) \cdot zi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\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)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 94.3% accurate, 1.6× speedup?

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

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

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

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

    \[\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 + \color{blue}{uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, \left(\left(uy \cdot uy\right) \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  5. Step-by-step derivation
    1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(\mathsf{neg}\left(ux\right)\right)\right), 1\right)} \cdot \color{blue}{\left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + \frac{-4}{3} \cdot \left(\left(\left(uy \cdot uy\right) \cdot yi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)}\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  6. Applied rewrites93.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 + uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)} \cdot \color{blue}{\mathsf{fma}\left(\left(2 \cdot yi\right) \cdot \sqrt{\pi}, \sqrt{\pi}, \left(uy \cdot uy\right) \cdot \left(\left(yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot -1.3333333333333333\right)\right)}\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  7. Taylor expanded in maxCos around 0

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(maxCos, \left(ux \cdot zi\right) \cdot \left(1 - ux\right), \mathsf{fma}\left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), \sqrt{\mathsf{fma}\left(maxCos \cdot \left(-maxCos\right), \left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(1 - ux\right)\right), 1\right)}, \left(uy \cdot yi\right) \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(uy \cdot uy\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \pi\right)\right)\right)} \]
    4. Final simplification93.0%

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

    Alternative 7: 94.4% accurate, 1.6× speedup?

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

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

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

      \[\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 + \color{blue}{uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, \left(\left(uy \cdot uy\right) \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(\mathsf{neg}\left(ux\right)\right)\right), 1\right)} \cdot \color{blue}{\left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + \frac{-4}{3} \cdot \left(\left(\left(uy \cdot uy\right) \cdot yi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)}\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    6. Applied rewrites93.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 + uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)} \cdot \color{blue}{\mathsf{fma}\left(\left(2 \cdot yi\right) \cdot \sqrt{\pi}, \sqrt{\pi}, \left(uy \cdot uy\right) \cdot \left(\left(yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot -1.3333333333333333\right)\right)}\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    7. Taylor expanded in yi around 0

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)}, \mathsf{fma}\left(uy, yi \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(uy \cdot uy\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \pi\right), xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right), \left(maxCos \cdot ux\right) \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
    9. Final simplification93.3%

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

    Alternative 8: 93.9% accurate, 1.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := ux \cdot \left(1 - ux\right)\\ t_1 := yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\\ t_2 := 2 \cdot \left(\pi \cdot yi\right)\\ t_3 := \sqrt{\mathsf{fma}\left(-maxCos \cdot maxCos, t\_0 \cdot t\_0, 1\right)}\\ \mathbf{if}\;uy \cdot 2 \leq 0.009499999694526196:\\ \;\;\;\;\mathsf{fma}\left(maxCos, \left(1 - ux\right) \cdot \left(ux \cdot zi\right), \mathsf{fma}\left(uy, \mathsf{fma}\left(uy, \mathsf{fma}\left(-2 \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), t\_3, t\_1 \cdot \left(uy \cdot -1.3333333333333333\right)\right), t\_2\right), xi \cdot t\_3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), uy \cdot \mathsf{fma}\left(-1.3333333333333333, t\_1 \cdot \left(uy \cdot uy\right), t\_2\right)\right)\right)\\ \end{array} \end{array} \]
    (FPCore (xi yi zi ux uy maxCos)
     :precision binary32
     (let* ((t_0 (* ux (- 1.0 ux)))
            (t_1 (* yi (* PI (* PI PI))))
            (t_2 (* 2.0 (* PI yi)))
            (t_3 (sqrt (fma (- (* maxCos maxCos)) (* t_0 t_0) 1.0))))
       (if (<= (* uy 2.0) 0.009499999694526196)
         (fma
          maxCos
          (* (- 1.0 ux) (* ux zi))
          (fma
           uy
           (fma
            uy
            (fma (* -2.0 (* xi (* PI PI))) t_3 (* t_1 (* uy -1.3333333333333333)))
            t_2)
           (* xi t_3)))
         (fma
          maxCos
          (* ux zi)
          (fma
           xi
           (cos (* 2.0 (* uy PI)))
           (* uy (fma -1.3333333333333333 (* t_1 (* uy uy)) t_2)))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	float t_0 = ux * (1.0f - ux);
    	float t_1 = yi * (((float) M_PI) * (((float) M_PI) * ((float) M_PI)));
    	float t_2 = 2.0f * (((float) M_PI) * yi);
    	float t_3 = sqrtf(fmaf(-(maxCos * maxCos), (t_0 * t_0), 1.0f));
    	float tmp;
    	if ((uy * 2.0f) <= 0.009499999694526196f) {
    		tmp = fmaf(maxCos, ((1.0f - ux) * (ux * zi)), fmaf(uy, fmaf(uy, fmaf((-2.0f * (xi * (((float) M_PI) * ((float) M_PI)))), t_3, (t_1 * (uy * -1.3333333333333333f))), t_2), (xi * t_3)));
    	} else {
    		tmp = fmaf(maxCos, (ux * zi), fmaf(xi, cosf((2.0f * (uy * ((float) M_PI)))), (uy * fmaf(-1.3333333333333333f, (t_1 * (uy * uy)), t_2))));
    	}
    	return tmp;
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	t_0 = Float32(ux * Float32(Float32(1.0) - ux))
    	t_1 = Float32(yi * Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi))))
    	t_2 = Float32(Float32(2.0) * Float32(Float32(pi) * yi))
    	t_3 = sqrt(fma(Float32(-Float32(maxCos * maxCos)), Float32(t_0 * t_0), Float32(1.0)))
    	tmp = Float32(0.0)
    	if (Float32(uy * Float32(2.0)) <= Float32(0.009499999694526196))
    		tmp = fma(maxCos, Float32(Float32(Float32(1.0) - ux) * Float32(ux * zi)), fma(uy, fma(uy, fma(Float32(Float32(-2.0) * Float32(xi * Float32(Float32(pi) * Float32(pi)))), t_3, Float32(t_1 * Float32(uy * Float32(-1.3333333333333333)))), t_2), Float32(xi * t_3)));
    	else
    		tmp = fma(maxCos, Float32(ux * zi), fma(xi, cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))), Float32(uy * fma(Float32(-1.3333333333333333), Float32(t_1 * Float32(uy * uy)), t_2))));
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := ux \cdot \left(1 - ux\right)\\
    t_1 := yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\\
    t_2 := 2 \cdot \left(\pi \cdot yi\right)\\
    t_3 := \sqrt{\mathsf{fma}\left(-maxCos \cdot maxCos, t\_0 \cdot t\_0, 1\right)}\\
    \mathbf{if}\;uy \cdot 2 \leq 0.009499999694526196:\\
    \;\;\;\;\mathsf{fma}\left(maxCos, \left(1 - ux\right) \cdot \left(ux \cdot zi\right), \mathsf{fma}\left(uy, \mathsf{fma}\left(uy, \mathsf{fma}\left(-2 \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), t\_3, t\_1 \cdot \left(uy \cdot -1.3333333333333333\right)\right), t\_2\right), xi \cdot t\_3\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), uy \cdot \mathsf{fma}\left(-1.3333333333333333, t\_1 \cdot \left(uy \cdot uy\right), t\_2\right)\right)\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f32 uy #s(literal 2 binary32)) < 0.00949999969

      1. Initial program 99.2%

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

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

        \[\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 + \color{blue}{uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, \left(\left(uy \cdot uy\right) \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      5. Step-by-step derivation
        1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 0.00949999969 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 97.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), uy \cdot \color{blue}{\mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right), 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right) \]
        7. Applied rewrites72.5%

          \[\leadsto \color{blue}{\mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot \left(uy \cdot uy\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)\right)} \]
      9. Recombined 2 regimes into one program.
      10. Final simplification92.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.009499999694526196:\\ \;\;\;\;\mathsf{fma}\left(maxCos, \left(1 - ux\right) \cdot \left(ux \cdot zi\right), \mathsf{fma}\left(uy, \mathsf{fma}\left(uy, \mathsf{fma}\left(-2 \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), \sqrt{\mathsf{fma}\left(-maxCos \cdot maxCos, \left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(1 - ux\right)\right), 1\right)}, \left(yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot \left(uy \cdot -1.3333333333333333\right)\right), 2 \cdot \left(\pi \cdot yi\right)\right), xi \cdot \sqrt{\mathsf{fma}\left(-maxCos \cdot maxCos, \left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(1 - ux\right)\right), 1\right)}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot \left(uy \cdot uy\right), 2 \cdot \left(\pi \cdot yi\right)\right)\right)\right)\\ \end{array} \]
      11. Add Preprocessing

      Alternative 9: 93.4% accurate, 1.9× speedup?

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

        1. Initial program 99.2%

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

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

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

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

        if 2.39999994e-4 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), uy \cdot \color{blue}{\mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right), 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right) \]
        7. Applied rewrites82.5%

          \[\leadsto \color{blue}{\mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot \left(uy \cdot uy\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)\right)} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification92.5%

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.00023999999393709004:\\ \;\;\;\;\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot zi + \mathsf{fma}\left(uy, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(\pi \cdot yi\right)\right), xi \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(yi \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot \left(uy \cdot uy\right), 2 \cdot \left(\pi \cdot yi\right)\right)\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 10: 91.4% accurate, 2.0× speedup?

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

        1. Initial program 99.2%

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

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

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

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

        if 2.39999994e-4 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(uy, \frac{-4}{3} \cdot \left({uy}^{2} \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right), xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
        9. Applied rewrites79.9%

          \[\leadsto \color{blue}{\mathsf{fma}\left(uy, \mathsf{fma}\left(-1.3333333333333333, \left(\left(uy \cdot uy\right) \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(yi \cdot \pi\right)\right), xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification91.5%

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.00023999999393709004:\\ \;\;\;\;\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot zi + \mathsf{fma}\left(uy, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(\pi \cdot yi\right)\right), xi \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(-1.3333333333333333, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(yi \cdot \left(uy \cdot uy\right)\right), 2 \cdot \left(\pi \cdot yi\right)\right), xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 11: 88.4% accurate, 2.2× speedup?

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

        1. Initial program 99.1%

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

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

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

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

        if 0.200000003 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 95.3%

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)} \]
        5. Applied rewrites56.0%

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), yi \cdot \sin \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
          9. lower-PI.f3256.0

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.20000000298023224:\\ \;\;\;\;\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot zi + \mathsf{fma}\left(uy, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(\pi \cdot yi\right)\right), xi \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot \left(\left(1 - ux\right) \cdot zi\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 12: 88.4% accurate, 2.2× speedup?

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

        1. Initial program 99.1%

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

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

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

        if 0.200000003 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 95.3%

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)} \]
        5. Applied rewrites56.0%

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), yi \cdot \sin \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
          9. lower-PI.f3256.0

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.20000000298023224:\\ \;\;\;\;\mathsf{fma}\left(xi, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)}, \mathsf{fma}\left(uy, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(\pi \cdot yi\right)\right), maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot zi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot \left(\left(1 - ux\right) \cdot zi\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 13: 88.4% accurate, 2.2× speedup?

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

        1. Initial program 99.1%

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

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

          \[\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 + \color{blue}{uy \cdot \left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, \left(\left(uy \cdot uy\right) \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
        5. Step-by-step derivation
          1. lift-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 0.200000003 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 95.3%

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)} \]
        5. Applied rewrites56.0%

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), yi \cdot \sin \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
          9. lower-PI.f3256.0

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.20000000298023224:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot \left(\left(1 - ux\right) \cdot zi\right), \mathsf{fma}\left(uy, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \left(\pi \cdot yi\right)\right), xi \cdot \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot \left(\left(1 - ux\right) \cdot zi\right), yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 14: 85.5% accurate, 2.4× speedup?

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

        1. Initial program 99.2%

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

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

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

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

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

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

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

        if 0.0285999998 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 96.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. Add Preprocessing
        3. Taylor expanded in yi around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(maxCos, \left(ux \cdot zi\right) \cdot \left(1 - ux\right), xi \cdot \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
          10. lower-PI.f3256.4

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(maxCos, \left(ux \cdot zi\right) \cdot \left(1 - ux\right), xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification85.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.028599999845027924:\\ \;\;\;\;\mathsf{fma}\left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right), zi, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, 2 \cdot \left(\pi \cdot yi\right), xi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(maxCos, \left(1 - ux\right) \cdot \left(ux \cdot zi\right), xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 15: 85.1% accurate, 2.6× speedup?

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

        1. Initial program 99.2%

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

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

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

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

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

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

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

        if 0.0285999998 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 96.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. Add Preprocessing
        3. Taylor expanded in yi around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.028599999845027924:\\ \;\;\;\;\mathsf{fma}\left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right), zi, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, 2 \cdot \left(\pi \cdot yi\right), xi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), maxCos \cdot \left(ux \cdot zi\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 16: 84.4% accurate, 2.8× speedup?

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

        1. Initial program 99.2%

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

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

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

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

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

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

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

        if 0.0285999998 < (*.f32 uy #s(literal 2 binary32))

        1. Initial program 96.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. Add Preprocessing
        3. Taylor expanded in yi around 0

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

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

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

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

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

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

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

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

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

            \[\leadsto xi \cdot \cos \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \]
          5. lower-PI.f3250.7

            \[\leadsto xi \cdot \cos \left(2 \cdot \left(uy \cdot \color{blue}{\pi}\right)\right) \]
        8. Applied rewrites50.7%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.028599999845027924:\\ \;\;\;\;\mathsf{fma}\left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right), zi, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, 2 \cdot \left(\pi \cdot yi\right), xi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 17: 82.2% accurate, 4.3× speedup?

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(maxCos \cdot \left(\left(1 - ux\right) \cdot ux\right), zi, \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, 2 \cdot \left(\pi \cdot yi\right), xi\right)\right)} \]
      7. Final simplification80.4%

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

      Alternative 18: 82.2% accurate, 4.3× speedup?

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(-ux\right)\right), 1\right)}, \mathsf{fma}\left(2, uy \cdot \left(yi \cdot \pi\right), xi\right), maxCos \cdot \left(\left(ux \cdot zi\right) \cdot \left(1 - ux\right)\right)\right)} \]
      6. Final simplification80.3%

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

      Alternative 19: 82.1% accurate, 4.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{xi + \mathsf{fma}\left(ux, \mathsf{fma}\left(ux, \mathsf{fma}\left(\mathsf{fma}\left(2 \cdot uy, yi \cdot \pi, xi\right), \left(maxCos \cdot maxCos\right) \cdot \left(ux + -0.5\right), -maxCos \cdot zi\right), maxCos \cdot zi\right), \left(2 \cdot uy\right) \cdot \left(yi \cdot \pi\right)\right)} \]
      9. Final simplification80.2%

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

      Alternative 20: 82.1% accurate, 5.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 21: 82.1% accurate, 9.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 22: 82.1% accurate, 9.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 23: 79.3% accurate, 11.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(2 \cdot uy, yi \cdot \mathsf{PI}\left(\right), xi\right) + \color{blue}{maxCos \cdot \left(ux \cdot zi\right)} \]
        10. lower-*.f3276.0

          \[\leadsto \mathsf{fma}\left(2 \cdot uy, yi \cdot \pi, xi\right) + maxCos \cdot \color{blue}{\left(ux \cdot zi\right)} \]
      8. Applied rewrites76.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2 \cdot uy, yi \cdot \pi, xi\right) + maxCos \cdot \left(ux \cdot zi\right)} \]
      9. Final simplification76.0%

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

      Alternative 24: 74.3% accurate, 20.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(2 \cdot uy, \color{blue}{yi \cdot \mathsf{PI}\left(\right)}, xi\right) \]
        6. lower-PI.f3270.0

          \[\leadsto \mathsf{fma}\left(2 \cdot uy, yi \cdot \color{blue}{\pi}, xi\right) \]
      8. Applied rewrites70.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2 \cdot uy, yi \cdot \pi, xi\right)} \]
      9. Final simplification70.0%

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

      Alternative 25: 31.9% accurate, 22.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(2 \cdot uy\right) \cdot \color{blue}{\left(yi \cdot \mathsf{PI}\left(\right)\right)} \]
        5. lower-PI.f3230.6

          \[\leadsto \left(2 \cdot uy\right) \cdot \left(yi \cdot \color{blue}{\pi}\right) \]
      11. Applied rewrites30.6%

        \[\leadsto \color{blue}{\left(2 \cdot uy\right) \cdot \left(yi \cdot \pi\right)} \]
      12. Final simplification30.6%

        \[\leadsto \left(uy \cdot 2\right) \cdot \left(\pi \cdot yi\right) \]
      13. Add Preprocessing

      Alternative 26: 12.3% accurate, 32.1× speedup?

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

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

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

          \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
        2. associate-*r*N/A

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

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

          \[\leadsto maxCos \cdot \left(\color{blue}{\left(ux \cdot zi\right)} \cdot \left(1 - ux\right)\right) \]
        5. lower--.f3214.7

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

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

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

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

          \[\leadsto maxCos \cdot \color{blue}{\left(ux \cdot zi\right)} \]
      8. Applied rewrites12.6%

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

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

          \[\leadsto \color{blue}{\left(maxCos \cdot ux\right) \cdot zi} \]
        3. *-commutativeN/A

          \[\leadsto \color{blue}{\left(ux \cdot maxCos\right)} \cdot zi \]
        4. lower-*.f3212.6

          \[\leadsto \color{blue}{\left(ux \cdot maxCos\right)} \cdot zi \]
      10. Applied rewrites12.6%

        \[\leadsto \color{blue}{\left(ux \cdot maxCos\right) \cdot zi} \]
      11. Final simplification12.6%

        \[\leadsto zi \cdot \left(ux \cdot maxCos\right) \]
      12. Add Preprocessing

      Alternative 27: 12.3% accurate, 32.1× speedup?

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

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

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

          \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
        2. associate-*r*N/A

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

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

          \[\leadsto maxCos \cdot \left(\color{blue}{\left(ux \cdot zi\right)} \cdot \left(1 - ux\right)\right) \]
        5. lower--.f3214.7

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

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

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

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

          \[\leadsto maxCos \cdot \color{blue}{\left(ux \cdot zi\right)} \]
      8. Applied rewrites12.6%

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

          \[\leadsto maxCos \cdot \color{blue}{\left(zi \cdot ux\right)} \]
        2. associate-*r*N/A

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

          \[\leadsto \color{blue}{\left(maxCos \cdot zi\right) \cdot ux} \]
        4. lower-*.f3212.6

          \[\leadsto \color{blue}{\left(maxCos \cdot zi\right)} \cdot ux \]
      10. Applied rewrites12.6%

        \[\leadsto \color{blue}{\left(maxCos \cdot zi\right) \cdot ux} \]
      11. Final simplification12.6%

        \[\leadsto ux \cdot \left(maxCos \cdot zi\right) \]
      12. Add Preprocessing

      Alternative 28: 12.3% accurate, 32.1× 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);
      }
      
      real(4) function code(xi, yi, zi, ux, uy, maxcos)
          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.7%

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

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

          \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
        2. associate-*r*N/A

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

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

          \[\leadsto maxCos \cdot \left(\color{blue}{\left(ux \cdot zi\right)} \cdot \left(1 - ux\right)\right) \]
        5. lower--.f3214.7

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

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

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

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

          \[\leadsto maxCos \cdot \color{blue}{\left(ux \cdot zi\right)} \]
      8. Applied rewrites12.6%

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

      Reproduce

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