UniformSampleCone 2

Percentage Accurate: 98.9% → 98.7%
Time: 21.8s
Alternatives: 17
Speedup: N/A×

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

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.7% 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(ux \cdot zi\right) \cdot \left(1 - ux\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 (* (* ux zi) (- 1.0 ux)))))))
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 * ((ux * zi) * (1.0f - ux)))));
}
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(ux * zi) * Float32(Float32(1.0) - ux)))))
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(ux \cdot zi\right) \cdot \left(1 - ux\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 98.9%

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

    \[\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. Add Preprocessing

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

\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
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.013000000268220901:\\
\;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, t\_1 \cdot \left(yi \cdot \pi\right), uy \cdot \left(t\_1 \cdot \mathsf{fma}\left(-1.3333333333333333, \left(uy \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\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(ux \cdot zi\right) \cdot \left(1 - ux\right)\right)\right)\right)\\

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


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

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

      \[\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 ux\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 ux\right), 1\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, \left(uy \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\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 ux\right), 1\right)}, maxCos \cdot \left(\left(ux \cdot zi\right) \cdot \left(1 - ux\right)\right)\right)\right)} \]

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

    1. Initial program 97.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.013000000268220901:\\ \;\;\;\;\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(yi \cdot \pi\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, \left(uy \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\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(ux \cdot zi\right) \cdot \left(1 - ux\right)\right)\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 3: 95.8% accurate, 1.5× speedup?

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \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)\right) \]
    5. associate-*r*N/A

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

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

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

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

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

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

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

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

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

Alternative 4: 95.9% accurate, 1.5× 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(ux \cdot zi\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 (* 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 * (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(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(ux \cdot zi\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 98.9%

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

      \[\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 \color{blue}{\left(ux \cdot zi\right)}\right)\right) \]
  5. Applied rewrites96.4%

    \[\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(ux \cdot zi\right)\right)\right)} \]
  6. Add Preprocessing

