UniformSampleCone 2

Percentage Accurate: 99.0% → 99.0%
Time: 37.4s
Alternatives: 17
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 99.0% 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: 99.0% accurate, 0.8× speedup?

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

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

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

    \[\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. Final simplification99.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(\left(ux \cdot maxCos\right) \cdot \left(ux \cdot \left(ux + -1\right)\right)\right)\right)} \cdot xi, \mathsf{fma}\left(\sqrt{1 + \left(1 - ux\right) \cdot \left(maxCos \cdot \left(\left(ux \cdot maxCos\right) \cdot \left(ux \cdot \left(ux + -1\right)\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) \]

Alternative 2: 99.0% accurate, 0.9× speedup?

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

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

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

    \[\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 simplification99.1%

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

Alternative 3: 99.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 4: 99.0% accurate, 1.0× speedup?

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

\\
\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) + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)
\end{array}
Derivation
  1. Initial program 99.1%

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

    \[\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 simplification99.1%

    \[\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(\pi \cdot \left(uy \cdot -2\right)\right) + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right) \]

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

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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*99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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 99.0%

    \[\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. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
    2. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
  7. Simplified99.0%

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

    \[\leadsto zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \left(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) + yi \cdot \sin \left(\pi \cdot \left(uy \cdot 2\right)\right)\right) \]

Alternative 6: 95.8% accurate, 1.2× speedup?

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

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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*99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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 99.0%

    \[\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. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
    2. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
  7. Simplified99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \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) + \color{blue}{\left(maxCos \cdot ux\right)} \cdot zi \]
  9. Step-by-step derivation
    1. *-commutative96.3%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \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) + \color{blue}{\left(ux \cdot maxCos\right)} \cdot zi \]
  10. Simplified96.3%

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \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) + \color{blue}{\left(ux \cdot maxCos\right)} \cdot zi \]
  11. Final simplification96.3%

    \[\leadsto \left(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) + yi \cdot \sin \left(\pi \cdot \left(uy \cdot 2\right)\right)\right) + \left(ux \cdot maxCos\right) \cdot zi \]

Alternative 7: 90.0% accurate, 1.5× speedup?

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

\\
zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \left(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) + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right)
\end{array}
Derivation
  1. Initial program 99.1%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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*99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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 99.0%

    \[\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. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
    2. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
  7. Simplified99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \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 \]
  9. Step-by-step derivation
    1. associate-*r*93.2%

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

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

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

    \[\leadsto zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \left(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) + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) \]

Alternative 8: 90.0% accurate, 1.5× speedup?

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

\\
zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \left(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) + \left(uy \cdot 2\right) \cdot \left(\pi \cdot yi\right)\right)
\end{array}
Derivation
  1. Initial program 99.1%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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*99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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 99.0%

    \[\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. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
    2. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
  7. Simplified99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \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 \]
  9. Step-by-step derivation
    1. associate-*r*93.2%

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

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

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

    \[\leadsto zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \left(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) + \left(uy \cdot 2\right) \cdot \left(\pi \cdot yi\right)\right) \]

Alternative 9: 90.0% accurate, 1.5× speedup?

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

\\
zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \left(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) + \left(uy \cdot \pi\right) \cdot \left(2 \cdot yi\right)\right)
\end{array}
Derivation
  1. Initial program 99.1%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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*99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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 99.0%

    \[\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. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
    2. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
  7. Simplified99.0%

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

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \cdot ux\right)}\right) \cdot xi + yi \cdot \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. add-exp-log98.0%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \cdot ux\right)}\right) \cdot xi + yi \cdot \sin \color{blue}{\left(e^{\log \left(uy \cdot \left(2 \cdot \pi\right)\right)}\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    4. expm1-log1p-u98.0%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \cdot ux\right)}\right) \cdot xi + yi \cdot \sin \color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\log \left(uy \cdot \left(2 \cdot \pi\right)\right)}\right)\right)\right)}\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. add-exp-log98.9%

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

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

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

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \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 \]
  11. Step-by-step derivation
    1. *-commutative93.2%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \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. *-commutative93.2%

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

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

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

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

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

    \[\leadsto zi \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) + \left(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) + \left(uy \cdot \pi\right) \cdot \left(2 \cdot yi\right)\right) \]

Alternative 10: 81.8% accurate, 1.5× speedup?

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

\\
\left(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) + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) - zi \cdot \left(maxCos \cdot \left(ux \cdot ux\right)\right)
\end{array}
Derivation
  1. Initial program 99.1%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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*99.0%

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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 93.2%

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{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. associate-*r*93.2%

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

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

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

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

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

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

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

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

    \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
  12. Step-by-step derivation
    1. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
    2. unpow285.8%

      \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
  13. Simplified85.8%

    \[\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 + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) + \left(\left(-maxCos\right) \cdot \left(ux \cdot ux\right)\right) \cdot zi \]
  14. Final simplification85.8%

    \[\leadsto \left(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) + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right) - zi \cdot \left(maxCos \cdot \left(ux \cdot ux\right)\right) \]

