UniformSampleCone 2

Percentage Accurate: 98.9% → 98.9%
Time: 23.5s
Alternatives: 13
Speedup: N/A×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\\
t_1 := \left(uy \cdot 2\right) \cdot \pi\\
\left(\left(\cos t_1 \cdot \sqrt{1 + \left(1 + \left(-1 - {t_0}^{2}\right)\right)}\right) \cdot xi + yi \cdot \sin t_1\right) + t_0 \cdot zi
\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. Step-by-step derivation
    1. expm1-log1p-u99.0%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)\right)\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. expm1-udef99.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 + {\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)}^{2}\right) - 1\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)}}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  7. 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(1 + {\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)}^{2}\right) - 1\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 \]
  8. 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(1 + {\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)}^{2}\right) - 1\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 \]
    2. *-commutative99.0%

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

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

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

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

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

Alternative 2: 98.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := uy \cdot \left(2 \cdot \pi\right)\\
\mathsf{fma}\left(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot maxCos\right)\right)} \cdot \left(xi \cdot \cos t_0 + yi \cdot \sin t_0\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. Simplified99.0%

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

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

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

Alternative 3: 90.2% accurate, 1.2× speedup?

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

\\
\mathsf{fma}\left(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) + 2 \cdot \left(yi \cdot \left(uy \cdot \pi\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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

Alternative 4: 90.2% accurate, 1.2× speedup?

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

\\
\mathsf{fma}\left(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 + ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux + -1\right)\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) + uy \cdot \left(2 \cdot \left(\pi \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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

Alternative 5: 90.1% accurate, 1.2× speedup?

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

\\
\mathsf{fma}\left(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos + -2 \cdot \left(ux \cdot maxCos\right)\right)\right)\right)} \cdot \left(xi \cdot \cos \left(uy \cdot \left(2 \cdot \pi\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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

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

Alternative 6: 90.0% accurate, 1.2× speedup?

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

\\
\mathsf{fma}\left(ux, maxCos \cdot \left(\left(1 - ux\right) \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot maxCos\right)\right)} \cdot \left(xi \cdot \cos \left(uy \cdot \left(2 \cdot \pi\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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 90.0% accurate, 1.2× speedup?

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

\\
\mathsf{fma}\left(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot maxCos\right)\right)} \cdot \left(xi \cdot \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) + 2 \cdot \left(uy \cdot \left(\pi \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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

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

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

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

Alternative 8: 87.2% accurate, 1.3× speedup?

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

\\
\mathsf{fma}\left(ux, maxCos \cdot zi, \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot maxCos\right)\right)} \cdot \left(xi \cdot \cos \left(uy \cdot \left(2 \cdot \pi\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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

Alternative 9: 83.9% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;xi \cdot \left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t_0 \cdot t_0}\right) + \left(1 - ux\right) \cdot \left(zi \cdot \left(ux \cdot maxCos\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy 2) < 0.00449999981

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

    if 0.00449999981 < (*.f32 uy 2)

    1. Initial program 98.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left({\left(\sqrt[3]{\color{blue}{\left(uy \cdot 2\right) \cdot \pi}}\right)}^{3}\right) \cdot \sqrt{1 - \left(\left(\left(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(1 - ux\right) \cdot \left(\left(ux \cdot maxCos\right) \cdot zi\right) \]
      5. *-commutative97.4%

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

        \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left({\left(\sqrt[3]{\color{blue}{2 \cdot \left(uy \cdot \pi\right)}}\right)}^{3}\right) \cdot \sqrt{1 - \left(\left(\left(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(1 - ux\right) \cdot \left(\left(ux \cdot maxCos\right) \cdot zi\right) \]
    6. Applied egg-rr97.4%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \color{blue}{\left({\left(\sqrt[3]{2 \cdot \left(uy \cdot \pi\right)}\right)}^{3}\right)} \cdot \sqrt{1 - \left(\left(\left(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(1 - ux\right) \cdot \left(\left(ux \cdot maxCos\right) \cdot zi\right) \]
    7. Taylor expanded in uy around 0 55.6%

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \color{blue}{0}\right) + \left(1 - ux\right) \cdot \left(\left(ux \cdot maxCos\right) \cdot zi\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.0044999998062849045:\\ \;\;\;\;\mathsf{fma}\left(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos + -2 \cdot \left(ux \cdot maxCos\right)\right)\right)\right)} \cdot \left(xi + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;xi \cdot \left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\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) + \left(1 - ux\right) \cdot \left(zi \cdot \left(ux \cdot maxCos\right)\right)\\ \end{array} \]

Alternative 10: 81.2% accurate, 2.0× speedup?

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

\\
\mathsf{fma}\left(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos + -2 \cdot \left(ux \cdot maxCos\right)\right)\right)\right)} \cdot \left(xi + 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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

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

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

Alternative 11: 81.2% accurate, 2.0× speedup?

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

\\
\mathsf{fma}\left(ux, maxCos \cdot \left(\left(1 - ux\right) \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot maxCos\right)\right)} \cdot \left(xi + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 81.2% accurate, 2.0× speedup?

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

\\
\mathsf{fma}\left(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot maxCos\right)\right)} \cdot \left(xi + 2 \cdot \left(uy \cdot \left(\pi \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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

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

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

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

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

Alternative 13: 78.6% accurate, 2.0× speedup?

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

\\
\mathsf{fma}\left(ux, maxCos \cdot zi, \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot maxCos\right)\right)} \cdot \left(xi + 2 \cdot \left(\pi \cdot \left(uy \cdot yi\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 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(ux, \left(1 - ux\right) \cdot \left(maxCos \cdot zi\right), \sqrt{1 - ux \cdot \left(ux \cdot \left(maxCos \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right)\right)\right)\right)} \cdot \left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot xi + \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Taylor expanded in uy around 0 88.9%

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

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

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

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

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

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

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

Reproduce

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