UniformSampleCone 2

Percentage Accurate: 98.9% → 98.5%
Time: 24.6s
Alternatives: 24
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 24 alternatives:

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.5% accurate, 1.4× speedup?

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

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

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


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

    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. Add Preprocessing
    3. Taylor expanded in uy around 0

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.8% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 3: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

Alternative 4: 98.6% accurate, 1.1× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(zi, maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} \cdot \sqrt{1 + -1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)\right)}, \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 + -1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)\right)}\right)} \]
  7. Simplified98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.3% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

Alternative 6: 98.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.4% accurate, 1.5× speedup?

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

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

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


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

    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. Add Preprocessing
    3. Taylor expanded in uy around 0

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

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

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

    1. Initial program 98.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(zi, maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} \cdot \sqrt{1 + -1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)\right)}, \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 + -1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)\right)}\right)} \]
    7. Simplified97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 97.4% accurate, 1.5× speedup?

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

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

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


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

    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. Add Preprocessing
    3. Taylor expanded in uy around 0

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 92.1% accurate, 1.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\pi \cdot \pi\right) \cdot \left(xi \cdot \left(uy \cdot uy\right)\right)}{zi}, \frac{xi}{zi}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{zi}\right)\\


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

    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. Add Preprocessing
    3. Taylor expanded in uy around 0

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

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

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

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified96.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\left(uy \cdot uy\right) \cdot xi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}{zi}, \frac{xi}{zi}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}\right) \]
      12. lower-/.f3267.0

        \[\leadsto zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\left(uy \cdot uy\right) \cdot xi\right) \cdot \left(\pi \cdot \pi\right)}{zi}, \color{blue}{\frac{xi}{zi}}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{zi}\right) \]
    10. Simplified67.0%

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

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

Alternative 10: 90.8% accurate, 2.2× speedup?

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

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

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


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

    1. Initial program 99.1%

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

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified94.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\left(uy \cdot uy\right) \cdot xi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}{zi}, \frac{xi}{zi}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}\right) \]
      12. lower-/.f3277.0

        \[\leadsto zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\left(uy \cdot uy\right) \cdot xi\right) \cdot \left(\pi \cdot \pi\right)}{zi}, \color{blue}{\frac{xi}{zi}}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{zi}\right) \]
    10. Simplified77.0%

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

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

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

        \[\leadsto \color{blue}{\mathsf{neg}\left(\left(-1 \cdot xi + \left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right)\right)} \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) + -1 \cdot xi\right)}\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\left(\left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(xi\right)\right)}\right)\right) \]
      5. unsub-negN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) - xi\right)}\right) \]
      6. lower--.f32N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) - xi\right)}\right) \]
    13. Simplified78.3%

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

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

Alternative 11: 89.7% accurate, 2.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00279999990016222:\\
\;\;\;\;zi \cdot \mathsf{fma}\left(maxCos, ux \cdot \left(1 - ux\right), \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, \frac{\left(\pi \cdot \pi\right) \cdot \left(xi \cdot uy\right)}{zi}, \frac{2 \cdot \left(\pi \cdot yi\right)}{zi}\right), \frac{xi}{zi}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;xi - \mathsf{fma}\left(2, \left(xi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot uy\right), \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \left(-yi\right)\right)\\


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

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \mathsf{fma}\left(maxCos, ux \cdot \left(1 - ux\right), \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(\mathsf{neg}\left(ux\right)\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, \frac{\left(uy \cdot xi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{zi}, \frac{2 \cdot \left(yi \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}{zi}\right), \frac{xi}{zi}\right)\right) \]
      16. lower-/.f3297.6

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified94.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\left(uy \cdot uy\right) \cdot xi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}{zi}, \frac{xi}{zi}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}\right) \]
      12. lower-/.f3277.0

        \[\leadsto zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\left(uy \cdot uy\right) \cdot xi\right) \cdot \left(\pi \cdot \pi\right)}{zi}, \color{blue}{\frac{xi}{zi}}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{zi}\right) \]
    10. Simplified77.0%

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

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

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

        \[\leadsto \color{blue}{\mathsf{neg}\left(\left(-1 \cdot xi + \left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right)\right)} \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) + -1 \cdot xi\right)}\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\left(\left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(xi\right)\right)}\right)\right) \]
      5. unsub-negN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) - xi\right)}\right) \]
      6. lower--.f32N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(-1 \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left({uy}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) - xi\right)}\right) \]
    13. Simplified78.3%

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

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

