UniformSampleCone 2

Percentage Accurate: 98.9% → 99.0%
Time: 8.2s
Alternatives: 15
Speedup: 0.5×

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}

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 15 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.0% accurate, 0.5× speedup?

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

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

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

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

Alternative 2: 98.8% accurate, 0.7× speedup?

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

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

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

    \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
  3. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot \color{blue}{maxCos} \]
    2. lower-*.f32N/A

      \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot \color{blue}{maxCos} \]
    3. *-commutativeN/A

      \[\leadsto \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos \]
    4. lower-*.f32N/A

      \[\leadsto \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos \]
    5. *-commutativeN/A

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
    6. lower-*.f32N/A

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
    7. lift--.f3213.7

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
  4. Applied rewrites13.7%

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

    \[\leadsto \color{blue}{ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \left(\frac{-1}{2} \cdot \left({maxCos}^{2} \cdot \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. lower-fma.f32N/A

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

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

Alternative 3: 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 := \left(uy \cdot 2\right) \cdot \pi\\ \left(\left(\cos t\_1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.5, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right), ux \cdot ux, 1\right)\right) \cdot xi + \left(\sin t\_1 \cdot \sqrt{1 - t\_0 \cdot t\_0}\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 (* (* uy 2.0) PI)))
   (+
    (+
     (*
      (*
       (cos t_1)
       (fma
        (fma -0.5 (* maxCos maxCos) (* (* maxCos maxCos) ux))
        (* ux ux)
        1.0))
      xi)
     (* (* (sin t_1) (sqrt (- 1.0 (* t_0 t_0)))) 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 = (uy * 2.0f) * ((float) M_PI);
	return (((cosf(t_1) * fmaf(fmaf(-0.5f, (maxCos * maxCos), ((maxCos * maxCos) * ux)), (ux * ux), 1.0f)) * xi) + ((sinf(t_1) * sqrtf((1.0f - (t_0 * t_0)))) * 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 = Float32(Float32(uy * Float32(2.0)) * Float32(pi))
	return Float32(Float32(Float32(Float32(cos(t_1) * fma(fma(Float32(-0.5), Float32(maxCos * maxCos), Float32(Float32(maxCos * maxCos) * ux)), Float32(ux * ux), Float32(1.0))) * xi) + Float32(Float32(sin(t_1) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0)))) * yi)) + Float32(t_0 * zi))
end
\begin{array}{l}

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

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

    \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \color{blue}{\left(1 + {ux}^{2} \cdot \left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux\right)\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left({ux}^{2} \cdot \left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux\right) + \color{blue}{1}\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    2. *-commutativeN/A

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \left(\left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux\right) \cdot {ux}^{2} + 1\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. lower-fma.f32N/A

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \mathsf{fma}\left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux, \color{blue}{{ux}^{2}}, 1\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    4. lower-fma.f32N/A

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2}, {maxCos}^{2}, {maxCos}^{2} \cdot ux\right), {\color{blue}{ux}}^{2}, 1\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. unpow2N/A

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, {maxCos}^{2} \cdot ux\right), {ux}^{2}, 1\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    6. lower-*.f32N/A

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, {maxCos}^{2} \cdot ux\right), {ux}^{2}, 1\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    7. lower-*.f32N/A

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

      \[\leadsto \left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right), {ux}^{2}, 1\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    9. lower-*.f32N/A

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

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

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

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

Alternative 4: 98.8% accurate, 1.4× speedup?

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

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

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

    \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \left(maxCos \cdot ux\right) \cdot \left(zi \cdot \left(1 - ux\right)\right) + \left(\color{blue}{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    2. lower-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \color{blue}{zi \cdot \left(1 - ux\right)}, xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    3. lower-*.f32N/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \color{blue}{zi} \cdot \left(1 - ux\right), xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \color{blue}{zi}, xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    5. lower-*.f32N/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot \color{blue}{zi}, xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    6. lift--.f32N/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
  4. Applied rewrites98.8%

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

Alternative 5: 95.7% accurate, 1.5× speedup?

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

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

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

    \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \left(maxCos \cdot ux\right) \cdot zi + \left(\color{blue}{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    2. lower-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, \color{blue}{zi}, xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    3. lower-*.f32N/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, zi, xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, zi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    5. lower-fma.f32N/A

      \[\leadsto \mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), xi, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
  4. Applied rewrites95.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)\right)} \]
  5. Add Preprocessing

Alternative 6: 95.9% accurate, 1.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos t\_1, xi, \sin t\_1 \cdot yi\right)\\


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

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot \color{blue}{maxCos} \]
      2. lower-*.f32N/A

        \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot \color{blue}{maxCos} \]
      3. *-commutativeN/A

        \[\leadsto \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos \]
      4. lower-*.f32N/A

        \[\leadsto \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
      6. lower-*.f32N/A

        \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
      7. lift--.f3214.1

        \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
    4. Applied rewrites14.1%

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

      \[\leadsto \color{blue}{ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \left(\frac{-1}{2} \cdot \left({maxCos}^{2} \cdot \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
    6. Step-by-step derivation
      1. lower-fma.f32N/A

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

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

      \[\leadsto xi + \color{blue}{\left(ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) + uy \cdot \left(-1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + uy \cdot \left(-2 \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right) + {maxCos}^{2} \cdot \left({ux}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right)\right)\right)} \]
    9. Applied rewrites97.8%

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

    if 0.00350000011 < 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. Taylor expanded in ux around 0

      \[\leadsto \color{blue}{xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi + \color{blue}{yi} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
      2. lower-fma.f32N/A

        \[\leadsto \mathsf{fma}\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{xi}, yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    4. Applied rewrites90.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\pi \cdot \left(2 \cdot uy\right)\right), xi, \sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 85.6% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
t_0 := xi \cdot \left(\pi \cdot \pi\right)\\
xi + \mathsf{fma}\left(ux, \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right), uy \cdot \mathsf{fma}\left(-1, \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(yi \cdot \pi\right)\right), \mathsf{fma}\left(2, yi \cdot \pi, uy \cdot \mathsf{fma}\left(-2, t\_0, \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot t\_0\right)\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 98.9%

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

    \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
  3. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot \color{blue}{maxCos} \]
    2. lower-*.f32N/A

      \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot \color{blue}{maxCos} \]
    3. *-commutativeN/A

      \[\leadsto \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos \]
    4. lower-*.f32N/A

      \[\leadsto \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos \]
    5. *-commutativeN/A

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
    6. lower-*.f32N/A

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
    7. lift--.f3213.7

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
  4. Applied rewrites13.7%

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

    \[\leadsto \color{blue}{ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \left(\frac{-1}{2} \cdot \left({maxCos}^{2} \cdot \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. lower-fma.f32N/A

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

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

    \[\leadsto xi + \color{blue}{\left(ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) + uy \cdot \left(-1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + \left(2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right) + uy \cdot \left(-2 \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right) + {maxCos}^{2} \cdot \left({ux}^{2} \cdot \left(xi \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right)\right)\right)} \]
  9. Applied rewrites85.6%

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

Alternative 8: 81.4% accurate, 3.8× speedup?

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

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

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

    \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
  3. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot \color{blue}{maxCos} \]
    2. lower-*.f32N/A

      \[\leadsto \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \cdot \color{blue}{maxCos} \]
    3. *-commutativeN/A

      \[\leadsto \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos \]
    4. lower-*.f32N/A

      \[\leadsto \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos \]
    5. *-commutativeN/A

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
    6. lower-*.f32N/A

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
    7. lift--.f3213.7

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos \]
  4. Applied rewrites13.7%

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

    \[\leadsto \color{blue}{ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \left(\frac{-1}{2} \cdot \left({maxCos}^{2} \cdot \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot \left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. lower-fma.f32N/A

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

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

    \[\leadsto xi + \color{blue}{\left(ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) + uy \cdot \left(-1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
  9. Step-by-step derivation
    1. lower-+.f32N/A

      \[\leadsto xi + \left(ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) + \color{blue}{uy \cdot \left(-1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
    2. lower-fma.f32N/A

      \[\leadsto xi + \mathsf{fma}\left(ux, maxCos \cdot zi + \color{blue}{ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)}, uy \cdot \left(-1 \cdot \left({maxCos}^{2} \cdot \left({ux}^{2} \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) + 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
  10. Applied rewrites81.4%

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

Alternative 9: 60.7% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\\ \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\ \;\;\;\;\sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_0\\ \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\ \;\;\;\;\mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
 :precision binary32
 (let* ((t_0 (* (* 2.0 (* uy PI)) yi)))
   (if (<= yi -4.99999991225835e-14)
     (* (sqrt (- 1.0 (* (* ux ux) (* maxCos maxCos)))) t_0)
     (if (<= yi 3.5000000934815034e-5)
       (fma
        (+
         1.0
         (* (* ux ux) (fma -0.5 (* maxCos maxCos) (* (* maxCos maxCos) ux))))
        xi
        (* (* (* (- 1.0 ux) zi) ux) maxCos))
       (* 1.0 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))) * yi;
	float tmp;
	if (yi <= -4.99999991225835e-14f) {
		tmp = sqrtf((1.0f - ((ux * ux) * (maxCos * maxCos)))) * t_0;
	} else if (yi <= 3.5000000934815034e-5f) {
		tmp = fmaf((1.0f + ((ux * ux) * fmaf(-0.5f, (maxCos * maxCos), ((maxCos * maxCos) * ux)))), xi, ((((1.0f - ux) * zi) * ux) * maxCos));
	} else {
		tmp = 1.0f * t_0;
	}
	return tmp;
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(2.0) * Float32(uy * Float32(pi))) * yi)
	tmp = Float32(0.0)
	if (yi <= Float32(-4.99999991225835e-14))
		tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(ux * ux) * Float32(maxCos * maxCos)))) * t_0);
	elseif (yi <= Float32(3.5000000934815034e-5))
		tmp = fma(Float32(Float32(1.0) + Float32(Float32(ux * ux) * fma(Float32(-0.5), Float32(maxCos * maxCos), Float32(Float32(maxCos * maxCos) * ux)))), xi, Float32(Float32(Float32(Float32(Float32(1.0) - ux) * zi) * ux) * maxCos));
	else
		tmp = Float32(Float32(1.0) * t_0);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\\
\mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\
\;\;\;\;\sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_0\\

\mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\\

\mathbf{else}:\\
\;\;\;\;1 \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if yi < -4.99999991e-14

    1. Initial program 98.8%

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

      \[\leadsto \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
      2. lower-*.f32N/A

        \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
    4. Applied rewrites62.5%

      \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
    5. Taylor expanded in uy around 0

      \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
      2. lower-*.f32N/A

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
      3. lift-PI.f3251.8

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
    7. Applied rewrites51.8%

      \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
    8. Taylor expanded in ux around 0

      \[\leadsto \sqrt{1 - {ux}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
    9. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
      2. lift-*.f3251.8

        \[\leadsto \sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
    10. Applied rewrites51.8%

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

    if -4.99999991e-14 < yi < 3.50000009e-5

    1. Initial program 99.0%

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

      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
      2. *-commutativeN/A

        \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi + \color{blue}{maxCos} \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
      3. lower-fma.f32N/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)}, xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)} \]
    5. Taylor expanded in ux around 0

      \[\leadsto \mathsf{fma}\left(1 + {ux}^{2} \cdot \left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
    6. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto \mathsf{fma}\left(1 + {ux}^{2} \cdot \left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      2. lower-*.f32N/A

        \[\leadsto \mathsf{fma}\left(1 + {ux}^{2} \cdot \left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      4. lower-*.f32N/A

        \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \left(\frac{-1}{2} \cdot {maxCos}^{2} + {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      5. lower-fma.f32N/A

        \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, {maxCos}^{2}, {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      6. pow2N/A

        \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      7. lift-*.f32N/A

        \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      8. lower-*.f32N/A

        \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, {maxCos}^{2} \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      9. pow2N/A

        \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
      10. lift-*.f3263.3

        \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]
    7. Applied rewrites63.3%

      \[\leadsto \mathsf{fma}\left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right), xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right) \]

    if 3.50000009e-5 < yi

    1. Initial program 98.7%

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

      \[\leadsto \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
      2. lower-*.f32N/A

        \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
    4. Applied rewrites75.1%

      \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
    5. Taylor expanded in uy around 0

      \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
      2. lower-*.f32N/A

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
      3. lift-PI.f3261.4

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
    7. Applied rewrites61.4%

      \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
    8. Taylor expanded in ux around 0

      \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]
    9. Step-by-step derivation
      1. Applied rewrites61.2%

        \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]
    10. Recombined 3 regimes into one program.
    11. Add Preprocessing

    Alternative 10: 60.7% accurate, 6.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\\ \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\ \;\;\;\;\sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_0\\ \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\ \;\;\;\;xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot t\_0\\ \end{array} \end{array} \]
    (FPCore (xi yi zi ux uy maxCos)
     :precision binary32
     (let* ((t_0 (* (* 2.0 (* uy PI)) yi)))
       (if (<= yi -4.99999991225835e-14)
         (* (sqrt (- 1.0 (* (* ux ux) (* maxCos maxCos)))) t_0)
         (if (<= yi 3.5000000934815034e-5)
           (+
            xi
            (*
             ux
             (fma
              maxCos
              zi
              (* ux (fma -1.0 (* maxCos zi) (* -0.5 (* (* maxCos maxCos) xi)))))))
           (* 1.0 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))) * yi;
    	float tmp;
    	if (yi <= -4.99999991225835e-14f) {
    		tmp = sqrtf((1.0f - ((ux * ux) * (maxCos * maxCos)))) * t_0;
    	} else if (yi <= 3.5000000934815034e-5f) {
    		tmp = xi + (ux * fmaf(maxCos, zi, (ux * fmaf(-1.0f, (maxCos * zi), (-0.5f * ((maxCos * maxCos) * xi))))));
    	} else {
    		tmp = 1.0f * t_0;
    	}
    	return tmp;
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	t_0 = Float32(Float32(Float32(2.0) * Float32(uy * Float32(pi))) * yi)
    	tmp = Float32(0.0)
    	if (yi <= Float32(-4.99999991225835e-14))
    		tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(ux * ux) * Float32(maxCos * maxCos)))) * t_0);
    	elseif (yi <= Float32(3.5000000934815034e-5))
    		tmp = Float32(xi + Float32(ux * fma(maxCos, zi, Float32(ux * fma(Float32(-1.0), Float32(maxCos * zi), Float32(Float32(-0.5) * Float32(Float32(maxCos * maxCos) * xi)))))));
    	else
    		tmp = Float32(Float32(1.0) * t_0);
    	end
    	return tmp
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\\
    \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\
    \;\;\;\;\sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_0\\
    
    \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\
    \;\;\;\;xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;1 \cdot t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if yi < -4.99999991e-14

      1. Initial program 98.8%

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

        \[\leadsto \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
        2. lower-*.f32N/A

          \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
      4. Applied rewrites62.5%

        \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
      5. Taylor expanded in uy around 0

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
      6. Step-by-step derivation
        1. lower-*.f32N/A

          \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
        2. lower-*.f32N/A

          \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
        3. lift-PI.f3251.8

          \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
      7. Applied rewrites51.8%

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
      8. Taylor expanded in ux around 0

        \[\leadsto \sqrt{1 - {ux}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
      9. Step-by-step derivation
        1. pow2N/A

          \[\leadsto \sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
        2. lift-*.f3251.8

          \[\leadsto \sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
      10. Applied rewrites51.8%

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

      if -4.99999991e-14 < yi < 3.50000009e-5

      1. Initial program 99.0%

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

        \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
      3. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
        2. *-commutativeN/A

          \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi + \color{blue}{maxCos} \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
        3. lower-fma.f32N/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)}, xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)} \]
      5. Taylor expanded in ux around 0

        \[\leadsto xi + \color{blue}{ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right)} \]
      6. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto xi + ux \cdot \color{blue}{\left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right)} \]
        2. lower-*.f32N/A

          \[\leadsto xi + ux \cdot \left(maxCos \cdot zi + \color{blue}{ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)}\right) \]
        3. lower-fma.f32N/A

          \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
        4. lower-*.f32N/A

          \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
        5. lower-fma.f32N/A

          \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
        6. lift-*.f32N/A

          \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
        7. lower-*.f32N/A

          \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
        8. lower-*.f32N/A

          \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
        9. pow2N/A

          \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right) \]
        10. lift-*.f3263.3

          \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right) \]
      7. Applied rewrites63.3%

        \[\leadsto xi + \color{blue}{ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right)} \]

      if 3.50000009e-5 < yi

      1. Initial program 98.7%

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

        \[\leadsto \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
        2. lower-*.f32N/A

          \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
      4. Applied rewrites75.1%

        \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
      5. Taylor expanded in uy around 0

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
      6. Step-by-step derivation
        1. lower-*.f32N/A

          \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
        2. lower-*.f32N/A

          \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
        3. lift-PI.f3261.4

          \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
      7. Applied rewrites61.4%

        \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
      8. Taylor expanded in ux around 0

        \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]
      9. Step-by-step derivation
        1. Applied rewrites61.2%

          \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]
      10. Recombined 3 regimes into one program.
      11. Add Preprocessing

      Alternative 11: 60.7% accurate, 6.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\\ \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\ \;\;\;\;xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (xi yi zi ux uy maxCos)
       :precision binary32
       (let* ((t_0 (* 1.0 (* (* 2.0 (* uy PI)) yi))))
         (if (<= yi -4.99999991225835e-14)
           t_0
           (if (<= yi 3.5000000934815034e-5)
             (+
              xi
              (*
               ux
               (fma
                maxCos
                zi
                (* ux (fma -1.0 (* maxCos zi) (* -0.5 (* (* maxCos maxCos) xi)))))))
             t_0))))
      float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
      	float t_0 = 1.0f * ((2.0f * (uy * ((float) M_PI))) * yi);
      	float tmp;
      	if (yi <= -4.99999991225835e-14f) {
      		tmp = t_0;
      	} else if (yi <= 3.5000000934815034e-5f) {
      		tmp = xi + (ux * fmaf(maxCos, zi, (ux * fmaf(-1.0f, (maxCos * zi), (-0.5f * ((maxCos * maxCos) * xi))))));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(xi, yi, zi, ux, uy, maxCos)
      	t_0 = Float32(Float32(1.0) * Float32(Float32(Float32(2.0) * Float32(uy * Float32(pi))) * yi))
      	tmp = Float32(0.0)
      	if (yi <= Float32(-4.99999991225835e-14))
      		tmp = t_0;
      	elseif (yi <= Float32(3.5000000934815034e-5))
      		tmp = Float32(xi + Float32(ux * fma(maxCos, zi, Float32(ux * fma(Float32(-1.0), Float32(maxCos * zi), Float32(Float32(-0.5) * Float32(Float32(maxCos * maxCos) * xi)))))));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := 1 \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\\
      \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\
      \;\;\;\;xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if yi < -4.99999991e-14 or 3.50000009e-5 < yi

        1. Initial program 98.7%

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

          \[\leadsto \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
        3. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
          2. lower-*.f32N/A

            \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
        4. Applied rewrites66.6%

          \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
        5. Taylor expanded in uy around 0

          \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
        6. Step-by-step derivation
          1. lower-*.f32N/A

            \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
          2. lower-*.f32N/A

            \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
          3. lift-PI.f3254.9

            \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
        7. Applied rewrites54.9%

          \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
        8. Taylor expanded in ux around 0

          \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]
        9. Step-by-step derivation
          1. Applied rewrites54.8%

            \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]

          if -4.99999991e-14 < yi < 3.50000009e-5

          1. Initial program 99.0%

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

            \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
          3. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
            2. *-commutativeN/A

              \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi + \color{blue}{maxCos} \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
            3. lower-fma.f32N/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)}, xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)} \]
          5. Taylor expanded in ux around 0

            \[\leadsto xi + \color{blue}{ux \cdot \left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right)} \]
          6. Step-by-step derivation
            1. lower-+.f32N/A

              \[\leadsto xi + ux \cdot \color{blue}{\left(maxCos \cdot zi + ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right)} \]
            2. lower-*.f32N/A

              \[\leadsto xi + ux \cdot \left(maxCos \cdot zi + \color{blue}{ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)}\right) \]
            3. lower-fma.f32N/A

              \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
            4. lower-*.f32N/A

              \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \left(-1 \cdot \left(maxCos \cdot zi\right) + \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
            5. lower-fma.f32N/A

              \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
            6. lift-*.f32N/A

              \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
            7. lower-*.f32N/A

              \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
            8. lower-*.f32N/A

              \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left({maxCos}^{2} \cdot xi\right)\right)\right) \]
            9. pow2N/A

              \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, \frac{-1}{2} \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right) \]
            10. lift-*.f3263.3

              \[\leadsto xi + ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right) \]
          7. Applied rewrites63.3%

            \[\leadsto xi + \color{blue}{ux \cdot \mathsf{fma}\left(maxCos, zi, ux \cdot \mathsf{fma}\left(-1, maxCos \cdot zi, -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot xi\right)\right)\right)} \]
        10. Recombined 2 regimes into one program.
        11. Add Preprocessing

        Alternative 12: 60.7% accurate, 10.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\\ \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\ \;\;\;\;xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (xi yi zi ux uy maxCos)
         :precision binary32
         (let* ((t_0 (* 1.0 (* (* 2.0 (* uy PI)) yi))))
           (if (<= yi -4.99999991225835e-14)
             t_0
             (if (<= yi 3.5000000934815034e-5)
               (+ xi (* maxCos (* ux (* zi (- 1.0 ux)))))
               t_0))))
        float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
        	float t_0 = 1.0f * ((2.0f * (uy * ((float) M_PI))) * yi);
        	float tmp;
        	if (yi <= -4.99999991225835e-14f) {
        		tmp = t_0;
        	} else if (yi <= 3.5000000934815034e-5f) {
        		tmp = xi + (maxCos * (ux * (zi * (1.0f - ux))));
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(xi, yi, zi, ux, uy, maxCos)
        	t_0 = Float32(Float32(1.0) * Float32(Float32(Float32(2.0) * Float32(uy * Float32(pi))) * yi))
        	tmp = Float32(0.0)
        	if (yi <= Float32(-4.99999991225835e-14))
        		tmp = t_0;
        	elseif (yi <= Float32(3.5000000934815034e-5))
        		tmp = Float32(xi + Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux)))));
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(xi, yi, zi, ux, uy, maxCos)
        	t_0 = single(1.0) * ((single(2.0) * (uy * single(pi))) * yi);
        	tmp = single(0.0);
        	if (yi <= single(-4.99999991225835e-14))
        		tmp = t_0;
        	elseif (yi <= single(3.5000000934815034e-5))
        		tmp = xi + (maxCos * (ux * (zi * (single(1.0) - ux))));
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := 1 \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\\
        \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\
        \;\;\;\;xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if yi < -4.99999991e-14 or 3.50000009e-5 < yi

          1. Initial program 98.7%

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

            \[\leadsto \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
            2. lower-*.f32N/A

              \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
          4. Applied rewrites66.6%

            \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
          5. Taylor expanded in uy around 0

            \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
          6. Step-by-step derivation
            1. lower-*.f32N/A

              \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
            2. lower-*.f32N/A

              \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
            3. lift-PI.f3254.9

              \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
          7. Applied rewrites54.9%

            \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
          8. Taylor expanded in ux around 0

            \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]
          9. Step-by-step derivation
            1. Applied rewrites54.8%

              \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]

            if -4.99999991e-14 < yi < 3.50000009e-5

            1. Initial program 99.0%

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

              \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
            3. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
              2. *-commutativeN/A

                \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi + \color{blue}{maxCos} \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
              3. lower-fma.f32N/A

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)}, xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)} \]
            5. Taylor expanded in maxCos around 0

              \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
            6. Step-by-step derivation
              1. lower-+.f32N/A

                \[\leadsto xi + maxCos \cdot \color{blue}{\left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
              2. lower-*.f32N/A

                \[\leadsto xi + maxCos \cdot \left(ux \cdot \color{blue}{\left(zi \cdot \left(1 - ux\right)\right)}\right) \]
              3. lower-*.f32N/A

                \[\leadsto xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \color{blue}{\left(1 - ux\right)}\right)\right) \]
              4. lower-*.f32N/A

                \[\leadsto xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - \color{blue}{ux}\right)\right)\right) \]
              5. lift--.f3263.3

                \[\leadsto xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
            7. Applied rewrites63.3%

              \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
          10. Recombined 2 regimes into one program.
          11. Add Preprocessing

          Alternative 13: 58.7% accurate, 10.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\\ \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\ \;\;\;\;xi + maxCos \cdot \left(ux \cdot zi\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (xi yi zi ux uy maxCos)
           :precision binary32
           (let* ((t_0 (* 1.0 (* (* 2.0 (* uy PI)) yi))))
             (if (<= yi -4.99999991225835e-14)
               t_0
               (if (<= yi 3.5000000934815034e-5) (+ xi (* maxCos (* ux zi))) t_0))))
          float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
          	float t_0 = 1.0f * ((2.0f * (uy * ((float) M_PI))) * yi);
          	float tmp;
          	if (yi <= -4.99999991225835e-14f) {
          		tmp = t_0;
          	} else if (yi <= 3.5000000934815034e-5f) {
          		tmp = xi + (maxCos * (ux * zi));
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          function code(xi, yi, zi, ux, uy, maxCos)
          	t_0 = Float32(Float32(1.0) * Float32(Float32(Float32(2.0) * Float32(uy * Float32(pi))) * yi))
          	tmp = Float32(0.0)
          	if (yi <= Float32(-4.99999991225835e-14))
          		tmp = t_0;
          	elseif (yi <= Float32(3.5000000934815034e-5))
          		tmp = Float32(xi + Float32(maxCos * Float32(ux * zi)));
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(xi, yi, zi, ux, uy, maxCos)
          	t_0 = single(1.0) * ((single(2.0) * (uy * single(pi))) * yi);
          	tmp = single(0.0);
          	if (yi <= single(-4.99999991225835e-14))
          		tmp = t_0;
          	elseif (yi <= single(3.5000000934815034e-5))
          		tmp = xi + (maxCos * (ux * zi));
          	else
          		tmp = t_0;
          	end
          	tmp_2 = tmp;
          end
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := 1 \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right)\\
          \mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;yi \leq 3.5000000934815034 \cdot 10^{-5}:\\
          \;\;\;\;xi + maxCos \cdot \left(ux \cdot zi\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if yi < -4.99999991e-14 or 3.50000009e-5 < yi

            1. Initial program 98.7%

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

              \[\leadsto \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
              2. lower-*.f32N/A

                \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \color{blue}{\left(yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \]
            4. Applied rewrites66.6%

              \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)} \]
            5. Taylor expanded in uy around 0

              \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
            6. Step-by-step derivation
              1. lower-*.f32N/A

                \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
              2. lower-*.f32N/A

                \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right) \]
              3. lift-PI.f3254.9

                \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
            7. Applied rewrites54.9%

              \[\leadsto \sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot yi\right) \]
            8. Taylor expanded in ux around 0

              \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]
            9. Step-by-step derivation
              1. Applied rewrites54.8%

                \[\leadsto 1 \cdot \left(\color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot yi\right) \]

              if -4.99999991e-14 < yi < 3.50000009e-5

              1. Initial program 99.0%

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

                \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
              3. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
                2. *-commutativeN/A

                  \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi + \color{blue}{maxCos} \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
                3. lower-fma.f32N/A

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)}, xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)} \]
              5. Taylor expanded in ux around 0

                \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot zi\right)} \]
              6. Step-by-step derivation
                1. lower-+.f32N/A

                  \[\leadsto xi + maxCos \cdot \color{blue}{\left(ux \cdot zi\right)} \]
                2. lower-*.f32N/A

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
                3. lower-*.f3260.4

                  \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
              7. Applied rewrites60.4%

                \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot zi\right)} \]
            10. Recombined 2 regimes into one program.
            11. Add Preprocessing

            Alternative 14: 49.8% accurate, 25.2× speedup?

            \[\begin{array}{l} \\ xi + maxCos \cdot \left(ux \cdot zi\right) \end{array} \]
            (FPCore (xi yi zi ux uy maxCos)
             :precision binary32
             (+ xi (* maxCos (* ux zi))))
            float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
            	return xi + (maxCos * (ux * zi));
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(4) function code(xi, yi, zi, ux, uy, maxcos)
            use fmin_fmax_functions
                real(4), intent (in) :: xi
                real(4), intent (in) :: yi
                real(4), intent (in) :: zi
                real(4), intent (in) :: ux
                real(4), intent (in) :: uy
                real(4), intent (in) :: maxcos
                code = xi + (maxcos * (ux * zi))
            end function
            
            function code(xi, yi, zi, ux, uy, maxCos)
            	return Float32(xi + Float32(maxCos * Float32(ux * zi)))
            end
            
            function tmp = code(xi, yi, zi, ux, uy, maxCos)
            	tmp = xi + (maxCos * (ux * zi));
            end
            
            \begin{array}{l}
            
            \\
            xi + maxCos \cdot \left(ux \cdot zi\right)
            \end{array}
            
            Derivation
            1. Initial program 98.9%

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

              \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
            3. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
              2. *-commutativeN/A

                \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi + \color{blue}{maxCos} \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
              3. lower-fma.f32N/A

                \[\leadsto \mathsf{fma}\left(\sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}, \color{blue}{xi}, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
            4. Applied rewrites52.0%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)}, xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)} \]
            5. Taylor expanded in ux around 0

              \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot zi\right)} \]
            6. Step-by-step derivation
              1. lower-+.f32N/A

                \[\leadsto xi + maxCos \cdot \color{blue}{\left(ux \cdot zi\right)} \]
              2. lower-*.f32N/A

                \[\leadsto xi + maxCos \cdot \left(ux \cdot \color{blue}{zi}\right) \]
              3. lower-*.f3249.8

                \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
            7. Applied rewrites49.8%

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

            Alternative 15: 45.6% accurate, 353.0× speedup?

            \[\begin{array}{l} \\ xi \end{array} \]
            (FPCore (xi yi zi ux uy maxCos) :precision binary32 xi)
            float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
            	return xi;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(4) function code(xi, yi, zi, ux, uy, maxcos)
            use fmin_fmax_functions
                real(4), intent (in) :: xi
                real(4), intent (in) :: yi
                real(4), intent (in) :: zi
                real(4), intent (in) :: ux
                real(4), intent (in) :: uy
                real(4), intent (in) :: maxcos
                code = xi
            end function
            
            function code(xi, yi, zi, ux, uy, maxCos)
            	return xi
            end
            
            function tmp = code(xi, yi, zi, ux, uy, maxCos)
            	tmp = xi;
            end
            
            \begin{array}{l}
            
            \\
            xi
            \end{array}
            
            Derivation
            1. Initial program 98.9%

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

              \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}} \]
            3. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto xi \cdot \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} + \color{blue}{maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)} \]
              2. *-commutativeN/A

                \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi + \color{blue}{maxCos} \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
              3. lower-fma.f32N/A

                \[\leadsto \mathsf{fma}\left(\sqrt{1 - {maxCos}^{2} \cdot \left({ux}^{2} \cdot {\left(1 - ux\right)}^{2}\right)}, \color{blue}{xi}, maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
            4. Applied rewrites52.0%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{1 - {\left(\left(1 - ux\right) \cdot ux\right)}^{2} \cdot \left(maxCos \cdot maxCos\right)}, xi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)} \]
            5. Taylor expanded in ux around 0

              \[\leadsto xi \]
            6. Step-by-step derivation
              1. Applied rewrites45.6%

                \[\leadsto xi \]
              2. Add Preprocessing

              Reproduce

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