UniformSampleCone 2

Percentage Accurate: 98.9% → 98.8%
Time: 22.3s
Alternatives: 13
Speedup: 0.9×

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 13 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.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := maxCos - maxCos \cdot ux\\ \mathsf{fma}\left(t_0, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(t_0 \cdot \left(ux + -1\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(-0.6666666666666666 \cdot \left(\pi \cdot uy\right)\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{{\left(\pi \cdot 2\right)}^{3} \cdot {uy}^{3}}\right)\right)\right) \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (- maxCos (* maxCos ux))))
   (fma
    t_0
    (* ux zi)
    (*
     (sqrt (+ 1.0 (* ux (* ux (* maxCos (* t_0 (+ ux -1.0)))))))
     (+
      (* xi (cos (* 3.0 (log1p (expm1 (* -0.6666666666666666 (* PI uy)))))))
      (* yi (sin (cbrt (* (pow (* PI 2.0) 3.0) (pow uy 3.0))))))))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = maxCos - (maxCos * ux);
	return fmaf(t_0, (ux * zi), (sqrtf((1.0f + (ux * (ux * (maxCos * (t_0 * (ux + -1.0f))))))) * ((xi * cosf((3.0f * log1pf(expm1f((-0.6666666666666666f * (((float) M_PI) * uy))))))) + (yi * sinf(cbrtf((powf((((float) M_PI) * 2.0f), 3.0f) * powf(uy, 3.0f))))))));
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(maxCos - Float32(maxCos * ux))
	return fma(t_0, Float32(ux * zi), Float32(sqrt(Float32(Float32(1.0) + Float32(ux * Float32(ux * Float32(maxCos * Float32(t_0 * Float32(ux + Float32(-1.0)))))))) * Float32(Float32(xi * cos(Float32(Float32(3.0) * log1p(expm1(Float32(Float32(-0.6666666666666666) * Float32(Float32(pi) * uy))))))) + Float32(yi * sin(cbrt(Float32((Float32(Float32(pi) * Float32(2.0)) ^ Float32(3.0)) * (uy ^ Float32(3.0)))))))))
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := maxCos - maxCos \cdot ux\\
\mathsf{fma}\left(t_0, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(t_0 \cdot \left(ux + -1\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(-0.6666666666666666 \cdot \left(\pi \cdot uy\right)\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{{\left(\pi \cdot 2\right)}^{3} \cdot {uy}^{3}}\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 98.7%

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \color{blue}{\log \left(e^{\pi \cdot \left(uy \cdot -2\right)}\right)} + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
  4. Applied egg-rr98.8%

    \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \color{blue}{\log \left(e^{\pi \cdot \left(uy \cdot -2\right)}\right)} + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
  5. Step-by-step derivation
    1. add-cube-cbrt98.7%

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \color{blue}{\left(3 \cdot \log \left(\sqrt[3]{e^{\pi \cdot \left(uy \cdot -2\right)}}\right)\right)} + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
    4. pow1/398.7%

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \log \color{blue}{\left({\left(e^{\pi \cdot \left(uy \cdot -2\right)}\right)}^{0.3333333333333333}\right)}\right) + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
    5. log-pow98.8%

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \color{blue}{\left(0.3333333333333333 \cdot \log \left(e^{\pi \cdot \left(uy \cdot -2\right)}\right)\right)}\right) + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
    6. add-log-exp98.8%

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \left(0.3333333333333333 \cdot \left(\pi \cdot \left(uy \cdot -2\right)\right)\right)\right) + yi \cdot \sin \left(\color{blue}{\sqrt[3]{\left(\left(2 \cdot \pi\right) \cdot \left(2 \cdot \pi\right)\right) \cdot \left(2 \cdot \pi\right)}} \cdot uy\right)\right)\right) \]
    3. add-cbrt-cube98.7%

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \left(0.3333333333333333 \cdot \left(\pi \cdot \left(uy \cdot -2\right)\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{\color{blue}{{\left(2 \cdot \pi\right)}^{3}} \cdot \left(\left(uy \cdot uy\right) \cdot uy\right)}\right)\right)\right) \]
    6. *-commutative98.8%

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(0.3333333333333333 \cdot \left(\pi \cdot \left(uy \cdot -2\right)\right)\right)\right)}\right) + yi \cdot \sin \left(\sqrt[3]{{\left(\pi \cdot 2\right)}^{3} \cdot {uy}^{3}}\right)\right)\right) \]
    2. *-commutative98.9%

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(\pi \cdot \left(uy \cdot -2\right)\right) \cdot 0.3333333333333333}\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{{\left(\pi \cdot 2\right)}^{3} \cdot {uy}^{3}}\right)\right)\right) \]
    3. associate-*r*98.9%

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(\left(\pi \cdot uy\right) \cdot -2\right)} \cdot 0.3333333333333333\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{{\left(\pi \cdot 2\right)}^{3} \cdot {uy}^{3}}\right)\right)\right) \]
    4. associate-*l*98.9%

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(\pi \cdot uy\right) \cdot \left(-2 \cdot 0.3333333333333333\right)}\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{{\left(\pi \cdot 2\right)}^{3} \cdot {uy}^{3}}\right)\right)\right) \]
    5. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\pi \cdot uy\right) \cdot \color{blue}{-0.6666666666666666}\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{{\left(\pi \cdot 2\right)}^{3} \cdot {uy}^{3}}\right)\right)\right) \]
  10. Applied egg-rr98.9%

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

    \[\leadsto \mathsf{fma}\left(maxCos - maxCos \cdot ux, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(maxCos - maxCos \cdot ux\right) \cdot \left(ux + -1\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(-0.6666666666666666 \cdot \left(\pi \cdot uy\right)\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{{\left(\pi \cdot 2\right)}^{3} \cdot {uy}^{3}}\right)\right)\right) \]