Alternative 11: 59.5% accurate, 1.5× speedup?

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

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

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

    \[\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 67.5%

    \[\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. *-commutative67.5%

      \[\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*67.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 \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*67.5%

      \[\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. *-commutative67.5%

      \[\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*67.5%

      \[\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. *-commutative67.5%

      \[\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. *-commutative67.5%

      \[\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-neg67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-identity67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-neg67.5%

      \[\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. *-commutative67.5%

      \[\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. Simplified67.5%

    \[\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 67.5%

    \[\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 maxCos around -inf 67.5%

    \[\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(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) \]
  8. Final simplification67.5%

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

Alternative 12: 59.5% accurate, 1.6× speedup?

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

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

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

    \[\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 67.5%

    \[\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. *-commutative67.5%

      \[\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*67.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 \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*67.5%

      \[\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. *-commutative67.5%

      \[\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*67.5%

      \[\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. *-commutative67.5%

      \[\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. *-commutative67.5%

      \[\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-neg67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-identity67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-neg67.5%

      \[\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. *-commutative67.5%

      \[\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. Simplified67.5%

    \[\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 67.5%

    \[\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 ux around 0 67.5%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  9. Simplified67.5%

    \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  10. Final simplification67.5%

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

Alternative 13: 59.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), xi \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \cdot ux\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
  (cos (* uy (* 2.0 PI)))
  (* xi (sqrt (- 1.0 (* (* maxCos maxCos) (* ux ux)))))
  (* ux (* (- 1.0 ux) (* maxCos zi)))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	return fmaf(cosf((uy * (2.0f * ((float) M_PI)))), (xi * sqrtf((1.0f - ((maxCos * maxCos) * (ux * ux))))), (ux * ((1.0f - ux) * (maxCos * zi))));
}
function code(xi, yi, zi, ux, uy, maxCos)
	return fma(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))), Float32(xi * sqrt(Float32(Float32(1.0) - Float32(Float32(maxCos * maxCos) * Float32(ux * ux))))), Float32(ux * Float32(Float32(Float32(1.0) - ux) * Float32(maxCos * zi))))
end
\begin{array}{l}

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

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

    \[\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 67.5%

    \[\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. *-commutative67.5%

      \[\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*67.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 \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*67.5%

      \[\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. *-commutative67.5%

      \[\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*67.5%

      \[\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. *-commutative67.5%

      \[\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. *-commutative67.5%

      \[\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-neg67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-identity67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-neg67.5%

      \[\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. *-commutative67.5%

      \[\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. Simplified67.5%

    \[\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 67.5%

    \[\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 ux around 0 67.5%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  9. Simplified67.5%

    \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  10. Taylor expanded in zi around 0 67.5%

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

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

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

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

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

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

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

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

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

Alternative 14: 59.5% accurate, 1.6× speedup?

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

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

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

    \[\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 67.5%

    \[\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. *-commutative67.5%

      \[\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*67.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 \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*67.5%

      \[\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. *-commutative67.5%

      \[\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*67.5%

      \[\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. *-commutative67.5%

      \[\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. *-commutative67.5%

      \[\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-neg67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-identity67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-neg67.5%

      \[\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. *-commutative67.5%

      \[\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. Simplified67.5%

    \[\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 67.5%

    \[\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 ux around 0 67.5%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  9. Simplified67.5%

    \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  10. Taylor expanded in zi around 0 67.5%

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

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

Alternative 15: 59.5% accurate, 1.6× speedup?

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

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

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

    \[\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 67.5%

    \[\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. *-commutative67.5%

      \[\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*67.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 \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*67.5%

      \[\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. *-commutative67.5%

      \[\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*67.5%

      \[\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. *-commutative67.5%

      \[\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. *-commutative67.5%

      \[\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-neg67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-identity67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-neg67.5%

      \[\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. *-commutative67.5%

      \[\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. Simplified67.5%

    \[\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 67.5%

    \[\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 ux around 0 67.5%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  9. Simplified67.5%

    \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  10. Taylor expanded in maxCos around -inf 67.5%

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

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

Alternative 16: 57.2% accurate, 1.6× speedup?

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

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

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

    \[\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 67.5%

    \[\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. *-commutative67.5%

      \[\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*67.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 \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*67.5%

      \[\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. *-commutative67.5%

      \[\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*67.5%

      \[\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. *-commutative67.5%

      \[\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. *-commutative67.5%

      \[\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-neg67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-identity67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-neg67.5%

      \[\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. *-commutative67.5%

      \[\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. Simplified67.5%

    \[\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 67.5%

    \[\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 ux around 0 67.5%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  9. Simplified67.5%

    \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  10. Taylor expanded in ux around 0 65.2%

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

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

Alternative 17: 57.2% accurate, 1.6× speedup?

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

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

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

    \[\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 67.5%

    \[\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. *-commutative67.5%

      \[\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*67.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 \color{blue}{\left(\left(maxCos \cdot zi\right) \cdot ux\right)}\right) \]
    3. associate-*l*67.5%

      \[\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. *-commutative67.5%

      \[\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*67.5%

      \[\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. *-commutative67.5%

      \[\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. *-commutative67.5%

      \[\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-neg67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-identity67.5%

      \[\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-neg67.5%

      \[\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-in67.5%

      \[\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-neg67.5%

      \[\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. *-commutative67.5%

      \[\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. Simplified67.5%

    \[\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 67.5%

    \[\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 ux around 0 67.5%

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

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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. unpow267.5%

      \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  9. Simplified67.5%

    \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \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) \]
  10. Taylor expanded in ux around 0 65.2%

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

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

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

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

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

Reproduce

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