UniformSampleCone 2

Percentage Accurate: 98.9% → 99.0%
Time: 11.4s
Alternatives: 21
Speedup: 1.0×

Specification

?
\[\left(\left(\left(\left(\left(-10000 \leq xi \land xi \leq 10000\right) \land \left(-10000 \leq yi \land yi \leq 10000\right)\right) \land \left(-10000 \leq zi \land zi \leq 10000\right)\right) \land \left(\frac{2328306437}{10000000000000000000} \leq ux \land ux \leq 1\right)\right) \land \left(\frac{2328306437}{10000000000000000000} \leq uy \land uy \leq 1\right)\right) \land \left(0 \leq maxCos \land maxCos \leq 1\right)\]
\[\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} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* (* (- 1 ux) maxCos) ux))
       (t_1 (sqrt (- 1 (* t_0 t_0))))
       (t_2 (* (* uy 2) 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}
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}

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 21 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} 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} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* (* (- 1 ux) maxCos) ux))
       (t_1 (sqrt (- 1 (* t_0 t_0))))
       (t_2 (* (* uy 2) 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}
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}

Alternative 1: 99.0% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\ t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\ \left(\left(\sin \left(uy \cdot \left(-2 \cdot \pi + \frac{1}{2} \cdot \frac{\pi}{uy}\right)\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* (* (- 1 ux) maxCos) ux))
       (t_1 (sqrt (- 1 (* t_0 t_0)))))
  (+
   (+
    (* (* (sin (* uy (+ (* -2 PI) (* 1/2 (/ PI uy))))) t_1) xi)
    (* (* (sin (* (* uy 2) PI)) 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)));
	return (((sinf((uy * ((-2.0f * ((float) M_PI)) + (0.5f * (((float) M_PI) / uy))))) * t_1) * xi) + ((sinf(((uy * 2.0f) * ((float) M_PI))) * 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)))
	return Float32(Float32(Float32(Float32(sin(Float32(uy * Float32(Float32(Float32(-2.0) * Float32(pi)) + Float32(Float32(0.5) * Float32(Float32(pi) / uy))))) * t_1) * xi) + Float32(Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * 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)));
	tmp = (((sin((uy * ((single(-2.0) * single(pi)) + (single(0.5) * (single(pi) / uy))))) * t_1) * xi) + ((sin(((uy * single(2.0)) * single(pi))) * t_1) * yi)) + (t_0 * zi);
end
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
\left(\left(\sin \left(uy \cdot \left(-2 \cdot \pi + \frac{1}{2} \cdot \frac{\pi}{uy}\right)\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\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. Step-by-step derivation
    1. lift-cos.f32N/A

      \[\leadsto \left(\left(\color{blue}{\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. cos-neg-revN/A

      \[\leadsto \left(\left(\color{blue}{\cos \left(\mathsf{neg}\left(\left(uy \cdot 2\right) \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. sin-+PI/2-revN/A

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

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

      \[\leadsto \left(\left(\sin \color{blue}{\left(\left(\mathsf{neg}\left(\left(uy \cdot 2\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    6. lift-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(uy \cdot 2\right) \cdot \pi}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    7. lift-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(uy \cdot 2\right)} \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    8. associate-*l*N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{uy \cdot \left(2 \cdot \pi\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    9. distribute-lft-neg-inN/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(2 \cdot \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    10. lower-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(2 \cdot \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    11. lower-neg.f32N/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(-uy\right)} \cdot \left(2 \cdot \pi\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    12. count-2-revN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \color{blue}{\left(\pi + \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    13. lower-+.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \color{blue}{\left(\pi + \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    14. lift-PI.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \frac{\color{blue}{\pi}}{2}\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 \]
    15. mult-flipN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \color{blue}{\pi \cdot \frac{1}{2}}\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 \]
    16. metadata-evalN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \pi \cdot \color{blue}{\frac{1}{2}}\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 \]
    17. lower-*.f3299.0%

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \color{blue}{\pi \cdot \frac{1}{2}}\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 \]
  3. Applied rewrites99.0%

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\sin \left(uy \cdot \left(-2 \cdot \pi + \frac{1}{2} \cdot \frac{\pi}{uy}\right)\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  6. Applied rewrites98.9%

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

Alternative 2: 98.9% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\ t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\ \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \pi \cdot \frac{1}{2}\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* (* (- 1 ux) maxCos) ux))
       (t_1 (sqrt (- 1 (* t_0 t_0)))))
  (+
   (+
    (* (* (sin (+ (* (- uy) (+ PI PI)) (* PI 1/2))) t_1) xi)
    (* (* (sin (* (* uy 2) PI)) 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)));
	return (((sinf(((-uy * (((float) M_PI) + ((float) M_PI))) + (((float) M_PI) * 0.5f))) * t_1) * xi) + ((sinf(((uy * 2.0f) * ((float) M_PI))) * 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)))
	return Float32(Float32(Float32(Float32(sin(Float32(Float32(Float32(-uy) * Float32(Float32(pi) + Float32(pi))) + Float32(Float32(pi) * Float32(0.5)))) * t_1) * xi) + Float32(Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * 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)));
	tmp = (((sin(((-uy * (single(pi) + single(pi))) + (single(pi) * single(0.5)))) * t_1) * xi) + ((sin(((uy * single(2.0)) * single(pi))) * t_1) * yi)) + (t_0 * zi);
end
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
\left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \pi \cdot \frac{1}{2}\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\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. Step-by-step derivation
    1. lift-cos.f32N/A

      \[\leadsto \left(\left(\color{blue}{\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. cos-neg-revN/A

      \[\leadsto \left(\left(\color{blue}{\cos \left(\mathsf{neg}\left(\left(uy \cdot 2\right) \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. sin-+PI/2-revN/A

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

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

      \[\leadsto \left(\left(\sin \color{blue}{\left(\left(\mathsf{neg}\left(\left(uy \cdot 2\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    6. lift-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(uy \cdot 2\right) \cdot \pi}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    7. lift-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(uy \cdot 2\right)} \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    8. associate-*l*N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{uy \cdot \left(2 \cdot \pi\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    9. distribute-lft-neg-inN/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(2 \cdot \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    10. lower-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(2 \cdot \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    11. lower-neg.f32N/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(-uy\right)} \cdot \left(2 \cdot \pi\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    12. count-2-revN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \color{blue}{\left(\pi + \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    13. lower-+.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \color{blue}{\left(\pi + \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    14. lift-PI.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \frac{\color{blue}{\pi}}{2}\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 \]
    15. mult-flipN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \color{blue}{\pi \cdot \frac{1}{2}}\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 \]
    16. metadata-evalN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \pi \cdot \color{blue}{\frac{1}{2}}\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 \]
    17. lower-*.f3299.0%

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \color{blue}{\pi \cdot \frac{1}{2}}\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 \]
  3. Applied rewrites99.0%

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

Alternative 3: 98.9% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \left(uy + uy\right) \cdot \pi\\ t_1 := \sqrt{1 - \left(\left(\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot maxCos\right) \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux}\\ \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot \left(maxCos \cdot ux\right) + \left(\cos t\_0 \cdot xi\right) \cdot t\_1\right) + \left(\sin t\_0 \cdot yi\right) \cdot t\_1 \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* (+ uy uy) PI))
       (t_1
        (sqrt
         (-
          1
          (*
           (* (* (* (* maxCos (- 1 ux)) maxCos) (- 1 ux)) ux)
           ux)))))
  (+
   (+ (* (* zi (- 1 ux)) (* maxCos ux)) (* (* (cos t_0) xi) t_1))
   (* (* (sin t_0) yi) t_1))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = (uy + uy) * ((float) M_PI);
	float t_1 = sqrtf((1.0f - (((((maxCos * (1.0f - ux)) * maxCos) * (1.0f - ux)) * ux) * ux)));
	return (((zi * (1.0f - ux)) * (maxCos * ux)) + ((cosf(t_0) * xi) * t_1)) + ((sinf(t_0) * yi) * t_1);
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(uy + uy) * Float32(pi))
	t_1 = sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(Float32(Float32(maxCos * Float32(Float32(1.0) - ux)) * maxCos) * Float32(Float32(1.0) - ux)) * ux) * ux)))
	return Float32(Float32(Float32(Float32(zi * Float32(Float32(1.0) - ux)) * Float32(maxCos * ux)) + Float32(Float32(cos(t_0) * xi) * t_1)) + Float32(Float32(sin(t_0) * yi) * t_1))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	t_0 = (uy + uy) * single(pi);
	t_1 = sqrt((single(1.0) - (((((maxCos * (single(1.0) - ux)) * maxCos) * (single(1.0) - ux)) * ux) * ux)));
	tmp = (((zi * (single(1.0) - ux)) * (maxCos * ux)) + ((cos(t_0) * xi) * t_1)) + ((sin(t_0) * yi) * t_1);
end
\begin{array}{l}
t_0 := \left(uy + uy\right) \cdot \pi\\
t_1 := \sqrt{1 - \left(\left(\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot maxCos\right) \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux}\\
\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot \left(maxCos \cdot ux\right) + \left(\cos t\_0 \cdot xi\right) \cdot t\_1\right) + \left(\sin t\_0 \cdot yi\right) \cdot t\_1
\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. Step-by-step derivation
    1. lift-cos.f32N/A

      \[\leadsto \left(\left(\color{blue}{\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. cos-neg-revN/A

      \[\leadsto \left(\left(\color{blue}{\cos \left(\mathsf{neg}\left(\left(uy \cdot 2\right) \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. sin-+PI/2-revN/A

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

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

      \[\leadsto \left(\left(\sin \color{blue}{\left(\left(\mathsf{neg}\left(\left(uy \cdot 2\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    6. lift-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(uy \cdot 2\right) \cdot \pi}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    7. lift-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(uy \cdot 2\right)} \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    8. associate-*l*N/A

      \[\leadsto \left(\left(\sin \left(\left(\mathsf{neg}\left(\color{blue}{uy \cdot \left(2 \cdot \pi\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    9. distribute-lft-neg-inN/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(2 \cdot \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    10. lower-*.f32N/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(2 \cdot \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    11. lower-neg.f32N/A

      \[\leadsto \left(\left(\sin \left(\color{blue}{\left(-uy\right)} \cdot \left(2 \cdot \pi\right) + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    12. count-2-revN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \color{blue}{\left(\pi + \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    13. lower-+.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \color{blue}{\left(\pi + \pi\right)} + \frac{\mathsf{PI}\left(\right)}{2}\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 \]
    14. lift-PI.f32N/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \frac{\color{blue}{\pi}}{2}\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 \]
    15. mult-flipN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \color{blue}{\pi \cdot \frac{1}{2}}\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 \]
    16. metadata-evalN/A

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \pi \cdot \color{blue}{\frac{1}{2}}\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 \]
    17. lower-*.f3299.0%

      \[\leadsto \left(\left(\sin \left(\left(-uy\right) \cdot \left(\pi + \pi\right) + \color{blue}{\pi \cdot \frac{1}{2}}\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 \]
  3. Applied rewrites99.0%

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

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

Alternative 4: 98.9% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \pi \cdot \left(uy + uy\right)\\ t_1 := maxCos \cdot \left(1 - ux\right)\\ t_2 := t\_1 \cdot ux\\ t_3 := \sqrt{1 - \left(t\_2 \cdot ux\right) \cdot t\_1}\\ \left(zi \cdot t\_2 + \left(xi \cdot t\_3\right) \cdot \cos t\_0\right) + \left(yi \cdot t\_3\right) \cdot \sin t\_0 \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* PI (+ uy uy)))
       (t_1 (* maxCos (- 1 ux)))
       (t_2 (* t_1 ux))
       (t_3 (sqrt (- 1 (* (* t_2 ux) t_1)))))
  (+
   (+ (* zi t_2) (* (* xi t_3) (cos t_0)))
   (* (* yi t_3) (sin t_0)))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = ((float) M_PI) * (uy + uy);
	float t_1 = maxCos * (1.0f - ux);
	float t_2 = t_1 * ux;
	float t_3 = sqrtf((1.0f - ((t_2 * ux) * t_1)));
	return ((zi * t_2) + ((xi * t_3) * cosf(t_0))) + ((yi * t_3) * sinf(t_0));
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(pi) * Float32(uy + uy))
	t_1 = Float32(maxCos * Float32(Float32(1.0) - ux))
	t_2 = Float32(t_1 * ux)
	t_3 = sqrt(Float32(Float32(1.0) - Float32(Float32(t_2 * ux) * t_1)))
	return Float32(Float32(Float32(zi * t_2) + Float32(Float32(xi * t_3) * cos(t_0))) + Float32(Float32(yi * t_3) * sin(t_0)))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	t_0 = single(pi) * (uy + uy);
	t_1 = maxCos * (single(1.0) - ux);
	t_2 = t_1 * ux;
	t_3 = sqrt((single(1.0) - ((t_2 * ux) * t_1)));
	tmp = ((zi * t_2) + ((xi * t_3) * cos(t_0))) + ((yi * t_3) * sin(t_0));
end
\begin{array}{l}
t_0 := \pi \cdot \left(uy + uy\right)\\
t_1 := maxCos \cdot \left(1 - ux\right)\\
t_2 := t\_1 \cdot ux\\
t_3 := \sqrt{1 - \left(t\_2 \cdot ux\right) \cdot t\_1}\\
\left(zi \cdot t\_2 + \left(xi \cdot t\_3\right) \cdot \cos t\_0\right) + \left(yi \cdot t\_3\right) \cdot \sin t\_0
\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. Step-by-step derivation
    1. lift-+.f32N/A

      \[\leadsto \color{blue}{\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. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi + \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)} \]
    3. lift-+.f32N/A

      \[\leadsto \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi + \color{blue}{\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)} \]
  3. Applied rewrites98.9%

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

Alternative 5: 98.8% accurate, 1.2× speedup?

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

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

      \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\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. lower-*.f32N/A

      \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\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 \]
    4. lower-PI.f3298.8%

      \[\leadsto \left(\cos \left(2 \cdot \left(uy \cdot \pi\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.8%

    \[\leadsto \left(\color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\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 6: 98.8% accurate, 1.4× speedup?

\[\begin{array}{l} t_0 := \left(uy + uy\right) \cdot \pi\\ \left(\sin t\_0 \cdot yi + \cos t\_0 \cdot xi\right) - \left(\left(zi \cdot ux\right) \cdot \left(ux - 1\right)\right) \cdot maxCos \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* (+ uy uy) PI)))
  (-
   (+ (* (sin t_0) yi) (* (cos t_0) xi))
   (* (* (* zi ux) (- ux 1)) maxCos))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = (uy + uy) * ((float) M_PI);
	return ((sinf(t_0) * yi) + (cosf(t_0) * xi)) - (((zi * ux) * (ux - 1.0f)) * maxCos);
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(uy + uy) * Float32(pi))
	return Float32(Float32(Float32(sin(t_0) * yi) + Float32(cos(t_0) * xi)) - Float32(Float32(Float32(zi * ux) * Float32(ux - Float32(1.0))) * maxCos))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	t_0 = (uy + uy) * single(pi);
	tmp = ((sin(t_0) * yi) + (cos(t_0) * xi)) - (((zi * ux) * (ux - single(1.0))) * maxCos);
end
\begin{array}{l}
t_0 := \left(uy + uy\right) \cdot \pi\\
\left(\sin t\_0 \cdot yi + \cos t\_0 \cdot xi\right) - \left(\left(zi \cdot ux\right) \cdot \left(ux - 1\right)\right) \cdot maxCos
\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-+.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
    2. lower-*.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
    3. lower-*.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

      \[\leadsto 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) \]
    5. lower--.f32N/A

      \[\leadsto 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) \]
    6. lower-+.f32N/A

      \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
  4. Applied rewrites98.8%

    \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
  5. Applied rewrites98.8%

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

Alternative 7: 95.7% accurate, 1.4× speedup?

\[\begin{array}{l} t_0 := \left(uy + uy\right) \cdot \pi\\ \left(\sin \left(\pi \cdot \frac{1}{2} - t\_0\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin t\_0 \cdot yi \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* (+ uy uy) PI)))
  (+
   (+ (* (sin (- (* PI 1/2) t_0)) xi) (* (* zi ux) maxCos))
   (* (sin t_0) yi))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = (uy + uy) * ((float) M_PI);
	return ((sinf(((((float) M_PI) * 0.5f) - t_0)) * xi) + ((zi * ux) * maxCos)) + (sinf(t_0) * yi);
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(uy + uy) * Float32(pi))
	return Float32(Float32(Float32(sin(Float32(Float32(Float32(pi) * Float32(0.5)) - t_0)) * xi) + Float32(Float32(zi * ux) * maxCos)) + Float32(sin(t_0) * yi))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	t_0 = (uy + uy) * single(pi);
	tmp = ((sin(((single(pi) * single(0.5)) - t_0)) * xi) + ((zi * ux) * maxCos)) + (sin(t_0) * yi);
end
\begin{array}{l}
t_0 := \left(uy + uy\right) \cdot \pi\\
\left(\sin \left(\pi \cdot \frac{1}{2} - t\_0\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin t\_0 \cdot yi
\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-+.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
    2. lower-*.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
    3. lower-*.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}\right) \]
    3. associate-+r+N/A

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

      \[\leadsto \left(maxCos \cdot \left(ux \cdot zi\right) + xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  6. Applied rewrites95.7%

    \[\leadsto \left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \color{blue}{\sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi} \]
  7. Step-by-step derivation
    1. lift-cos.f32N/A

      \[\leadsto \left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\color{blue}{\left(uy + uy\right)} \cdot \pi\right) \cdot yi \]
    2. cos-neg-revN/A

      \[\leadsto \left(\cos \left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\color{blue}{\left(uy + uy\right)} \cdot \pi\right) \cdot yi \]
    3. lift-*.f32N/A

      \[\leadsto \left(\cos \left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    4. lift-+.f32N/A

      \[\leadsto \left(\cos \left(\mathsf{neg}\left(\left(uy + uy\right) \cdot \pi\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    5. count-2N/A

      \[\leadsto \left(\cos \left(\mathsf{neg}\left(\left(2 \cdot uy\right) \cdot \pi\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    6. associate-*r*N/A

      \[\leadsto \left(\cos \left(\mathsf{neg}\left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    7. lift-*.f32N/A

      \[\leadsto \left(\cos \left(\mathsf{neg}\left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    8. distribute-rgt-neg-inN/A

      \[\leadsto \left(\cos \left(2 \cdot \left(\mathsf{neg}\left(uy \cdot \pi\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(\color{blue}{uy} + uy\right) \cdot \pi\right) \cdot yi \]
    9. lift-*.f32N/A

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

      \[\leadsto \left(\cos \left(2 \cdot \left(\mathsf{neg}\left(\pi \cdot uy\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    11. distribute-rgt-neg-outN/A

      \[\leadsto \left(\cos \left(2 \cdot \left(\pi \cdot \left(\mathsf{neg}\left(uy\right)\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    12. count-2N/A

      \[\leadsto \left(\cos \left(\pi \cdot \left(\mathsf{neg}\left(uy\right)\right) + \pi \cdot \left(\mathsf{neg}\left(uy\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(\color{blue}{uy} + uy\right) \cdot \pi\right) \cdot yi \]
    13. distribute-rgt-inN/A

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

      \[\leadsto \left(\cos \left(\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(\mathsf{PI}\left(\right) + \pi\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    15. lift-PI.f32N/A

      \[\leadsto \left(\cos \left(\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi \]
    16. sin-+PI/2-revN/A

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

      \[\leadsto \left(\sin \left(\left(\mathsf{neg}\left(uy\right)\right) \cdot \left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\color{blue}{\left(uy + uy\right)} \cdot \pi\right) \cdot yi \]
    18. +-commutativeN/A

      \[\leadsto \left(\sin \left(\frac{\mathsf{PI}\left(\right)}{2} + \left(\mathsf{neg}\left(uy\right)\right) \cdot \left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(\color{blue}{uy} + uy\right) \cdot \pi\right) \cdot yi \]
    19. fp-cancel-sub-signN/A

      \[\leadsto \left(\sin \left(\frac{\mathsf{PI}\left(\right)}{2} - uy \cdot \left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\left(\color{blue}{uy} + uy\right) \cdot \pi\right) \cdot yi \]
  8. Applied rewrites95.7%

    \[\leadsto \left(\sin \left(\pi \cdot \frac{1}{2} - \left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin \left(\color{blue}{\left(uy + uy\right)} \cdot \pi\right) \cdot yi \]
  9. Add Preprocessing

Alternative 8: 95.7% accurate, 1.5× speedup?

\[\begin{array}{l} t_0 := \left(uy + uy\right) \cdot \pi\\ \left(\cos t\_0 \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin t\_0 \cdot yi \end{array} \]
(FPCore (xi yi zi ux uy maxCos)
  :precision binary32
  (let* ((t_0 (* (+ uy uy) PI)))
  (+ (+ (* (cos t_0) xi) (* (* zi ux) maxCos)) (* (sin t_0) yi))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
	float t_0 = (uy + uy) * ((float) M_PI);
	return ((cosf(t_0) * xi) + ((zi * ux) * maxCos)) + (sinf(t_0) * yi);
}
function code(xi, yi, zi, ux, uy, maxCos)
	t_0 = Float32(Float32(uy + uy) * Float32(pi))
	return Float32(Float32(Float32(cos(t_0) * xi) + Float32(Float32(zi * ux) * maxCos)) + Float32(sin(t_0) * yi))
end
function tmp = code(xi, yi, zi, ux, uy, maxCos)
	t_0 = (uy + uy) * single(pi);
	tmp = ((cos(t_0) * xi) + ((zi * ux) * maxCos)) + (sin(t_0) * yi);
end
\begin{array}{l}
t_0 := \left(uy + uy\right) \cdot \pi\\
\left(\cos t\_0 \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \sin t\_0 \cdot yi
\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-+.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
    2. lower-*.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
    3. lower-*.f32N/A

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

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

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

      \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}\right) \]
    3. associate-+r+N/A

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

      \[\leadsto \left(maxCos \cdot \left(ux \cdot zi\right) + xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  6. Applied rewrites95.7%

    \[\leadsto \left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \color{blue}{\sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi} \]
  7. Add Preprocessing

Alternative 9: 89.6% accurate, 1.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{2} \cdot \frac{xi}{uy \cdot \left(yi \cdot \pi\right)}\right) \cdot \left(\left(yi \cdot \sqrt{1 - \left(\left(t\_0 \cdot ux\right) \cdot ux\right) \cdot t\_0}\right) \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\


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

    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

        \[\leadsto 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) \]
      5. lower--.f32N/A

        \[\leadsto 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) \]
      6. lower-+.f32N/A

        \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
    4. Applied rewrites98.8%

      \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

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

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

    if 0.0141399996 < uy

    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. Step-by-step derivation
      1. lift-+.f32N/A

        \[\leadsto \color{blue}{\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. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi + \left(\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\right)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      3. sum-to-multN/A

        \[\leadsto \color{blue}{\left(1 + \frac{\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) \cdot \left(\left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      4. lower-unsound-*.f32N/A

        \[\leadsto \color{blue}{\left(1 + \frac{\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) \cdot \left(\left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. Applied rewrites96.8%

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

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

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

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

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

        \[\leadsto \left(1 + \frac{1}{2} \cdot \frac{xi}{uy \cdot \left(yi \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}\right) \cdot \left(\left(yi \cdot \sqrt{1 - \left(\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux\right) \cdot \left(maxCos \cdot \left(1 - ux\right)\right)}\right) \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      5. lower-PI.f3285.3%

        \[\leadsto \left(1 + \frac{1}{2} \cdot \frac{xi}{uy \cdot \left(yi \cdot \pi\right)}\right) \cdot \left(\left(yi \cdot \sqrt{1 - \left(\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux\right) \cdot \left(maxCos \cdot \left(1 - ux\right)\right)}\right) \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    6. Applied rewrites85.3%

      \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \frac{xi}{uy \cdot \left(yi \cdot \pi\right)}}\right) \cdot \left(\left(yi \cdot \sqrt{1 - \left(\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux\right) \cdot \left(maxCos \cdot \left(1 - ux\right)\right)}\right) \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 87.6% accurate, 1.8× speedup?

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

\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\left(yi \cdot \sqrt{1 - \left(\left(t\_0 \cdot ux\right) \cdot ux\right) \cdot t\_0}\right) \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\


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

    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

        \[\leadsto 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) \]
      5. lower--.f32N/A

        \[\leadsto 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) \]
      6. lower-+.f32N/A

        \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
    4. Applied rewrites98.8%

      \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

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

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

    if 0.0141399996 < uy

    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. Step-by-step derivation
      1. lift-+.f32N/A

        \[\leadsto \color{blue}{\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. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi + \left(\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\right)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      3. sum-to-multN/A

        \[\leadsto \color{blue}{\left(1 + \frac{\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) \cdot \left(\left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
      4. lower-unsound-*.f32N/A

        \[\leadsto \color{blue}{\left(1 + \frac{\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) \cdot \left(\left(\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right)}\right) \cdot yi\right)} + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    3. Applied rewrites96.8%

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

      \[\leadsto \color{blue}{1} \cdot \left(\left(yi \cdot \sqrt{1 - \left(\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux\right) \cdot \left(maxCos \cdot \left(1 - ux\right)\right)}\right) \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    5. Step-by-step derivation
      1. Applied rewrites43.4%

        \[\leadsto \color{blue}{1} \cdot \left(\left(yi \cdot \sqrt{1 - \left(\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux\right) \cdot \left(maxCos \cdot \left(1 - ux\right)\right)}\right) \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi \]
    6. Recombined 2 regimes into one program.
    7. Add Preprocessing

    Alternative 11: 87.5% accurate, 2.1× speedup?

    \[\begin{array}{l} t_0 := maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\\ \mathbf{if}\;uy \leq \frac{15182709}{1073741824}:\\ \;\;\;\;xi + \left(t\_0 + uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\pi}^{2}\right)\right) + 2 \cdot \left(yi \cdot \pi\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \end{array} \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (let* ((t_0 (* maxCos (* ux (* zi (- 1 ux))))))
      (if (<= uy 15182709/1073741824)
        (+
         xi
         (+
          t_0
          (* uy (+ (* -2 (* uy (* xi (pow PI 2)))) (* 2 (* yi PI))))))
        (+ t_0 (* yi (sin (* 2 (* uy PI))))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	float t_0 = maxCos * (ux * (zi * (1.0f - ux)));
    	float tmp;
    	if (uy <= 0.014139999635517597f) {
    		tmp = xi + (t_0 + (uy * ((-2.0f * (uy * (xi * powf(((float) M_PI), 2.0f)))) + (2.0f * (yi * ((float) M_PI))))));
    	} else {
    		tmp = t_0 + (yi * sinf((2.0f * (uy * ((float) M_PI)))));
    	}
    	return tmp;
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	t_0 = Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))))
    	tmp = Float32(0.0)
    	if (uy <= Float32(0.014139999635517597))
    		tmp = Float32(xi + Float32(t_0 + Float32(uy * Float32(Float32(Float32(-2.0) * Float32(uy * Float32(xi * (Float32(pi) ^ Float32(2.0))))) + Float32(Float32(2.0) * Float32(yi * Float32(pi)))))));
    	else
    		tmp = Float32(t_0 + Float32(yi * sin(Float32(Float32(2.0) * Float32(uy * Float32(pi))))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(xi, yi, zi, ux, uy, maxCos)
    	t_0 = maxCos * (ux * (zi * (single(1.0) - ux)));
    	tmp = single(0.0);
    	if (uy <= single(0.014139999635517597))
    		tmp = xi + (t_0 + (uy * ((single(-2.0) * (uy * (xi * (single(pi) ^ single(2.0))))) + (single(2.0) * (yi * single(pi))))));
    	else
    		tmp = t_0 + (yi * sin((single(2.0) * (uy * single(pi)))));
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    t_0 := maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\\
    \mathbf{if}\;uy \leq \frac{15182709}{1073741824}:\\
    \;\;\;\;xi + \left(t\_0 + uy \cdot \left(-2 \cdot \left(uy \cdot \left(xi \cdot {\pi}^{2}\right)\right) + 2 \cdot \left(yi \cdot \pi\right)\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0 + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if uy < 0.0141399996

      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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
        2. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
        3. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

          \[\leadsto 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) \]
        5. lower--.f32N/A

          \[\leadsto 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) \]
        6. lower-+.f32N/A

          \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      4. Applied rewrites98.8%

        \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      5. Taylor expanded in uy around 0

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

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

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

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

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

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

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

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

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

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

      if 0.0141399996 < uy

      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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
        2. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
        3. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

          \[\leadsto 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) \]
        5. lower--.f32N/A

          \[\leadsto 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) \]
        6. lower-+.f32N/A

          \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      4. Applied rewrites98.8%

        \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      5. Taylor expanded in xi around 0

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

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

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

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

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

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

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

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

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

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
        10. lower-PI.f3243.3%

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
      7. Applied rewrites43.3%

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 12: 85.9% accurate, 2.3× speedup?

    \[\begin{array}{l} \mathbf{if}\;uy \leq \frac{8589935}{268435456}:\\ \;\;\;\;\left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \end{array} \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (if (<= uy 8589935/268435456)
      (+
       (+ (* (cos (* (+ uy uy) PI)) xi) (* (* zi ux) maxCos))
       (* 2 (* uy (* yi PI))))
      (+ (* maxCos (* ux (* zi (- 1 ux)))) (* yi (sin (* 2 (* uy PI)))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	float tmp;
    	if (uy <= 0.03200000151991844f) {
    		tmp = ((cosf(((uy + uy) * ((float) M_PI))) * xi) + ((zi * ux) * maxCos)) + (2.0f * (uy * (yi * ((float) M_PI))));
    	} else {
    		tmp = (maxCos * (ux * (zi * (1.0f - ux)))) + (yi * sinf((2.0f * (uy * ((float) M_PI)))));
    	}
    	return tmp;
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	tmp = Float32(0.0)
    	if (uy <= Float32(0.03200000151991844))
    		tmp = Float32(Float32(Float32(cos(Float32(Float32(uy + uy) * Float32(pi))) * xi) + Float32(Float32(zi * ux) * maxCos)) + Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi)))));
    	else
    		tmp = Float32(Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux)))) + Float32(yi * sin(Float32(Float32(2.0) * Float32(uy * Float32(pi))))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(xi, yi, zi, ux, uy, maxCos)
    	tmp = single(0.0);
    	if (uy <= single(0.03200000151991844))
    		tmp = ((cos(((uy + uy) * single(pi))) * xi) + ((zi * ux) * maxCos)) + (single(2.0) * (uy * (yi * single(pi))));
    	else
    		tmp = (maxCos * (ux * (zi * (single(1.0) - ux)))) + (yi * sin((single(2.0) * (uy * single(pi)))));
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    \mathbf{if}\;uy \leq \frac{8589935}{268435456}:\\
    \;\;\;\;\left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if uy < 0.0320000015

      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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
        2. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
        3. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

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

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

          \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)}\right) \]
        3. associate-+r+N/A

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

          \[\leadsto \left(maxCos \cdot \left(ux \cdot zi\right) + xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
      6. Applied rewrites95.7%

        \[\leadsto \left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + \color{blue}{\sin \left(\left(uy + uy\right) \cdot \pi\right) \cdot yi} \]
      7. Taylor expanded in uy around 0

        \[\leadsto \left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + 2 \cdot \color{blue}{\left(uy \cdot \left(yi \cdot \pi\right)\right)} \]
      8. Step-by-step derivation
        1. lower-*.f32N/A

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

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

          \[\leadsto \left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right) \]
        4. lower-PI.f3287.6%

          \[\leadsto \left(\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot xi + \left(zi \cdot ux\right) \cdot maxCos\right) + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) \]
      9. Applied rewrites87.6%

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

      if 0.0320000015 < uy

      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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
        2. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
        3. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

          \[\leadsto 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) \]
        5. lower--.f32N/A

          \[\leadsto 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) \]
        6. lower-+.f32N/A

          \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      4. Applied rewrites98.8%

        \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      5. Taylor expanded in xi around 0

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

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

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

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

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

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

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

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

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

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
        10. lower-PI.f3243.3%

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
      7. Applied rewrites43.3%

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 13: 84.8% accurate, 2.5× speedup?

    \[\begin{array}{l} t_0 := maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\\ \mathbf{if}\;uy \leq \frac{15182709}{1073741824}:\\ \;\;\;\;xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \end{array} \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (let* ((t_0 (* maxCos (* ux (* zi (- 1 ux))))))
      (if (<= uy 15182709/1073741824)
        (+ xi (+ (* 2 (* uy (* yi PI))) t_0))
        (+ t_0 (* yi (sin (* 2 (* uy PI))))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	float t_0 = maxCos * (ux * (zi * (1.0f - ux)));
    	float tmp;
    	if (uy <= 0.014139999635517597f) {
    		tmp = xi + ((2.0f * (uy * (yi * ((float) M_PI)))) + t_0);
    	} else {
    		tmp = t_0 + (yi * sinf((2.0f * (uy * ((float) M_PI)))));
    	}
    	return tmp;
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	t_0 = Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))))
    	tmp = Float32(0.0)
    	if (uy <= Float32(0.014139999635517597))
    		tmp = Float32(xi + Float32(Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi)))) + t_0));
    	else
    		tmp = Float32(t_0 + Float32(yi * sin(Float32(Float32(2.0) * Float32(uy * Float32(pi))))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(xi, yi, zi, ux, uy, maxCos)
    	t_0 = maxCos * (ux * (zi * (single(1.0) - ux)));
    	tmp = single(0.0);
    	if (uy <= single(0.014139999635517597))
    		tmp = xi + ((single(2.0) * (uy * (yi * single(pi)))) + t_0);
    	else
    		tmp = t_0 + (yi * sin((single(2.0) * (uy * single(pi)))));
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    t_0 := maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\\
    \mathbf{if}\;uy \leq \frac{15182709}{1073741824}:\\
    \;\;\;\;xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + t\_0\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0 + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if uy < 0.0141399996

      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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
        2. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
        3. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

          \[\leadsto 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) \]
        5. lower--.f32N/A

          \[\leadsto 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) \]
        6. lower-+.f32N/A

          \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      4. Applied rewrites98.8%

        \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      5. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
        7. lower-*.f32N/A

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

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

          \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - \color{blue}{ux}\right)\right)\right)\right) \]
        10. lower--.f3282.0%

          \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
      7. Applied rewrites82.0%

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

      if 0.0141399996 < uy

      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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
        2. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
        3. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

          \[\leadsto 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) \]
        5. lower--.f32N/A

          \[\leadsto 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) \]
        6. lower-+.f32N/A

          \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      4. Applied rewrites98.8%

        \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      5. Taylor expanded in xi around 0

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

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

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

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

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

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

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

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

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

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
        10. lower-PI.f3243.3%

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
      7. Applied rewrites43.3%

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 14: 84.4% accurate, 2.6× speedup?

    \[\begin{array}{l} \mathbf{if}\;uy \leq \frac{15182709}{1073741824}:\\ \;\;\;\;xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \end{array} \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (if (<= uy 15182709/1073741824)
      (+ xi (+ (* 2 (* uy (* yi PI))) (* maxCos (* ux (* zi (- 1 ux))))))
      (+ (* maxCos (* ux zi)) (* yi (sin (* 2 (* uy PI)))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	float tmp;
    	if (uy <= 0.014139999635517597f) {
    		tmp = xi + ((2.0f * (uy * (yi * ((float) M_PI)))) + (maxCos * (ux * (zi * (1.0f - ux)))));
    	} else {
    		tmp = (maxCos * (ux * zi)) + (yi * sinf((2.0f * (uy * ((float) M_PI)))));
    	}
    	return tmp;
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	tmp = Float32(0.0)
    	if (uy <= Float32(0.014139999635517597))
    		tmp = Float32(xi + Float32(Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi)))) + Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))))));
    	else
    		tmp = Float32(Float32(maxCos * Float32(ux * zi)) + Float32(yi * sin(Float32(Float32(2.0) * Float32(uy * Float32(pi))))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(xi, yi, zi, ux, uy, maxCos)
    	tmp = single(0.0);
    	if (uy <= single(0.014139999635517597))
    		tmp = xi + ((single(2.0) * (uy * (yi * single(pi)))) + (maxCos * (ux * (zi * (single(1.0) - ux)))));
    	else
    		tmp = (maxCos * (ux * zi)) + (yi * sin((single(2.0) * (uy * single(pi)))));
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    \mathbf{if}\;uy \leq \frac{15182709}{1073741824}:\\
    \;\;\;\;xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if uy < 0.0141399996

      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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
        2. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
        3. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

          \[\leadsto 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) \]
        5. lower--.f32N/A

          \[\leadsto 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) \]
        6. lower-+.f32N/A

          \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
      4. Applied rewrites98.8%

        \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      5. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
        7. lower-*.f32N/A

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

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

          \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - \color{blue}{ux}\right)\right)\right)\right) \]
        10. lower--.f3282.0%

          \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
      7. Applied rewrites82.0%

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

      if 0.0141399996 < uy

      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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-+.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
        2. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
        3. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

        \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
      5. Taylor expanded in xi around 0

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

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

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

          \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
        4. lower-*.f32N/A

          \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
        5. lower-PI.f3241.3%

          \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
      7. Applied rewrites41.3%

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + yi \cdot \color{blue}{\sin \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 15: 82.0% accurate, 8.8× speedup?

    \[xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (+ xi (+ (* 2 (* uy (* yi PI))) (* maxCos (* ux (* zi (- 1 ux)))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	return xi + ((2.0f * (uy * (yi * ((float) M_PI)))) + (maxCos * (ux * (zi * (1.0f - ux)))));
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	return Float32(xi + Float32(Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi)))) + Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))))))
    end
    
    function tmp = code(xi, yi, zi, ux, uy, maxCos)
    	tmp = xi + ((single(2.0) * (uy * (yi * single(pi)))) + (maxCos * (ux * (zi * (single(1.0) - ux)))));
    end
    
    xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)
    
    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

        \[\leadsto 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) \]
      5. lower--.f32N/A

        \[\leadsto 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) \]
      6. lower-+.f32N/A

        \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
    4. Applied rewrites98.8%

      \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy around 0

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

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

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

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

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

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

        \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
      7. lower-*.f32N/A

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

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

        \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - \color{blue}{ux}\right)\right)\right)\right) \]
      10. lower--.f3282.0%

        \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right) \]
    7. Applied rewrites82.0%

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

    Alternative 16: 79.2% accurate, 11.0× speedup?

    \[maxCos \cdot \left(ux \cdot zi\right) + \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right) \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (+ (* maxCos (* ux zi)) (+ xi (* 2 (* uy (* yi PI))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	return (maxCos * (ux * zi)) + (xi + (2.0f * (uy * (yi * ((float) M_PI)))));
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	return Float32(Float32(maxCos * Float32(ux * zi)) + Float32(xi + Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi))))))
    end
    
    function tmp = code(xi, yi, zi, ux, uy, maxCos)
    	tmp = (maxCos * (ux * zi)) + (xi + (single(2.0) * (uy * (yi * single(pi)))));
    end
    
    maxCos \cdot \left(ux \cdot zi\right) + \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right)
    
    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy around 0

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

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

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

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

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
      5. lower-PI.f3279.2%

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right) \]
    7. Applied rewrites79.2%

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

    Alternative 17: 79.2% accurate, 11.0× speedup?

    \[xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right) \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (+ xi (+ (* 2 (* uy (* yi PI))) (* maxCos (* ux zi)))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	return xi + ((2.0f * (uy * (yi * ((float) M_PI)))) + (maxCos * (ux * zi)));
    }
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	return Float32(xi + Float32(Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi)))) + Float32(maxCos * Float32(ux * zi))))
    end
    
    function tmp = code(xi, yi, zi, ux, uy, maxCos)
    	tmp = xi + ((single(2.0) * (uy * (yi * single(pi)))) + (maxCos * (ux * zi)));
    end
    
    xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right)
    
    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy 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-*.f3250.4%

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

      \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot zi\right)} \]
    8. Taylor expanded in xi around 0

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

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
      2. lower-*.f3212.0%

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
    10. Applied rewrites12.0%

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

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

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

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

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

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

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

        \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right) \]
      7. lower-*.f32N/A

        \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot \color{blue}{zi}\right)\right) \]
      8. lower-*.f3279.2%

        \[\leadsto xi + \left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right) \]
    13. Applied rewrites79.2%

      \[\leadsto xi + \color{blue}{\left(2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right) + maxCos \cdot \left(ux \cdot zi\right)\right)} \]
    14. Add Preprocessing

    Alternative 18: 52.5% accurate, 16.0× speedup?

    \[xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (+ xi (* maxCos (* ux (* zi (- 1 ux))))))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	return xi + (maxCos * (ux * (zi * (1.0f - ux))));
    }
    
    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 * (1.0e0 - ux))))
    end function
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	return Float32(xi + Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux)))))
    end
    
    function tmp = code(xi, yi, zi, ux, uy, maxCos)
    	tmp = xi + (maxCos * (ux * (zi * (single(1.0) - ux))));
    end
    
    xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)
    
    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right) + \left(xi \cdot \color{blue}{\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. lower-*.f32N/A

        \[\leadsto 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) \]
      5. lower--.f32N/A

        \[\leadsto 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) \]
      6. lower-+.f32N/A

        \[\leadsto 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) + \color{blue}{yi \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \]
    4. Applied rewrites98.8%

      \[\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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy 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. lower--.f3252.5%

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

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

    Alternative 19: 50.4% accurate, 25.2× speedup?

    \[xi + \left(maxCos \cdot zi\right) \cdot ux \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (+ xi (* (* maxCos zi) ux)))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	return xi + ((maxCos * zi) * ux);
    }
    
    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 * zi) * ux)
    end function
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	return Float32(xi + Float32(Float32(maxCos * zi) * ux))
    end
    
    function tmp = code(xi, yi, zi, ux, uy, maxCos)
    	tmp = xi + ((maxCos * zi) * ux);
    end
    
    xi + \left(maxCos \cdot zi\right) \cdot ux
    
    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy 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-*.f3250.4%

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

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

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

        \[\leadsto xi + maxCos \cdot \left(ux \cdot zi\right) \]
      3. *-commutativeN/A

        \[\leadsto xi + maxCos \cdot \left(zi \cdot ux\right) \]
      4. associate-*r*N/A

        \[\leadsto xi + \left(maxCos \cdot zi\right) \cdot ux \]
      5. lower-*.f32N/A

        \[\leadsto xi + \left(maxCos \cdot zi\right) \cdot ux \]
      6. lower-*.f3250.4%

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

      \[\leadsto xi + \left(maxCos \cdot zi\right) \cdot ux \]
    10. Add Preprocessing

    Alternative 20: 50.4% accurate, 25.2× speedup?

    \[xi + maxCos \cdot \left(ux \cdot zi\right) \]
    (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
    
    xi + maxCos \cdot \left(ux \cdot zi\right)
    
    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy 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-*.f3250.4%

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

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

    Alternative 21: 12.0% accurate, 32.1× speedup?

    \[maxCos \cdot \left(ux \cdot zi\right) \]
    (FPCore (xi yi zi ux uy maxCos)
      :precision binary32
      (* maxCos (* ux zi)))
    float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
    	return maxCos * (ux * zi);
    }
    
    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 = maxcos * (ux * zi)
    end function
    
    function code(xi, yi, zi, ux, uy, maxCos)
    	return Float32(maxCos * Float32(ux * zi))
    end
    
    function tmp = code(xi, yi, zi, ux, uy, maxCos)
    	tmp = maxCos * (ux * zi);
    end
    
    maxCos \cdot \left(ux \cdot zi\right)
    
    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 \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \color{blue}{\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)} \]
      2. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\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) \]
      3. lower-*.f32N/A

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \color{blue}{\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. lower-+.f32N/A

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

      \[\leadsto \color{blue}{maxCos \cdot \left(ux \cdot zi\right) + \left(xi \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) + yi \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right)} \]
    5. Taylor expanded in uy 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-*.f3250.4%

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

      \[\leadsto xi + \color{blue}{maxCos \cdot \left(ux \cdot zi\right)} \]
    8. Taylor expanded in xi around 0

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

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
      2. lower-*.f3212.0%

        \[\leadsto maxCos \cdot \left(ux \cdot zi\right) \]
    10. Applied rewrites12.0%

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

    Reproduce

    ?
    herbie shell --seed 2025271 -o generate:evaluate
    (FPCore (xi yi zi ux uy maxCos)
      :name "UniformSampleCone 2"
      :precision binary32
      :pre (and (and (and (and (and (and (<= -10000 xi) (<= xi 10000)) (and (<= -10000 yi) (<= yi 10000))) (and (<= -10000 zi) (<= zi 10000))) (and (<= 2328306437/10000000000000000000 ux) (<= ux 1))) (and (<= 2328306437/10000000000000000000 uy) (<= uy 1))) (and (<= 0 maxCos) (<= maxCos 1)))
      (+ (+ (* (* (cos (* (* uy 2) PI)) (sqrt (- 1 (* (* (* (- 1 ux) maxCos) ux) (* (* (- 1 ux) maxCos) ux))))) xi) (* (* (sin (* (* uy 2) PI)) (sqrt (- 1 (* (* (* (- 1 ux) maxCos) ux) (* (* (- 1 ux) maxCos) ux))))) yi)) (* (* (* (- 1 ux) maxCos) ux) zi)))