UniformSampleCone 2

Percentage Accurate: 99.0% → 99.1%
Time: 27.8s
Alternatives: 16
Speedup: 1.2×

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} 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} \]
(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}
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}

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 16 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: 99.0% accurate, 1.0× speedup?

\[\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} \]
(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}
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}

Alternative 1: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\ t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\ \left(\left(\sin \left(\pi \cdot \mathsf{fma}\left(-2, uy, 0.5\right)\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi \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)))))
  (+
   (+
    (* (* (sin (* PI (fma -2.0 uy 0.5))) t_1) xi)
    (* (* (sin (* (* uy 2.0) PI)) 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)));
	return (((sinf((((float) M_PI) * fmaf(-2.0f, uy, 0.5f))) * t_1) * xi) + ((sinf(((uy * 2.0f) * ((float) M_PI))) * 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)))
	return Float32(Float32(Float32(Float32(sin(Float32(Float32(pi) * fma(Float32(-2.0), uy, Float32(0.5)))) * t_1) * xi) + Float32(Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * t_1) * yi)) + Float32(t_0 * zi))
end
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
\left(\left(\sin \left(\pi \cdot \mathsf{fma}\left(-2, uy, 0.5\right)\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
Derivation
  1. Initial program 99.0%

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \frac{\color{blue}{\pi}}{2}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
    9. mult-flipN/A

      \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
    10. metadata-evalN/A

      \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \pi \cdot \color{blue}{\frac{1}{2}}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
    11. distribute-lft-outN/A

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

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

      \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\left(\mathsf{neg}\left(\color{blue}{uy \cdot 2}\right)\right) + \frac{1}{2}\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
    14. *-commutativeN/A

      \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\left(\mathsf{neg}\left(\color{blue}{2 \cdot uy}\right)\right) + \frac{1}{2}\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
    15. distribute-lft-neg-inN/A

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

      \[\leadsto \left(\left(\sin \left(\pi \cdot \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(2\right), uy, \frac{1}{2}\right)}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
    17. metadata-eval99.1%

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

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

Alternative 2: 99.0% accurate, 1.2× speedup?

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

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

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

Alternative 3: 99.0% accurate, 1.2× speedup?

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

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

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

Alternative 4: 98.8% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(yi \cdot \sqrt{\mathsf{fma}\left(\left(ux - 1\right) \cdot maxCos, \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux, 1\right)}, \sin \left(\pi \cdot \left(uy + uy\right)\right), \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) \]
  5. Applied rewrites98.9%

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

    \[\leadsto \mathsf{fma}\left(yi \cdot \sqrt{\mathsf{fma}\left(\color{blue}{-1} \cdot maxCos, \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux, 1\right)}, \sin \left(\pi \cdot \left(uy + uy\right)\right), \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) \]
  7. Step-by-step derivation
    1. Applied rewrites98.8%

      \[\leadsto \mathsf{fma}\left(yi \cdot \sqrt{\mathsf{fma}\left(\color{blue}{-1} \cdot maxCos, \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux, 1\right)}, \sin \left(\pi \cdot \left(uy + uy\right)\right), \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. Add Preprocessing

    Alternative 5: 98.8% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

    Alternative 6: 96.2% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \frac{\color{blue}{\pi}}{2}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
      9. mult-flipN/A

        \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
      10. metadata-evalN/A

        \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \pi \cdot \color{blue}{\frac{1}{2}}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
      11. distribute-lft-outN/A

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

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

        \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\left(\mathsf{neg}\left(\color{blue}{uy \cdot 2}\right)\right) + \frac{1}{2}\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
      14. *-commutativeN/A

        \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\left(\mathsf{neg}\left(\color{blue}{2 \cdot uy}\right)\right) + \frac{1}{2}\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
      15. distribute-lft-neg-inN/A

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

        \[\leadsto \left(\left(\sin \left(\pi \cdot \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(2\right), uy, \frac{1}{2}\right)}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
      17. metadata-eval99.1%

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

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

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

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

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

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

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

    Alternative 7: 96.1% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 90.9% accurate, 1.8× speedup?

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

      1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(yi \cdot \sqrt{\mathsf{fma}\left(\left(ux - 1\right) \cdot maxCos, \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux, 1\right)}, \sin \left(\pi \cdot \left(uy + uy\right)\right), \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) \]
      5. Applied rewrites98.9%

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(yi \cdot \sqrt{\mathsf{fma}\left(\left(ux - 1\right) \cdot maxCos, \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux, 1\right)}, \sin \left(\pi \cdot \left(uy + uy\right)\right), xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - \color{blue}{ux}\right)\right)\right)\right) \]
        5. lower--.f3288.8%

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

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

      if 1.00000002e-16 < xi

      1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
        4. lower-PI.f3287.5%

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

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

    Alternative 9: 87.5% accurate, 2.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      4. lower-PI.f3287.5%

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

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

    Alternative 10: 84.3% accurate, 2.7× speedup?

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

      1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

      if 0.200000003 < uy

      1. Initial program 99.0%

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

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

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

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

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

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

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

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

          \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \frac{\color{blue}{\pi}}{2}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
        9. mult-flipN/A

          \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
        10. metadata-evalN/A

          \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\mathsf{neg}\left(uy \cdot 2\right)\right) + \pi \cdot \color{blue}{\frac{1}{2}}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
        11. distribute-lft-outN/A

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

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

          \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\left(\mathsf{neg}\left(\color{blue}{uy \cdot 2}\right)\right) + \frac{1}{2}\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
        14. *-commutativeN/A

          \[\leadsto \left(\left(\sin \left(\pi \cdot \left(\left(\mathsf{neg}\left(\color{blue}{2 \cdot uy}\right)\right) + \frac{1}{2}\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
        15. distribute-lft-neg-inN/A

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

          \[\leadsto \left(\left(\sin \left(\pi \cdot \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(2\right), uy, \frac{1}{2}\right)}\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\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 \]
        17. metadata-eval99.1%

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + -2 \cdot uy\right)\right)\right) \]
        6. lower-*.f3258.1%

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

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

    Alternative 11: 84.2% accurate, 2.8× speedup?

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

      1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

      if 0.200000003 < uy

      1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
        5. lower-PI.f3258.0%

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

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

    Alternative 12: 82.3% accurate, 2.9× speedup?

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

      1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 0.0500000007 < uy

          1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(maxCos, ux \cdot zi, xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
            5. lower-PI.f3258.0%

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

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

        Alternative 13: 79.4% accurate, 3.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 14: 79.4% accurate, 7.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 15: 50.7% accurate, 16.6× speedup?

            \[xi + maxCos \cdot \left(ux \cdot zi\right) \]
            (FPCore (xi yi zi ux uy maxCos)
              :precision binary32
              (+ xi (* maxCos (* ux zi))))
            float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
            	return xi + (maxCos * (ux * zi));
            }
            
            real(4) function code(xi, yi, zi, ux, uy, maxcos)
            use fmin_fmax_functions
                real(4), intent (in) :: xi
                real(4), intent (in) :: yi
                real(4), intent (in) :: zi
                real(4), intent (in) :: ux
                real(4), intent (in) :: uy
                real(4), intent (in) :: maxcos
                code = xi + (maxcos * (ux * zi))
            end function
            
            function code(xi, yi, zi, ux, uy, maxCos)
            	return Float32(xi + Float32(maxCos * Float32(ux * zi)))
            end
            
            function tmp = code(xi, yi, zi, ux, uy, maxCos)
            	tmp = xi + (maxCos * (ux * zi));
            end
            
            xi + maxCos \cdot \left(ux \cdot zi\right)
            
            Derivation
            1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto xi + maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
              3. lower-*.f3250.7%

                \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
            10. Applied rewrites50.7%

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

            Alternative 16: 11.8% accurate, 22.8× speedup?

            \[maxCos \cdot \left(ux \cdot zi\right) \]
            (FPCore (xi yi zi ux uy maxCos)
              :precision binary32
              (* maxCos (* ux zi)))
            float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
            	return maxCos * (ux * zi);
            }
            
            real(4) function code(xi, yi, zi, ux, uy, maxcos)
            use fmin_fmax_functions
                real(4), intent (in) :: xi
                real(4), intent (in) :: yi
                real(4), intent (in) :: zi
                real(4), intent (in) :: ux
                real(4), intent (in) :: uy
                real(4), intent (in) :: maxcos
                code = maxcos * (ux * zi)
            end function
            
            function code(xi, yi, zi, ux, uy, maxCos)
            	return Float32(maxCos * Float32(ux * zi))
            end
            
            function tmp = code(xi, yi, zi, ux, uy, maxCos)
            	tmp = maxCos * (ux * zi);
            end
            
            maxCos \cdot \left(ux \cdot zi\right)
            
            Derivation
            1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Reproduce

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