UniformSampleCone 2

Percentage Accurate: 98.9% → 99.3%
Time: 33.7s
Alternatives: 14
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 99.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \langle \left( \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(ux + -1\right) \cdot \left(\left(1 - ux\right) \cdot {\left(ux \cdot maxCos\right)}^{2}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (cast
  (!
   :precision
   binary64
   (fma
    (* (- 1.0 ux) maxCos)
    (* ux zi)
    (*
     (sqrt (+ 1.0 (* (+ ux -1.0) (* (- 1.0 ux) (pow (* ux maxCos) 2.0)))))
     (+
      (*
       (cast
        (!
         :precision
         binary32
         (cast (! :precision binary64 (cos (* (* -2.0 PI) uy))))))
       xi)
      (* (sin (* 2.0 (* uy PI))) yi)))))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	double tmp_6 = cos(((-2.0 * ((double) M_PI)) * ((double) uy)));
	double tmp_5 = (float) tmp_6;
	double tmp_3 = fma(((1.0 - ((double) ux)) * ((double) maxCos)), (((double) ux) * ((double) zi)), (sqrt((1.0 + ((((double) ux) + -1.0) * ((1.0 - ((double) ux)) * pow((((double) ux) * ((double) maxCos)), 2.0))))) * ((((double) tmp_5) * ((double) xi)) + (sin((2.0 * (((double) uy) * ((double) M_PI)))) * ((double) yi)))));
	return (float) tmp_3;
}
function code(xi, yi, zi, ux, uy, maxCos)
	tmp_6 = cos(Float64(Float64(-2.0 * pi) * Float64(uy)))
	tmp_5 = Float32(tmp_6)
	tmp_3 = fma(Float64(Float64(1.0 - Float64(ux)) * Float64(maxCos)), Float64(Float64(ux) * Float64(zi)), Float64(sqrt(Float64(1.0 + Float64(Float64(Float64(ux) + -1.0) * Float64(Float64(1.0 - Float64(ux)) * (Float64(Float64(ux) * Float64(maxCos)) ^ 2.0))))) * Float64(Float64(Float64(tmp_5) * Float64(xi)) + Float64(sin(Float64(2.0 * Float64(Float64(uy) * pi))) * Float64(yi)))))
	return Float32(tmp_3)
end
\begin{array}{l}

\\
\langle \left( \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(ux + -1\right) \cdot \left(\left(1 - ux\right) \cdot {\left(ux \cdot maxCos\right)}^{2}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\cos \left(\pi \cdot \left(uy \cdot -2\right)\right) \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  2. Step-by-step derivation
    1. rewrite-binary64/binary32-simplify99.3%

      \[\leadsto \color{blue}{\langle \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\pi \cdot \left(uy \cdot -2\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right)} \rangle_{\text{binary64}}} \]
  3. Applied rewrite-once99.3%

    \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\pi \cdot \left(uy \cdot -2\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  4. Taylor expanded in uy around 0 99.3%

    \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(-2 \cdot \left(\pi \cdot uy\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  5. Step-by-step derivation
    1. associate-*r*99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  6. Simplified99.3%

    \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  7. Step-by-step derivation
    1. associate-*r*99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(ux \cdot ux\right) \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    2. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(ux \cdot ux\right) \cdot \left(\left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot \left(ux + -1\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    3. distribute-lft-in99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(ux \cdot ux\right) \cdot \left(\left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot ux + \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot -1\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    4. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(ux \cdot ux\right) \cdot \left(\left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot ux + -1 \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    5. distribute-lft-in99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux \cdot ux\right) \cdot \left(\left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right) \cdot ux\right) + \left(ux \cdot ux\right) \cdot \left(-1 \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  8. Applied egg-rr99.3%

    \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left({ux}^{2} \cdot \left(\left(1 - ux\right) \cdot \left({maxCos}^{2} \cdot ux\right)\right) + {ux}^{2} \cdot \left(-\left(1 - ux\right) \cdot {maxCos}^{2}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  9. Step-by-step derivation
    1. +-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left({ux}^{2} \cdot \left(-\left(1 - ux\right) \cdot {maxCos}^{2}\right) + {ux}^{2} \cdot \left(\left(1 - ux\right) \cdot \left({maxCos}^{2} \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    2. distribute-rgt-neg-out99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(-{ux}^{2} \cdot \left(\left(1 - ux\right) \cdot {maxCos}^{2}\right)\right) + {ux}^{2} \cdot \left(\left(1 - ux\right) \cdot \left({maxCos}^{2} \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    3. associate-*l*99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(-\left({ux}^{2} \cdot \left(1 - ux\right)\right) \cdot {maxCos}^{2}\right) + {ux}^{2} \cdot \left(\left(1 - ux\right) \cdot \left({maxCos}^{2} \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    4. mul-1-neg99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(-1 \cdot \left(\left({ux}^{2} \cdot \left(1 - ux\right)\right) \cdot {maxCos}^{2}\right) + {ux}^{2} \cdot \left(\left(1 - ux\right) \cdot \left({maxCos}^{2} \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    5. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(\left({ux}^{2} \cdot \left(1 - ux\right)\right) \cdot {maxCos}^{2}\right) \cdot -1 + {ux}^{2} \cdot \left(\left(1 - ux\right) \cdot \left({maxCos}^{2} \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    6. associate-*r*99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(\left({ux}^{2} \cdot \left(1 - ux\right)\right) \cdot {maxCos}^{2}\right) \cdot -1 + \left({ux}^{2} \cdot \left(1 - ux\right)\right) \cdot \left({maxCos}^{2} \cdot ux\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    7. associate-*l*99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(\left({ux}^{2} \cdot \left(1 - ux\right)\right) \cdot {maxCos}^{2}\right) \cdot -1 + \left(\left({ux}^{2} \cdot \left(1 - ux\right)\right) \cdot {maxCos}^{2}\right) \cdot ux\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    8. distribute-lft-out99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left({ux}^{2} \cdot \left(1 - ux\right)\right) \cdot {maxCos}^{2}\right) \cdot \left(-1 + ux\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    9. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot \left(1 - ux\right)\right)\right) \cdot \left(-1 + ux\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    10. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left({maxCos}^{2} \cdot \left(\left(1 - ux\right) \cdot {ux}^{2}\right)\right) \cdot \left(-1 + ux\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  10. Simplified99.3%

    \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left({maxCos}^{2} \cdot \left(\left(1 - ux\right) \cdot {ux}^{2}\right)\right) \cdot \left(-1 + ux\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  11. Step-by-step derivation
    1. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(-1 + ux\right) \cdot \left({maxCos}^{2} \cdot \left(\left(1 - ux\right) \cdot {ux}^{2}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    2. associate-*r*99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(1 - ux\right) \cdot {ux}^{2}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    3. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left({ux}^{2} \cdot \left(1 - ux\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    4. unpow299.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - ux\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    5. sub-neg99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 + \left(-ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    6. distribute-rgt-in99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(1 \cdot \left(ux \cdot ux\right) + \left(-ux\right) \cdot \left(ux \cdot ux\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    7. *-lft-identity99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(ux \cdot ux + \left(-ux\right) \cdot \left(ux \cdot ux\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    8. distribute-lft-in99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(ux \cdot ux\right) + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(-ux\right) \cdot \left(ux \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    9. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left({maxCos}^{2} \cdot \left(-1 + ux\right)\right) \cdot \left(ux \cdot ux\right) + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(-ux\right) \cdot \left(ux \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    10. +-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left({maxCos}^{2} \cdot \left(ux + -1\right)\right) \cdot \left(ux \cdot ux\right) + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(-ux\right) \cdot \left(ux \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    11. unpow299.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left({maxCos}^{2} \cdot \left(ux + -1\right)\right) \cdot {ux}^{2} + \left(\left(-1 + ux\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(-ux\right) \cdot \left(ux \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  12. Applied egg-rr99.3%

    \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left({maxCos}^{2} \cdot \left(ux + -1\right)\right) \cdot {ux}^{2} + \left({maxCos}^{2} \cdot \left(ux + -1\right)\right) \cdot {\left(-ux\right)}^{3}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  13. Step-by-step derivation
    1. distribute-lft-out99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left({maxCos}^{2} \cdot \left(ux + -1\right)\right) \cdot \left({ux}^{2} + {\left(-ux\right)}^{3}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    2. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left({ux}^{2} + {\left(-ux\right)}^{3}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    3. cube-neg99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left({ux}^{2} + \left(-{ux}^{3}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    4. unpow299.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(ux \cdot ux + \left(-{ux}^{3}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    5. sqr-neg99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(-ux\right) \cdot \left(-ux\right) + \left(-{ux}^{3}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    6. neg-mul-199.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(-1 \cdot ux\right) \cdot \left(-ux\right) + \left(-{ux}^{3}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    7. neg-mul-199.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(-1 \cdot ux\right) \cdot \left(-1 \cdot ux\right) + \left(-{ux}^{3}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    8. swap-sqr99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(-1 \cdot -1\right) \cdot \left(ux \cdot ux\right) + \left(-{ux}^{3}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    9. metadata-eval99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(1 \cdot \left(ux \cdot ux\right) + \left(-{ux}^{3}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    10. unpow299.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(1 \cdot {ux}^{2} + \left(-{ux}^{3}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    11. cube-mult99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(1 \cdot {ux}^{2} + \left(-ux \cdot \left(ux \cdot ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    12. unpow299.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(1 \cdot {ux}^{2} + \left(-ux \cdot {ux}^{2}\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    13. distribute-lft-neg-in99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(1 \cdot {ux}^{2} + \left(-ux\right) \cdot {ux}^{2}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    14. distribute-rgt-in99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left({ux}^{2} \cdot \left(1 + \left(-ux\right)\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    15. sub-neg99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left({ux}^{2} \cdot \left(1 - ux\right)\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
    16. *-commutative99.3%

      \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(\left(ux + -1\right) \cdot {maxCos}^{2}\right) \cdot \left(\left(1 - ux\right) \cdot {ux}^{2}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  14. Simplified99.3%

    \[\leadsto \langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + \left(-1 + ux\right) \cdot \left(\left(1 - ux\right) \cdot {\left(ux \cdot maxCos\right)}^{2}\right)} \cdot \left(\langle \left( \langle \left( \cos \left(\left(-2 \cdot \pi\right) \cdot uy\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  15. Final simplification99.3%

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

Alternative 2: 99.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \langle \left( \begin{array}{l} t_0 := \left(1 - ux\right) \cdot maxCos\\ \mathsf{fma}\left(t_0, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot t_0\right)\right)\right)} \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi + xi \cdot \cos \left(\pi \cdot \left(-2 \cdot uy\right)\right)\right)\right) \end{array} \right)_{\text{binary64}} \rangle_{\text{binary32}} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (cast
  (!
   :precision
   binary64
   (let* ((t_0 (* (- 1.0 ux) maxCos)))
     (fma
      t_0
      (* ux zi)
      (*
       (sqrt (+ 1.0 (* ux (* ux (* (+ ux -1.0) (* maxCos t_0))))))
       (+ (* (sin (* 2.0 (* uy PI))) yi) (* xi (cos (* PI (* -2.0 uy)))))))))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	double t_0_1 = (1.0 - ((double) ux)) * ((double) maxCos);
	double tmp = fma(t_0_1, (((double) ux) * ((double) zi)), (sqrt((1.0 + (((double) ux) * (((double) ux) * ((((double) ux) + -1.0) * (((double) maxCos) * t_0_1)))))) * ((sin((2.0 * (((double) uy) * ((double) M_PI)))) * ((double) yi)) + (((double) xi) * cos((((double) M_PI) * (-2.0 * ((double) uy))))))));
	return (float) tmp;
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0_1 = Float64(Float64(1.0 - Float64(ux)) * Float64(maxCos))
	tmp = fma(t_0_1, Float64(Float64(ux) * Float64(zi)), Float64(sqrt(Float64(1.0 + Float64(Float64(ux) * Float64(Float64(ux) * Float64(Float64(Float64(ux) + -1.0) * Float64(Float64(maxCos) * t_0_1)))))) * Float64(Float64(sin(Float64(2.0 * Float64(Float64(uy) * pi))) * Float64(yi)) + Float64(Float64(xi) * cos(Float64(pi * Float64(-2.0 * Float64(uy))))))))
	return Float32(tmp)
end
\begin{array}{l}

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

    \[\langle \mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\cos \left(\pi \cdot \left(uy \cdot -2\right)\right) \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right) \rangle_{\text{binary64}} \]
  2. Final simplification99.3%

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

Alternative 3: 99.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(maxCos \cdot \left(1 - ux\right), ux \cdot zi, \langle \left( \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi + xi \cdot \cos \left(\pi \cdot \left(-2 \cdot uy\right)\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}}\right) \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (fma
  (* maxCos (- 1.0 ux))
  (* ux zi)
  (cast
   (!
    :precision
    binary64
    (*
     (sqrt
      (+ 1.0 (* ux (* ux (* (+ ux -1.0) (* maxCos (* (- 1.0 ux) maxCos)))))))
     (+ (* (sin (* 2.0 (* uy PI))) yi) (* xi (cos (* PI (* -2.0 uy))))))))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	double tmp = sqrt((1.0 + (((double) ux) * (((double) ux) * ((((double) ux) + -1.0) * (((double) maxCos) * ((1.0 - ((double) ux)) * ((double) maxCos)))))))) * ((sin((2.0 * (((double) uy) * ((double) M_PI)))) * ((double) yi)) + (((double) xi) * cos((((double) M_PI) * (-2.0 * ((double) uy))))));
	return fmaf((maxCos * (1.0f - ux)), (ux * zi), ((float) tmp));
}
function code(xi, yi, zi, ux, uy, maxCos)
	tmp = Float64(sqrt(Float64(1.0 + Float64(Float64(ux) * Float64(Float64(ux) * Float64(Float64(Float64(ux) + -1.0) * Float64(Float64(maxCos) * Float64(Float64(1.0 - Float64(ux)) * Float64(maxCos)))))))) * Float64(Float64(sin(Float64(2.0 * Float64(Float64(uy) * pi))) * Float64(yi)) + Float64(Float64(xi) * cos(Float64(pi * Float64(-2.0 * Float64(uy)))))))
	return fma(Float32(maxCos * Float32(Float32(1.0) - ux)), Float32(ux * zi), Float32(tmp))
end
\begin{array}{l}

\\
\mathsf{fma}\left(maxCos \cdot \left(1 - ux\right), ux \cdot zi, \langle \left( \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi + xi \cdot \cos \left(\pi \cdot \left(-2 \cdot uy\right)\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}}\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 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\cos \left(\pi \cdot \left(uy \cdot -2\right)\right) \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Step-by-step derivation
    1. rewrite-binary32/binary6499.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \langle \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\cos \left(\pi \cdot \left(uy \cdot -2\right)\right) \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \rangle_{\text{binary64}}\right)} \]
  4. Applied rewrite-once99.2%

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

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

Alternative 4: 99.0% accurate, 0.6× speedup?

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

\\
\langle \left( \langle \left( \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \sqrt{\mathsf{fma}\left(ux, ux \cdot \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot \left(maxCos \cdot \left(ux + -1\right)\right)\right), 1\right)} \cdot \mathsf{fma}\left(xi, \cos \left(-2 \cdot \left(uy \cdot \pi\right)\right), yi \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right)\right) \right)_{\text{binary32}} \rangle_{\text{binary64}} \right)_{\text{binary64}} \rangle_{\text{binary32}}
\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 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\cos \left(\pi \cdot \left(uy \cdot -2\right)\right) \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right)} \]
  3. Step-by-step derivation
    1. rewrite-binary32/binary64-simplify98.9%

      \[\leadsto \color{blue}{\langle \color{blue}{\langle \color{blue}{\left( \color{blue}{\mathsf{fma}\left(\left(1 - ux\right) \cdot maxCos, ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(ux + -1\right) \cdot \left(maxCos \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\right)\right)\right)} \cdot \left(\cos \left(\pi \cdot \left(uy \cdot -2\right)\right) \cdot xi + \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\right)} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \rangle_{\text{binary64}}} \]
  4. Applied rewrite-once98.9%

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

    \[\leadsto \color{blue}{\langle \color{blue}{\langle \color{blue}{\left( \color{blue}{\mathsf{fma}\left(maxCos, ux \cdot \left(\left(1 - ux\right) \cdot zi\right), \sqrt{\mathsf{fma}\left(ux, ux \cdot \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot \left(maxCos \cdot \left(1 - ux\right)\right)\right), 1\right)} \cdot \mathsf{fma}\left(xi, \cos \left(-2 \cdot \left(uy \cdot \pi\right)\right), yi \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right)\right)} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \rangle_{\text{binary64}}} \]
  6. Final simplification99.1%

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

Alternative 5: 99.0% accurate, 0.8× speedup?

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

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

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

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

Alternative 6: 99.0% accurate, 0.9× speedup?

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

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

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

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

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

Alternative 7: 98.9% accurate, 1.0× speedup?

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

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

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

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

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

Alternative 8: 98.8% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 9: 97.8% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos t_0, xi \cdot \sqrt{1 - ux \cdot \left(\left(maxCos \cdot \left(ux \cdot maxCos\right)\right) \cdot \left(1 - ux\right)\right)}, yi \cdot \sin t_0 + maxCos \cdot \left(ux \cdot zi\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 3.9999999e-4

    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. Simplified99.4%

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

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

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

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

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

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

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

    if 3.9999999e-4 < uy

    1. Initial program 98.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.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \leq 0.00039999998989515007:\\ \;\;\;\;\mathsf{fma}\left(maxCos \cdot \left(1 - ux\right), ux \cdot zi, \sqrt{1 + ux \cdot \left(ux \cdot \left(\left(maxCos \cdot maxCos\right) \cdot \left(ux + -1\right)\right)\right)} \cdot \left(xi \cdot \cos \left(\pi \cdot \left(-2 \cdot uy\right)\right) + \left(2 \cdot uy\right) \cdot \left(\pi \cdot yi\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right), xi \cdot \sqrt{1 - ux \cdot \left(\left(maxCos \cdot \left(ux \cdot maxCos\right)\right) \cdot \left(1 - ux\right)\right)}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right)\\ \end{array} \]

Alternative 10: 90.2% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 87.3% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 59.3% accurate, 1.5× speedup?

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right), \sqrt{1 - ux \cdot \left(\left(1 - ux\right) \cdot \left(\left(ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) \cdot maxCos\right)\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. associate-*r*62.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 59.3% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 59.2% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

Reproduce

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