Alternative 2: 98.8% accurate, 0.7× speedup?

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

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \color{blue}{\log \left(e^{\pi \cdot \left(uy \cdot -2\right)}\right)} + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
  4. Applied egg-rr98.8%

    \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \color{blue}{\log \left(e^{\pi \cdot \left(uy \cdot -2\right)}\right)} + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
  5. Step-by-step derivation
    1. add-cube-cbrt98.7%

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \color{blue}{\left(3 \cdot \log \left(\sqrt[3]{e^{\pi \cdot \left(uy \cdot -2\right)}}\right)\right)} + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
    4. pow1/398.7%

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \log \color{blue}{\left({\left(e^{\pi \cdot \left(uy \cdot -2\right)}\right)}^{0.3333333333333333}\right)}\right) + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
    5. log-pow98.8%

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \color{blue}{\left(0.3333333333333333 \cdot \log \left(e^{\pi \cdot \left(uy \cdot -2\right)}\right)\right)}\right) + yi \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right) \]
    6. add-log-exp98.8%

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

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \left(0.3333333333333333 \cdot \left(\pi \cdot \left(uy \cdot -2\right)\right)\right)\right) + yi \cdot \sin \left(\color{blue}{\sqrt[3]{\left(\left(2 \cdot \pi\right) \cdot \left(2 \cdot \pi\right)\right) \cdot \left(2 \cdot \pi\right)}} \cdot uy\right)\right)\right) \]
    3. add-cbrt-cube98.7%

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

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

      \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot maxCos - maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(3 \cdot \left(0.3333333333333333 \cdot \left(\pi \cdot \left(uy \cdot -2\right)\right)\right)\right) + yi \cdot \sin \left(\sqrt[3]{\color{blue}{{\left(2 \cdot \pi\right)}^{3}} \cdot \left(\left(uy \cdot uy\right) \cdot uy\right)}\right)\right)\right) \]
    6. *-commutative98.8%

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

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

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

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

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

Alternative 3: 98.9% accurate, 0.9× speedup?

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

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

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

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

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

Alternative 4: 98.9% accurate, 1.0× speedup?

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

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

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

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

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

Alternative 5: 98.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := ux \cdot \left(maxCos \cdot \left(ux + -1\right)\right)\\ t_1 := \pi \cdot \left(uy \cdot 2\right)\\ \left(xi \cdot \left(\cos t_1 \cdot \sqrt{1 - t_0 \cdot t_0}\right) + yi \cdot \sin t_1\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 (* ux (* maxCos (+ ux -1.0)))) (t_1 (* PI (* uy 2.0))))
   (+
    (+ (* xi (* (cos t_1) (sqrt (- 1.0 (* t_0 t_0))))) (* yi (sin t_1)))
    (* zi (* ux (* maxCos (- 1.0 ux)))))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = ux * (maxCos * (ux + -1.0f));
	float t_1 = ((float) M_PI) * (uy * 2.0f);
	return ((xi * (cosf(t_1) * sqrtf((1.0f - (t_0 * t_0))))) + (yi * sinf(t_1))) + (zi * (ux * (maxCos * (1.0f - ux))));
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(ux * Float32(maxCos * Float32(ux + Float32(-1.0))))
	t_1 = Float32(Float32(pi) * Float32(uy * Float32(2.0)))
	return Float32(Float32(Float32(xi * Float32(cos(t_1) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))))) + Float32(yi * sin(t_1))) + Float32(zi * Float32(ux * Float32(maxCos * Float32(Float32(1.0) - ux)))))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	t_0 = ux * (maxCos * (ux + single(-1.0)));
	t_1 = single(pi) * (uy * single(2.0));
	tmp = ((xi * (cos(t_1) * sqrt((single(1.0) - (t_0 * t_0))))) + (yi * sin(t_1))) + (zi * (ux * (maxCos * (single(1.0) - ux))));
