UniformSampleCone 2

Percentage Accurate: 98.9% → 98.9%
Time: 21.3s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.9% accurate, 1.0× speedup?

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

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

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

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

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

Alternative 2: 98.8% accurate, 1.2× speedup?

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

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

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

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

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

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

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

Alternative 3: 90.3% accurate, 1.2× speedup?

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

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

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

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

    \[\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) + \color{blue}{2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)}\right)\right) \]
  4. Step-by-step derivation
    1. associate-*r*93.3%

      \[\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) + 2 \cdot \color{blue}{\left(\left(uy \cdot yi\right) \cdot \pi\right)}\right)\right) \]
    2. *-commutative93.3%

      \[\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) + 2 \cdot \color{blue}{\left(\pi \cdot \left(uy \cdot yi\right)\right)}\right)\right) \]
  5. Simplified93.3%

    \[\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) + \color{blue}{2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)}\right)\right) \]
  6. Final simplification93.3%

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

Alternative 4: 90.2% accurate, 1.2× speedup?

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

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

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

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

    \[\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) + \color{blue}{2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)}\right)\right) \]
  4. Step-by-step derivation
    1. associate-*r*93.3%

      \[\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) + \color{blue}{\left(2 \cdot uy\right) \cdot \left(yi \cdot \pi\right)}\right)\right) \]
    2. *-commutative93.3%

      \[\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) + \left(2 \cdot uy\right) \cdot \color{blue}{\left(\pi \cdot yi\right)}\right)\right) \]
  5. Simplified93.3%

    \[\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) + \color{blue}{\left(2 \cdot uy\right) \cdot \left(\pi \cdot yi\right)}\right)\right) \]
  6. Taylor expanded in ux around 0 93.2%

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

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

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

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

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

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

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

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

Alternative 5: 90.2% accurate, 1.2× speedup?

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

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

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

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

    \[\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) + \color{blue}{2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)}\right)\right) \]
  4. Step-by-step derivation
    1. associate-*r*93.3%

      \[\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) + 2 \cdot \color{blue}{\left(\left(uy \cdot yi\right) \cdot \pi\right)}\right)\right) \]
    2. *-commutative93.3%

      \[\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) + 2 \cdot \color{blue}{\left(\pi \cdot \left(uy \cdot yi\right)\right)}\right)\right) \]
  5. Simplified93.3%

    \[\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) + \color{blue}{2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)}\right)\right) \]
  6. Taylor expanded in ux around 0 93.2%

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

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

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

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

Alternative 6: 59.7% accurate, 1.5× speedup?

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

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

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

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

    \[\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}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}\right) \]
  4. Taylor expanded in ux around 0 60.6%

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

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

      \[\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}{\left(ux \cdot ux\right)} \cdot maxCos\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
    3. associate-*l*60.6%

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

      \[\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 \color{blue}{\left(maxCos \cdot ux\right)}\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
  6. Simplified60.6%

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

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

Alternative 7: 59.7% accurate, 1.5× speedup?

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

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

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

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

    \[\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}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}\right) \]
  4. Taylor expanded in ux around 0 60.6%

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

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

      \[\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}{\left(ux \cdot ux\right)} \cdot maxCos\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
    3. associate-*l*60.6%

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

      \[\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 \color{blue}{\left(maxCos \cdot ux\right)}\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
  6. Simplified60.6%

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

    \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \color{blue}{\left(-1 \cdot \left({ux}^{2} \cdot zi\right) + ux \cdot zi\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutative60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \color{blue}{\left(ux \cdot zi + -1 \cdot \left({ux}^{2} \cdot zi\right)\right)}\right) \]
    2. associate-*r*60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot zi + \color{blue}{\left(-1 \cdot {ux}^{2}\right) \cdot zi}\right)\right) \]
    3. distribute-rgt-out60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \color{blue}{\left(zi \cdot \left(ux + -1 \cdot {ux}^{2}\right)\right)}\right) \]
    4. *-lft-identity60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(zi \cdot \left(\color{blue}{1 \cdot ux} + -1 \cdot {ux}^{2}\right)\right)\right) \]
    5. unpow260.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(zi \cdot \left(1 \cdot ux + -1 \cdot \color{blue}{\left(ux \cdot ux\right)}\right)\right)\right) \]
    6. associate-*r*60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(zi \cdot \left(1 \cdot ux + \color{blue}{\left(-1 \cdot ux\right) \cdot ux}\right)\right)\right) \]
    7. neg-mul-160.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(zi \cdot \left(1 \cdot ux + \color{blue}{\left(-ux\right)} \cdot ux\right)\right)\right) \]
    8. distribute-rgt-in60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(zi \cdot \color{blue}{\left(ux \cdot \left(1 + \left(-ux\right)\right)\right)}\right)\right) \]
    9. sub-neg60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(zi \cdot \left(ux \cdot \color{blue}{\left(1 - ux\right)}\right)\right)\right) \]
    10. associate-*l*60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \color{blue}{\left(\left(zi \cdot ux\right) \cdot \left(1 - ux\right)\right)}\right) \]
    11. *-commutative60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(\color{blue}{\left(ux \cdot zi\right)} \cdot \left(1 - ux\right)\right)\right) \]
    12. associate-*r*60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \color{blue}{\left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}\right) \]
    13. *-commutative60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \color{blue}{\left(\left(1 - ux\right) \cdot zi\right)}\right)\right) \]
    14. sub-neg60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(\color{blue}{\left(1 + \left(-ux\right)\right)} \cdot zi\right)\right)\right) \]
    15. +-commutative60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(\color{blue}{\left(\left(-ux\right) + 1\right)} \cdot zi\right)\right)\right) \]
    16. distribute-rgt1-in60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \color{blue}{\left(zi + \left(-ux\right) \cdot zi\right)}\right)\right) \]
    17. distribute-lft-neg-in60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(zi + \color{blue}{\left(-ux \cdot zi\right)}\right)\right)\right) \]
    18. unsub-neg60.6%

      \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \color{blue}{\left(zi - ux \cdot zi\right)}\right)\right) \]
  9. Simplified60.6%

    \[\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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \color{blue}{\left(ux \cdot \left(zi - ux \cdot zi\right)\right)}\right) \]
  10. Final simplification60.6%

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

Alternative 8: 57.3% accurate, 1.6× speedup?

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

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

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

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

    \[\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}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)}\right) \]
  4. Taylor expanded in ux around 0 60.6%

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

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

      \[\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}{\left(ux \cdot ux\right)} \cdot maxCos\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
    3. associate-*l*60.6%

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

      \[\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 \color{blue}{\left(maxCos \cdot ux\right)}\right)\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
  6. Simplified60.6%

    \[\leadsto \mathsf{fma}\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right), \sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot \color{blue}{\left(ux \cdot \left(maxCos \cdot ux\right)\right)}\right)} \cdot xi, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
  7. Taylor expanded in ux around 0 58.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(maxCos \cdot ux\right)\right)\right)} \cdot xi, maxCos \cdot \color{blue}{\left(ux \cdot zi\right)}\right) \]
  8. Final simplification58.5%

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

Reproduce

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