Alternative 12: 89.7% accurate, 2.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00279999990016222:\\
\;\;\;\;zi \cdot \mathsf{fma}\left(maxCos, ux \cdot \left(1 - ux\right), \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, \frac{\left(\pi \cdot \pi\right) \cdot \left(xi \cdot uy\right)}{zi}, \frac{2 \cdot \left(\pi \cdot yi\right)}{zi}\right), \frac{xi}{zi}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;xi + \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \pi\right)\right), \left(xi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(-2 \cdot \left(uy \cdot uy\right)\right)\right)\\


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

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \mathsf{fma}\left(maxCos, ux \cdot \left(1 - ux\right), \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(\mathsf{neg}\left(ux\right)\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, \frac{\left(uy \cdot xi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{zi}, \frac{2 \cdot \left(yi \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}{zi}\right), \frac{xi}{zi}\right)\right) \]
      16. lower-/.f3297.6

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified94.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\left(uy \cdot uy\right) \cdot xi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}{zi}, \frac{xi}{zi}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}\right) \]
      12. lower-/.f3277.0

        \[\leadsto zi \cdot \left(\mathsf{fma}\left(-2, \frac{\left(\left(uy \cdot uy\right) \cdot xi\right) \cdot \left(\pi \cdot \pi\right)}{zi}, \color{blue}{\frac{xi}{zi}}\right) + \frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}{zi}\right) \]
    10. Simplified77.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto xi + \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{\left(-2 \cdot {uy}^{2}\right)} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right) \]
      11. unpow2N/A

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

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

        \[\leadsto xi + \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \left(-2 \cdot \left(uy \cdot uy\right)\right) \cdot \color{blue}{\left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)}\right) \]
      14. unpow2N/A

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

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

        \[\leadsto xi + \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \left(-2 \cdot \left(uy \cdot uy\right)\right) \cdot \left(xi \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
      17. lower-PI.f3278.2

        \[\leadsto xi + \mathsf{fma}\left(yi, \sin \left(2 \cdot \left(uy \cdot \pi\right)\right), \left(-2 \cdot \left(uy \cdot uy\right)\right) \cdot \left(xi \cdot \left(\pi \cdot \color{blue}{\pi}\right)\right)\right) \]
    13. Simplified78.2%

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

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

Alternative 13: 86.2% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00279999990016222:\\
\;\;\;\;zi \cdot \mathsf{fma}\left(maxCos, ux \cdot \left(1 - ux\right), \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, \frac{\left(\pi \cdot \pi\right) \cdot \left(xi \cdot uy\right)}{zi}, \frac{2 \cdot \left(\pi \cdot yi\right)}{zi}\right), \frac{xi}{zi}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\


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

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \mathsf{fma}\left(maxCos, ux \cdot \left(1 - ux\right), \sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot \left(\mathsf{neg}\left(ux\right)\right)\right), 1\right)} \cdot \mathsf{fma}\left(uy, \mathsf{fma}\left(-2, \frac{\left(uy \cdot xi\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{zi}, \frac{2 \cdot \left(yi \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}{zi}\right), \frac{xi}{zi}\right)\right) \]
      16. lower-/.f3297.6

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified94.5%

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

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

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

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

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

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

Alternative 14: 86.9% accurate, 2.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\


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

    1. Initial program 99.2%

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

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

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

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified91.9%

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

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

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

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

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

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

Alternative 15: 86.9% accurate, 3.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00044999999227002263:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(maxCos \cdot maxCos, \left(ux \cdot ux\right) \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right), 1\right)}, \mathsf{fma}\left(2, uy \cdot \left(\pi \cdot yi\right), xi\right), maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot zi\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\


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

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified91.9%

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

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

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

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

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

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

