UniformSampleCone 2

Percentage Accurate: 98.9% → 98.9%
Time: 17.8s
Alternatives: 14
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

\\
\begin{array}{l}
t_0 := ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\\
t_1 := \sqrt{1 + t\_0 \cdot \left(ux \cdot \left(maxCos \cdot \left(ux + -1\right)\right)\right)}\\
t_2 := \left(uy \cdot 2\right) \cdot \pi\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(t\_1 \cdot \sin t\_2\right) \cdot yi\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. Add Preprocessing
  3. Final simplification99.0%

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

Alternative 2: 98.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := uy \cdot \left(2 \cdot \pi\right)\\ \mathsf{fma}\left(maxCos \cdot \left(\left(2 - ux\right) + -1\right), ux \cdot zi, \sqrt{1 + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(\left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(ux \cdot ux\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
    (* maxCos (+ (- 2.0 ux) -1.0))
    (* ux zi)
    (*
     (sqrt
      (+ 1.0 (* (* (- 1.0 ux) maxCos) (* (* maxCos (+ ux -1.0)) (* ux ux)))))
     (+ (* 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((maxCos * ((2.0f - ux) + -1.0f)), (ux * zi), (sqrtf((1.0f + (((1.0f - ux) * maxCos) * ((maxCos * (ux + -1.0f)) * (ux * ux))))) * ((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(Float32(maxCos * Float32(Float32(Float32(2.0) - ux) + Float32(-1.0))), Float32(ux * zi), Float32(sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * Float32(Float32(maxCos * Float32(ux + Float32(-1.0))) * Float32(ux * ux))))) * 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(maxCos \cdot \left(\left(2 - ux\right) + -1\right), ux \cdot zi, \sqrt{1 + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(\left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(ux \cdot ux\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. Simplified98.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. Add Preprocessing
  4. Step-by-step derivation
    1. expm1-log1p-u98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  5. Applied egg-rr98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  6. Step-by-step derivation
    1. expm1-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} - 1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    2. sub-neg98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} + \left(-1\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. log1p-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\left(e^{\color{blue}{\log \left(1 + \left(1 - ux\right)\right)}} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    4. rem-exp-log98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(1 + \left(1 - ux\right)\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    5. associate-+r-98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(\left(1 + 1\right) - ux\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    6. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(\color{blue}{2} - ux\right) + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    7. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(2 - ux\right) + \color{blue}{-1}\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  7. Simplified98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(2 - ux\right) + -1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  8. Final simplification98.9%

    \[\leadsto \mathsf{fma}\left(maxCos \cdot \left(\left(2 - ux\right) + -1\right), ux \cdot zi, \sqrt{1 + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(\left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(ux \cdot ux\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) \]
  9. Add Preprocessing

Alternative 3: 98.9% accurate, 1.0× speedup?

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. Add Preprocessing
  4. Final simplification98.9%

    \[\leadsto \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(1 - ux\right) \cdot maxCos\right) \cdot \left(\left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(ux \cdot ux\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) \]
  5. Add Preprocessing

Alternative 4: 98.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := uy \cdot \left(2 \cdot \pi\right)\\
\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot zi + xi \cdot \left(\sqrt{1 - {\left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right)}^{2}} \cdot \left(\cos t\_0 + yi \cdot \frac{\sin t\_0}{xi}\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. Add Preprocessing
  3. Step-by-step derivation
    1. add-log-exp98.0%

      \[\leadsto \left(\left(\color{blue}{\log \left(e^{\cos \left(\left(uy \cdot 2\right) \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 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. Applied egg-rr98.0%

    \[\leadsto \left(\left(\color{blue}{\log \left(e^{\cos \left(\left(uy \cdot 2\right) \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 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. Taylor expanded in xi around inf 98.8%

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

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

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

Alternative 5: 98.8% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

Alternative 6: 98.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := uy \cdot \left(2 \cdot \pi\right)\\ \left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot zi + \mathsf{fma}\left(xi, \cos t\_0, yi \cdot \sin t\_0\right) \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* uy (* 2.0 PI))))
   (+
    (* (* ux (* (- 1.0 ux) maxCos)) zi)
    (fma xi (cos t_0) (* yi (sin t_0))))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = uy * (2.0f * ((float) M_PI));
	return ((ux * ((1.0f - ux) * maxCos)) * zi) + fmaf(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 Float32(Float32(Float32(ux * Float32(Float32(Float32(1.0) - ux) * maxCos)) * zi) + fma(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)\\
\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot zi + \mathsf{fma}\left(xi, \cos t\_0, yi \cdot \sin t\_0\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. Add Preprocessing
  3. Step-by-step derivation
    1. add-log-exp98.0%

      \[\leadsto \left(\left(\color{blue}{\log \left(e^{\cos \left(\left(uy \cdot 2\right) \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 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. Applied egg-rr98.0%

    \[\leadsto \left(\left(\color{blue}{\log \left(e^{\cos \left(\left(uy \cdot 2\right) \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 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. Taylor expanded in ux around 0 98.7%

    \[\leadsto \color{blue}{\left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + 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 \]
  6. Step-by-step derivation
    1. fma-define98.7%

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

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

      \[\leadsto \mathsf{fma}\left(xi, \cos \left(\color{blue}{\left(uy \cdot 2\right)} \cdot \pi\right), 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 \]
    4. associate-*r*98.7%

      \[\leadsto \mathsf{fma}\left(xi, \cos \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)}, 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 \]
    5. associate-*r*98.7%

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

      \[\leadsto \mathsf{fma}\left(xi, \cos \left(uy \cdot \left(2 \cdot \pi\right)\right), 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 \]
    7. associate-*r*98.7%

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

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

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

Alternative 7: 98.7% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
\left(ux \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot zi + \left(xi \cdot \cos t\_0 + yi \cdot \sin t\_0\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. Add Preprocessing
  3. Step-by-step derivation
    1. add-log-exp98.0%

      \[\leadsto \left(\left(\color{blue}{\log \left(e^{\cos \left(\left(uy \cdot 2\right) \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 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. Applied egg-rr98.0%

    \[\leadsto \left(\left(\color{blue}{\log \left(e^{\cos \left(\left(uy \cdot 2\right) \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 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. Taylor expanded in ux around 0 98.7%

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

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

Alternative 8: 95.6% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
\left(xi \cdot \cos t\_0 + yi \cdot \sin t\_0\right) + maxCos \cdot \left(ux \cdot zi\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. Simplified98.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. Add Preprocessing
  4. Step-by-step derivation
    1. expm1-log1p-u98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  5. Applied egg-rr98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  6. Step-by-step derivation
    1. expm1-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} - 1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    2. sub-neg98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} + \left(-1\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. log1p-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\left(e^{\color{blue}{\log \left(1 + \left(1 - ux\right)\right)}} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    4. rem-exp-log98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(1 + \left(1 - ux\right)\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    5. associate-+r-98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(\left(1 + 1\right) - ux\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    6. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(\color{blue}{2} - ux\right) + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    7. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(2 - ux\right) + \color{blue}{-1}\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  7. Simplified98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(2 - ux\right) + -1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  8. Step-by-step derivation
    1. associate-*r*98.9%

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

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

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

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

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

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

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

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

    \[\leadsto \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) + maxCos \cdot \left(ux \cdot zi\right) \]
  12. Add Preprocessing

Alternative 9: 84.7% accurate, 3.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 0.0549999997

    1. Initial program 99.4%

      \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp98.3%

        \[\leadsto \left(\left(\color{blue}{\log \left(e^{\cos \left(\left(uy \cdot 2\right) \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 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. Applied egg-rr98.3%

      \[\leadsto \left(\left(\color{blue}{\log \left(e^{\cos \left(\left(uy \cdot 2\right) \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 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. Taylor expanded in uy around 0 89.1%

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

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

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

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

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

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

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

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

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

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

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

    if 0.0549999997 < uy

    1. Initial program 96.2%

      \[\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    2. Step-by-step derivation
      1. associate-+l+96.2%

        \[\leadsto \color{blue}{\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(\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 + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\right)} \]
      2. associate-*l*96.2%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 59.4% accurate, 3.9× speedup?

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

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

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

      \[\leadsto \color{blue}{\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(\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 + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\right)} \]
    2. associate-*l*98.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot zi\right)\right) \]
  12. Add Preprocessing

Alternative 11: 57.2% accurate, 4.1× speedup?

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

\\
xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot zi\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. Step-by-step derivation
    1. associate-+l+98.9%

      \[\leadsto \color{blue}{\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(\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 + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\right)} \]
    2. associate-*l*98.9%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot zi\right) + xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  11. Final simplification53.3%

    \[\leadsto xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot zi\right) \]
  12. Add Preprocessing

Alternative 12: 13.7% accurate, 51.2× speedup?

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. Add Preprocessing
  4. Step-by-step derivation
    1. expm1-log1p-u98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  5. Applied egg-rr98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  6. Step-by-step derivation
    1. expm1-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} - 1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    2. sub-neg98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} + \left(-1\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. log1p-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\left(e^{\color{blue}{\log \left(1 + \left(1 - ux\right)\right)}} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    4. rem-exp-log98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(1 + \left(1 - ux\right)\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    5. associate-+r-98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(\left(1 + 1\right) - ux\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    6. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(\color{blue}{2} - ux\right) + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    7. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(2 - ux\right) + \color{blue}{-1}\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  7. Simplified98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(2 - ux\right) + -1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  8. Step-by-step derivation
    1. associate-*r*98.9%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
  11. Step-by-step derivation
    1. associate-*r*11.8%

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

    \[\leadsto \color{blue}{maxCos \cdot \left(\left(ux \cdot zi\right) \cdot \left(1 - ux\right)\right)} \]
  13. Final simplification11.8%

    \[\leadsto maxCos \cdot \left(\left(1 - ux\right) \cdot \left(ux \cdot zi\right)\right) \]
  14. Add Preprocessing

Alternative 13: 13.7% accurate, 51.2× speedup?

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. Add Preprocessing
  4. Step-by-step derivation
    1. expm1-log1p-u98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  5. Applied egg-rr98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  6. Step-by-step derivation
    1. expm1-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} - 1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    2. sub-neg98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} + \left(-1\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. log1p-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\left(e^{\color{blue}{\log \left(1 + \left(1 - ux\right)\right)}} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    4. rem-exp-log98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(1 + \left(1 - ux\right)\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    5. associate-+r-98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(\left(1 + 1\right) - ux\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    6. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(\color{blue}{2} - ux\right) + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    7. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(2 - ux\right) + \color{blue}{-1}\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  7. Simplified98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(2 - ux\right) + -1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  8. Step-by-step derivation
    1. associate-*r*98.9%

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

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

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

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

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

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

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

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

    \[\leadsto maxCos \cdot \left(ux \cdot \left(\left(1 - ux\right) \cdot zi\right)\right) \]
  12. Add Preprocessing

Alternative 14: 12.3% accurate, 92.2× speedup?

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. Add Preprocessing
  4. Step-by-step derivation
    1. expm1-log1p-u98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  5. Applied egg-rr98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - ux\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  6. Step-by-step derivation
    1. expm1-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} - 1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    2. sub-neg98.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(e^{\mathsf{log1p}\left(1 - ux\right)} + \left(-1\right)\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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. log1p-undefine98.9%

      \[\leadsto \mathsf{fma}\left(\left(e^{\color{blue}{\log \left(1 + \left(1 - ux\right)\right)}} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    4. rem-exp-log98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(1 + \left(1 - ux\right)\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    5. associate-+r-98.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(\left(1 + 1\right) - ux\right)} + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    6. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(\color{blue}{2} - ux\right) + \left(-1\right)\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
    7. metadata-eval98.9%

      \[\leadsto \mathsf{fma}\left(\left(\left(2 - ux\right) + \color{blue}{-1}\right) \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  7. Simplified98.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(2 - ux\right) + -1\right)} \cdot maxCos, ux \cdot zi, \sqrt{1 - \left(maxCos \cdot \left(ux + -1\right)\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(maxCos \cdot \left(ux + -1\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) \]
  8. Step-by-step derivation
    1. associate-*r*98.9%

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

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

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

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

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

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

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

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

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

Reproduce

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