end
\begin{array}{l}

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  3. Step-by-step derivation
    1. associate-*r*98.6%

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

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

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

Alternative 6: 98.8% accurate, 1.2× speedup?

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

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  3. Step-by-step derivation
    1. associate-*r*98.6%

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

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

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

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

Alternative 7: 98.6% accurate, 1.2× speedup?

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

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  3. Step-by-step derivation
    1. associate-*r*98.6%

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{{maxCos}^{2} \cdot {ux}^{2}}}\right) \cdot xi + yi \cdot \sin \left(\left(2 \cdot uy\right) \cdot \pi\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  6. Step-by-step derivation
    1. unpow298.5%

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

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

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

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

Alternative 8: 90.2% accurate, 1.5× speedup?

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

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  3. Step-by-step derivation
    1. associate-*r*98.6%

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  6. Step-by-step derivation
    1. *-commutative90.4%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{\left(uy \cdot \left(yi \cdot \pi\right)\right) \cdot 2}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    2. associate-*l*90.4%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{uy \cdot \left(\left(yi \cdot \pi\right) \cdot 2\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. *-commutative90.4%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + uy \cdot \left(\color{blue}{\left(\pi \cdot yi\right)} \cdot 2\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  7. Simplified90.4%

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

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

Alternative 9: 81.4% accurate, 2.0× speedup?

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(maxCos - ux \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(-maxCos\right)\right)\right)} \cdot \left(xi \cdot \cos \left(\pi \cdot \left(uy \cdot -2\right)\right) + \color{blue}{2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)}\right)\right) \]
  7. Step-by-step derivation
    1. associate-*r*90.3%

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

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

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

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