Alternative 16: 86.8% accurate, 3.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00044999999227002263:\\
\;\;\;\;xi + \mathsf{fma}\left(ux, \mathsf{fma}\left(ux, \mathsf{fma}\left(-maxCos, zi, \mathsf{fma}\left(-0.5, xi \cdot \left(maxCos \cdot maxCos\right), \left(maxCos \cdot maxCos\right) \cdot \left(uy \cdot \left(\pi \cdot \left(-yi\right)\right)\right)\right)\right), maxCos \cdot zi\right), 2 \cdot \left(uy \cdot \left(\pi \cdot yi\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\


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

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified91.9%

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

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

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

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

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

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

Alternative 17: 86.8% accurate, 3.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.00044999999227002263:\\ \;\;\;\;\mathsf{fma}\left(yi \cdot \left(2 \cdot uy\right), \pi, \mathsf{fma}\left(ux, \mathsf{fma}\left(ux, \mathsf{fma}\left(zi, -maxCos, \mathsf{fma}\left(uy \cdot \pi, -\left(maxCos \cdot maxCos\right) \cdot yi, \left(maxCos \cdot maxCos\right) \cdot \left(xi \cdot -0.5\right)\right)\right), maxCos \cdot zi\right), xi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\ \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (if (<= (* 2.0 uy) 0.00044999999227002263)
   (fma
    (* yi (* 2.0 uy))
    PI
    (fma
     ux
     (fma
      ux
      (fma
       zi
       (- maxCos)
       (fma
        (* uy PI)
        (- (* (* maxCos maxCos) yi))
        (* (* maxCos maxCos) (* xi -0.5))))
      (* maxCos zi))
     xi))
   (fma
    uy
    (fma
     2.0
     (* PI yi)
     (*
      uy
      (fma
       -2.0
       (* xi (* PI PI))
       (* -1.3333333333333333 (* (* PI (* PI PI)) (* uy yi))))))
    xi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float tmp;
	if ((2.0f * uy) <= 0.00044999999227002263f) {
		tmp = fmaf((yi * (2.0f * uy)), ((float) M_PI), fmaf(ux, fmaf(ux, fmaf(zi, -maxCos, fmaf((uy * ((float) M_PI)), -((maxCos * maxCos) * yi), ((maxCos * maxCos) * (xi * -0.5f)))), (maxCos * zi)), xi));
	} else {
		tmp = fmaf(uy, fmaf(2.0f, (((float) M_PI) * yi), (uy * fmaf(-2.0f, (xi * (((float) M_PI) * ((float) M_PI))), (-1.3333333333333333f * ((((float) M_PI) * (((float) M_PI) * ((float) M_PI))) * (uy * yi)))))), xi);
	}
	return tmp;
}
function code(xi, yi, zi, ux, uy, maxCos)
	tmp = Float32(0.0)
	if (Float32(Float32(2.0) * uy) <= Float32(0.00044999999227002263))
		tmp = fma(Float32(yi * Float32(Float32(2.0) * uy)), Float32(pi), fma(ux, fma(ux, fma(zi, Float32(-maxCos), fma(Float32(uy * Float32(pi)), Float32(-Float32(Float32(maxCos * maxCos) * yi)), Float32(Float32(maxCos * maxCos) * Float32(xi * Float32(-0.5))))), Float32(maxCos * zi)), xi));
	else
		tmp = fma(uy, fma(Float32(2.0), Float32(Float32(pi) * yi), Float32(uy * fma(Float32(-2.0), Float32(xi * Float32(Float32(pi) * Float32(pi))), Float32(Float32(-1.3333333333333333) * Float32(Float32(Float32(pi) * Float32(Float32(pi) * Float32(pi))) * Float32(uy * yi)))))), xi);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00044999999227002263:\\
\;\;\;\;\mathsf{fma}\left(yi \cdot \left(2 \cdot uy\right), \pi, \mathsf{fma}\left(ux, \mathsf{fma}\left(ux, \mathsf{fma}\left(zi, -maxCos, \mathsf{fma}\left(uy \cdot \pi, -\left(maxCos \cdot maxCos\right) \cdot yi, \left(maxCos \cdot maxCos\right) \cdot \left(xi \cdot -0.5\right)\right)\right), maxCos \cdot zi\right), xi\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\


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

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified91.9%

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

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

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

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

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

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

Alternative 18: 86.7% accurate, 4.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00044999999227002263:\\
\;\;\;\;xi + \mathsf{fma}\left(ux, zi \cdot \mathsf{fma}\left(maxCos, -ux, maxCos\right), 2 \cdot \left(uy \cdot \left(\pi \cdot yi\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(uy, \mathsf{fma}\left(2, \pi \cdot yi, uy \cdot \mathsf{fma}\left(-2, xi \cdot \left(\pi \cdot \pi\right), -1.3333333333333333 \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(uy \cdot yi\right)\right)\right)\right), xi\right)\\


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

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto xi + \mathsf{fma}\left(ux, zi \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)} + maxCos\right), 2 \cdot \left(uy \cdot \left(\mathsf{PI}\left(\right) \cdot yi\right)\right)\right) \]
      11. distribute-rgt-neg-inN/A

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

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

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

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

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

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
    7. Simplified91.9%

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

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

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

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

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

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

Alternative 19: 81.7% accurate, 9.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto xi + \mathsf{fma}\left(ux, zi \cdot \left(\color{blue}{\left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)} + maxCos\right), 2 \cdot \left(uy \cdot \left(\mathsf{PI}\left(\right) \cdot yi\right)\right)\right) \]
    11. distribute-rgt-neg-inN/A

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

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

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

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

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

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

Alternative 20: 78.9% accurate, 11.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 21: 78.9% accurate, 11.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 22: 73.8% accurate, 20.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 23: 45.2% accurate, 20.8× speedup?

\[\begin{array}{l} \\ zi \cdot \frac{xi}{zi} \end{array} \]
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* zi (/ xi zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	return zi * (xi / zi);
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
    real(4), intent (in) :: xi
    real(4), intent (in) :: yi
    real(4), intent (in) :: zi
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = zi * (xi / zi)
end function
function code(xi, yi, zi, ux, uy, maxCos)
	return Float32(zi * Float32(xi / zi))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	tmp = zi * (xi / zi);
end
\begin{array}{l}

\\
zi \cdot \frac{xi}{zi}
\end{array}
Derivation
  1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto zi \cdot \left(\frac{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi} + \color{blue}{\frac{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}{zi}}\right) \]
  7. Simplified88.9%

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

    \[\leadsto zi \cdot \color{blue}{\frac{xi}{zi}} \]
  9. Step-by-step derivation
    1. lower-/.f3243.7

      \[\leadsto zi \cdot \color{blue}{\frac{xi}{zi}} \]
  10. Simplified43.7%

    \[\leadsto zi \cdot \color{blue}{\frac{xi}{zi}} \]
  11. Add Preprocessing

Alternative 24: 12.3% accurate, 32.1× speedup?

\[\begin{array}{l} \\ maxCos \cdot \left(ux \cdot zi\right) \end{array} \]
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* maxCos (* ux zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	return maxCos * (ux * zi);
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
    real(4), intent (in) :: xi
    real(4), intent (in) :: yi
    real(4), intent (in) :: zi
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = maxcos * (ux * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos)
	return Float32(maxCos * Float32(ux * zi))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	tmp = maxCos * (ux * zi);
end
\begin{array}{l}

\\
maxCos \cdot \left(ux \cdot zi\right)
\end{array}
Derivation
  1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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