Alternative 5: 93.0% accurate, 2.2× speedup?

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

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

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

    \[\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. Step-by-step derivation
    1. Applied rewrites99.0%

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

      \[\leadsto \mathsf{fma}\left(\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), yi, \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), xi \cdot \left(1 + -2 \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right) \]
    3. Step-by-step derivation
      1. Applied rewrites93.9%

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

      Alternative 6: 93.0% accurate, 2.2× speedup?

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

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

        \[\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. Taylor expanded in uy around 0

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

          \[\leadsto \mathsf{fma}\left(xi, \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \color{blue}{\pi \cdot \pi}, 1\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) \]
        2. Add Preprocessing

        Alternative 7: 91.8% accurate, 2.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.10199999809265137:\\ \;\;\;\;xi + \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), xi \cdot \left(\pi \cdot \pi\right), \mathsf{fma}\left(uy \cdot yi, \mathsf{fma}\left(-1.3333333333333333, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot uy\right), 2 \cdot \pi\right), \left(zi \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(xi, 1, \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)\\ \end{array} \end{array} \]
        (FPCore (xi yi zi ux uy maxCos)
         :precision binary32
         (if (<= (* uy 2.0) 0.10199999809265137)
           (+
            xi
            (fma
             (* -2.0 (* uy uy))
             (* xi (* PI PI))
             (fma
              (* uy yi)
              (fma -1.3333333333333333 (* (* PI (* PI PI)) (* uy uy)) (* 2.0 PI))
              (* (* zi (- 1.0 ux)) (* ux maxCos)))))
           (fma
            xi
            1.0
            (fma yi (sin (* 2.0 (* uy PI))) (* maxCos (* (* ux zi) (- 1.0 ux)))))))
        float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
        	float tmp;
        	if ((uy * 2.0f) <= 0.10199999809265137f) {
        		tmp = xi + fmaf((-2.0f * (uy * uy)), (xi * (((float) M_PI) * ((float) M_PI))), fmaf((uy * yi), fmaf(-1.3333333333333333f, ((((float) M_PI) * (((float) M_PI) * ((float) M_PI))) * (uy * uy)), (2.0f * ((float) M_PI))), ((zi * (1.0f - ux)) * (ux * maxCos))));
        	} else {
        		tmp = fmaf(xi, 1.0f, fmaf(yi, sinf((2.0f * (uy * ((float) M_PI)))), (maxCos * ((ux * zi) * (1.0f - ux)))));
        	}
        	return tmp;
        }
        
        function code(xi, yi, zi, ux, uy, maxCos)
        	tmp = Float32(0.0)
        	if (Float32(uy * Float32(2.0)) <= Float32(0.10199999809265137))
        		tmp = Float32(xi + fma(Float32(Float32(-2.0) * Float32(uy * uy)), Float32(xi * Float32(Float32(pi) * Float32(pi))), fma(Float32(uy * yi), fma(Float32(-1.3333333333333333), Float32(Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi))) * Float32(uy * uy)), Float32(Float32(2.0) * Float32(pi))), Float32(Float32(zi * Float32(Float32(1.0) - ux)) * Float32(ux * maxCos)))));
        	else
        		tmp = fma(xi, Float32(1.0), fma(yi, sin(Float32(Float32(2.0) * Float32(uy * Float32(pi)))), Float32(maxCos * Float32(Float32(ux * zi) * Float32(Float32(1.0) - ux)))));
        	end
        	return tmp
        end
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;uy \cdot 2 \leq 0.10199999809265137:\\
        \;\;\;\;xi + \mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), xi \cdot \left(\pi \cdot \pi\right), \mathsf{fma}\left(uy \cdot yi, \mathsf{fma}\left(-1.3333333333333333, \left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot uy\right), 2 \cdot \pi\right), \left(zi \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(xi, 1, \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)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f32 uy #s(literal 2 binary32)) < 0.102

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

            \[\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. Step-by-step derivation
            1. Applied rewrites99.3%

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

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

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

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

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

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

                1. Initial program 97.0%

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

                  \[\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. Taylor expanded in uy around 0

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

                    \[\leadsto \mathsf{fma}\left(xi, 1, \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) \]
                8. Recombined 2 regimes into one program.
                9. Final simplification92.7%

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

                Alternative 8: 90.8% accurate, 2.8× speedup?

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

                    \[\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. Step-by-step derivation
                    1. Applied rewrites99.3%

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

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

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

                        \[\leadsto xi + \left(-2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) + \color{blue}{\left(maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + 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)}\right) \]
                      3. Step-by-step derivation
                        1. Applied rewrites96.2%

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

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

                        1. Initial program 96.6%

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

                          \[\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. Taylor expanded in yi around inf

                          \[\leadsto yi \cdot \color{blue}{\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                        7. Step-by-step derivation
                          1. Applied rewrites62.4%

                            \[\leadsto yi \cdot \color{blue}{\sin \left(\left(2 \cdot uy\right) \cdot \pi\right)} \]
                        8. Recombined 2 regimes into one program.
                        9. Final simplification92.3%

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

                        Alternative 9: 89.5% accurate, 4.3× speedup?

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

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

                          \[\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. Step-by-step derivation
                          1. Applied rewrites99.0%

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

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

                              \[\leadsto xi + \color{blue}{\mathsf{fma}\left(uy, \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(uy \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\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)} \]
                            2. Step-by-step derivation
                              1. Applied rewrites88.7%

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

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

                              Alternative 10: 86.8% accurate, 4.6× speedup?

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

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

                                \[\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. Step-by-step derivation
                                1. Applied rewrites99.0%

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

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

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

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

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

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

                                    Alternative 11: 85.8% accurate, 6.0× speedup?

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

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

                                      \[\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. Step-by-step derivation
                                      1. Applied rewrites99.0%

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

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

                                          \[\leadsto xi + \color{blue}{\mathsf{fma}\left(uy, \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(uy \cdot yi\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right)\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)} \]
                                        2. Taylor expanded in xi around inf

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

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

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

                                          Alternative 12: 85.8% accurate, 6.0× speedup?

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

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

                                            \[\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. Step-by-step derivation
                                            1. Applied rewrites99.0%

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

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

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

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

                                              Alternative 13: 85.8% accurate, 6.0× speedup?

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

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

                                                \[\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. Taylor expanded in uy around 0

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

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

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

                                                Alternative 14: 81.8% accurate, 9.3× speedup?

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

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

                                                  \[\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. Step-by-step derivation
                                                  1. Applied rewrites99.0%

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

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

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

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

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

                                                      Alternative 15: 81.8% accurate, 9.3× speedup?

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

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

                                                        \[\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. Taylor expanded in uy around 0

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

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

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

                                                        Alternative 16: 51.3% accurate, 17.7× speedup?

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

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

                                                          \[\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. Taylor expanded in uy around 0

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

                                                            \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \color{blue}{zi \cdot \left(1 - ux\right)}, xi\right) \]
                                                          2. Final simplification49.1%

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

                                                          Alternative 17: 45.3% accurate, 58.8× speedup?

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

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

                                                            \[\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 ux\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 xi \cdot \color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \]
                                                          7. Step-by-step derivation
                                                            1. Applied rewrites50.8%

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

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

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

                                                              Reproduce

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