Alternative 10: 52.1% accurate, 2.9× speedup?

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \left(1 - ux\right) \cdot \left(maxCos \cdot \color{blue}{\left(zi \cdot ux\right)}\right)\right) \]
    2. associate-*r*63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \left(1 - ux\right) \cdot \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*63.3%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \color{blue}{ux \cdot \left(\left(1 - ux\right) \cdot \left(maxCos \cdot zi\right)\right)}\right) \]
    5. associate-*r*63.3%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \color{blue}{\left(zi \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)}\right) \]
    7. *-commutative63.3%

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos \cdot \left(1 + \color{blue}{-1 \cdot ux}\right)\right)\right)\right) \]
    10. distribute-lft-in63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \color{blue}{\left(maxCos \cdot 1 + maxCos \cdot \left(-1 \cdot ux\right)\right)}\right)\right) \]
    11. *-rgt-identity63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(\color{blue}{maxCos} + maxCos \cdot \left(-1 \cdot ux\right)\right)\right)\right) \]
    12. mul-1-neg63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos + maxCos \cdot \color{blue}{\left(-ux\right)}\right)\right)\right) \]
    13. distribute-rgt-neg-in63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos + \color{blue}{\left(-maxCos \cdot ux\right)}\right)\right)\right) \]
    14. unsub-neg63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \color{blue}{\left(maxCos - maxCos \cdot ux\right)}\right)\right) \]
    15. *-commutative63.3%

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

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

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

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

    \[\leadsto \mathsf{fma}\left(1, xi \cdot \sqrt{1 + \left(maxCos \cdot \left(ux \cdot \left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux + -1\right)}, ux \cdot \left(\left(maxCos - maxCos \cdot ux\right) \cdot zi\right)\right) \]

Alternative 11: 52.0% accurate, 2.9× speedup?

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \left(1 - ux\right) \cdot \left(maxCos \cdot \color{blue}{\left(zi \cdot ux\right)}\right)\right) \]
    2. associate-*r*63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \left(1 - ux\right) \cdot \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*63.3%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \color{blue}{ux \cdot \left(\left(1 - ux\right) \cdot \left(maxCos \cdot zi\right)\right)}\right) \]
    5. associate-*r*63.3%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \color{blue}{\left(zi \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)}\right) \]
    7. *-commutative63.3%

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos \cdot \left(1 + \color{blue}{-1 \cdot ux}\right)\right)\right)\right) \]
    10. distribute-lft-in63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \color{blue}{\left(maxCos \cdot 1 + maxCos \cdot \left(-1 \cdot ux\right)\right)}\right)\right) \]
    11. *-rgt-identity63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(\color{blue}{maxCos} + maxCos \cdot \left(-1 \cdot ux\right)\right)\right)\right) \]
    12. mul-1-neg63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos + maxCos \cdot \color{blue}{\left(-ux\right)}\right)\right)\right) \]
    13. distribute-rgt-neg-in63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos + \color{blue}{\left(-maxCos \cdot ux\right)}\right)\right)\right) \]
    14. unsub-neg63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \color{blue}{\left(maxCos - maxCos \cdot ux\right)}\right)\right) \]
    15. *-commutative63.3%

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

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

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{1}, \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(ux \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos - ux \cdot maxCos\right)\right)\right) \]
  8. Taylor expanded in maxCos around 0 57.3%

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

    \[\leadsto \mathsf{fma}\left(1, xi \cdot \sqrt{1 + \left(maxCos \cdot \left(ux \cdot \left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux + -1\right)}, ux \cdot \left(\left(1 - ux\right) \cdot \left(maxCos \cdot zi\right)\right)\right) \]

Alternative 12: 52.0% accurate, 2.9× speedup?

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \left(1 - ux\right) \cdot \left(maxCos \cdot \color{blue}{\left(zi \cdot ux\right)}\right)\right) \]
    2. associate-*r*63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \left(1 - ux\right) \cdot \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*63.3%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \color{blue}{ux \cdot \left(\left(1 - ux\right) \cdot \left(maxCos \cdot zi\right)\right)}\right) \]
    5. associate-*r*63.3%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \color{blue}{\left(zi \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)}\right) \]
    7. *-commutative63.3%

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos \cdot \left(1 + \color{blue}{-1 \cdot ux}\right)\right)\right)\right) \]
    10. distribute-lft-in63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \color{blue}{\left(maxCos \cdot 1 + maxCos \cdot \left(-1 \cdot ux\right)\right)}\right)\right) \]
    11. *-rgt-identity63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(\color{blue}{maxCos} + maxCos \cdot \left(-1 \cdot ux\right)\right)\right)\right) \]
    12. mul-1-neg63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos + maxCos \cdot \color{blue}{\left(-ux\right)}\right)\right)\right) \]
    13. distribute-rgt-neg-in63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos + \color{blue}{\left(-maxCos \cdot ux\right)}\right)\right)\right) \]
    14. unsub-neg63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \color{blue}{\left(maxCos - maxCos \cdot ux\right)}\right)\right) \]
    15. *-commutative63.3%

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

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

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{1}, \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(ux \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos - ux \cdot maxCos\right)\right)\right) \]
  8. Taylor expanded in maxCos around -inf 57.3%

    \[\leadsto \mathsf{fma}\left(1, \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(ux \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \color{blue}{\left(maxCos \cdot \left(\left(-1 \cdot ux + 1\right) \cdot zi\right)\right)}\right) \]
  9. Final simplification57.3%

    \[\leadsto \mathsf{fma}\left(1, xi \cdot \sqrt{1 + \left(maxCos \cdot \left(ux \cdot \left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux + -1\right)}, ux \cdot \left(maxCos \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]

Alternative 13: 52.0% accurate, 3.0× speedup?

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \left(1 - ux\right) \cdot \left(maxCos \cdot \color{blue}{\left(zi \cdot ux\right)}\right)\right) \]
    2. associate-*r*63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \left(1 - ux\right) \cdot \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*63.3%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, \color{blue}{ux \cdot \left(\left(1 - ux\right) \cdot \left(maxCos \cdot zi\right)\right)}\right) \]
    5. associate-*r*63.3%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \color{blue}{\left(zi \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)}\right) \]
    7. *-commutative63.3%

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

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos \cdot \left(1 + \color{blue}{-1 \cdot ux}\right)\right)\right)\right) \]
    10. distribute-lft-in63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \color{blue}{\left(maxCos \cdot 1 + maxCos \cdot \left(-1 \cdot ux\right)\right)}\right)\right) \]
    11. *-rgt-identity63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(\color{blue}{maxCos} + maxCos \cdot \left(-1 \cdot ux\right)\right)\right)\right) \]
    12. mul-1-neg63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos + maxCos \cdot \color{blue}{\left(-ux\right)}\right)\right)\right) \]
    13. distribute-rgt-neg-in63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos + \color{blue}{\left(-maxCos \cdot ux\right)}\right)\right)\right) \]
    14. unsub-neg63.3%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \color{blue}{\left(maxCos - maxCos \cdot ux\right)}\right)\right) \]
    15. *-commutative63.3%

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

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

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{1}, \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \left(ux \cdot \left(ux \cdot maxCos\right)\right)\right)} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos - ux \cdot maxCos\right)\right)\right) \]
  8. Taylor expanded in ux around 0 57.2%

    \[\leadsto \mathsf{fma}\left(1, \sqrt{1 - \color{blue}{{maxCos}^{2} \cdot {ux}^{2}}} \cdot xi, ux \cdot \left(zi \cdot \left(maxCos - ux \cdot maxCos\right)\right)\right) \]
  9. Step-by-step derivation
    1. *-commutative57.2%

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

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

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

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

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

Reproduce

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