UniformSampleCone, y

Percentage Accurate: 57.9% → 98.2%
Time: 15.0s
Alternatives: 18
Speedup: 2.0×

Specification

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

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 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: 57.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Alternative 1: 98.2% accurate, 0.4× speedup?

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

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

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around inf 98.2%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\frac{\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos}{ux}}} \]
  5. Step-by-step derivation
    1. associate--l+98.2%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\color{blue}{\left(-1 \cdot ux\right) \cdot {\left(maxCos - 1\right)}^{2}} - 2 \cdot maxCos\right)}{ux}} \]
    3. neg-mul-198.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\color{blue}{\left(-ux\right)} \cdot {\left(maxCos - 1\right)}^{2} - 2 \cdot maxCos\right)}{ux}} \]
    4. sub-neg98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\left(-ux\right) \cdot {\color{blue}{\left(maxCos + \left(-1\right)\right)}}^{2} - 2 \cdot maxCos\right)}{ux}} \]
    5. metadata-eval98.2%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\frac{2 + \left(\left(-ux\right) \cdot {\left(maxCos + -1\right)}^{2} - 2 \cdot maxCos\right)}{ux}}} \]
  7. Step-by-step derivation
    1. associate-*r/98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\frac{{ux}^{2} \cdot \left(2 + \left(\left(-ux\right) \cdot {\left(maxCos + -1\right)}^{2} - 2 \cdot maxCos\right)\right)}{ux}}} \]
    2. cancel-sign-sub-inv98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\frac{{ux}^{2} \cdot \left(2 + \color{blue}{\left(\left(-ux\right) \cdot {\left(maxCos + -1\right)}^{2} + \left(-2\right) \cdot maxCos\right)}\right)}{ux}} \]
    3. fma-define98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\frac{{ux}^{2} \cdot \left(2 + \color{blue}{\mathsf{fma}\left(-ux, {\left(maxCos + -1\right)}^{2}, \left(-2\right) \cdot maxCos\right)}\right)}{ux}} \]
    4. metadata-eval98.2%

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\frac{{ux}^{2} \cdot \left(2 + \mathsf{fma}\left(-ux, {\left(maxCos + -1\right)}^{2}, maxCos \cdot -2\right)\right)}{ux}} \]
  10. Add Preprocessing

Alternative 2: 98.2% accurate, 0.7× speedup?

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

\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\frac{\left(2 + ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right) - maxCos}{ux} - \frac{maxCos}{ux}\right)}
\end{array}
Derivation
  1. Initial program 58.1%

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

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. sub-neg58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
    3. +-commutative58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
    5. fma-define58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
  3. Simplified58.2%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in ux around inf 98.1%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 \cdot \frac{maxCos - 1}{ux} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)}} \]
  6. Step-by-step derivation
    1. add-exp-log97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-1 \cdot \frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    2. mul-1-neg97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \color{blue}{\left(-\frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    3. sub-neg97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{\color{blue}{maxCos + \left(-1\right)}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    4. metadata-eval97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{maxCos + \color{blue}{-1}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
  7. Applied egg-rr97.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-\frac{maxCos + -1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
  8. Taylor expanded in ux around 0 98.2%

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

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

Alternative 3: 98.2% accurate, 0.7× speedup?

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

\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\frac{{ux}^{2} \cdot \left(2 + \left(maxCos \cdot \left(\left(2 \cdot ux - ux \cdot maxCos\right) - 2\right) - ux\right)\right)}{ux}}
\end{array}
Derivation
  1. Initial program 58.1%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around inf 98.2%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\frac{\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos}{ux}}} \]
  5. Step-by-step derivation
    1. associate--l+98.2%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\color{blue}{\left(-1 \cdot ux\right) \cdot {\left(maxCos - 1\right)}^{2}} - 2 \cdot maxCos\right)}{ux}} \]
    3. neg-mul-198.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\color{blue}{\left(-ux\right)} \cdot {\left(maxCos - 1\right)}^{2} - 2 \cdot maxCos\right)}{ux}} \]
    4. sub-neg98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\left(-ux\right) \cdot {\color{blue}{\left(maxCos + \left(-1\right)\right)}}^{2} - 2 \cdot maxCos\right)}{ux}} \]
    5. metadata-eval98.2%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\frac{2 + \left(\left(-ux\right) \cdot {\left(maxCos + -1\right)}^{2} - 2 \cdot maxCos\right)}{ux}}} \]
  7. Step-by-step derivation
    1. associate-*r/98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\frac{{ux}^{2} \cdot \left(2 + \left(\left(-ux\right) \cdot {\left(maxCos + -1\right)}^{2} - 2 \cdot maxCos\right)\right)}{ux}}} \]
    2. cancel-sign-sub-inv98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\frac{{ux}^{2} \cdot \left(2 + \color{blue}{\left(\left(-ux\right) \cdot {\left(maxCos + -1\right)}^{2} + \left(-2\right) \cdot maxCos\right)}\right)}{ux}} \]
    3. fma-define98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\frac{{ux}^{2} \cdot \left(2 + \color{blue}{\mathsf{fma}\left(-ux, {\left(maxCos + -1\right)}^{2}, \left(-2\right) \cdot maxCos\right)}\right)}{ux}} \]
    4. metadata-eval98.2%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\frac{{ux}^{2} \cdot \left(2 + \mathsf{fma}\left(-ux, {\left(maxCos + -1\right)}^{2}, -2 \cdot maxCos\right)\right)}{ux}}} \]
  9. Taylor expanded in maxCos around 0 98.2%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\frac{{ux}^{2} \cdot \left(2 + \left(maxCos \cdot \left(\left(2 \cdot ux - ux \cdot maxCos\right) - 2\right) - ux\right)\right)}{ux}} \]
  11. Add Preprocessing

Alternative 4: 98.3% accurate, 0.7× speedup?

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

\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - \left(2 \cdot maxCos + ux \cdot {\left(maxCos + -1\right)}^{2}\right)\right)}
\end{array}
Derivation
  1. Initial program 58.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
  4. Step-by-step derivation
    1. associate--l+98.2%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + \left(\color{blue}{\left(-1 \cdot ux\right) \cdot {\left(maxCos - 1\right)}^{2}} - 2 \cdot maxCos\right)\right)} \]
    3. mul-1-neg98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + \left(\color{blue}{\left(-ux\right)} \cdot {\left(maxCos - 1\right)}^{2} - 2 \cdot maxCos\right)\right)} \]
    4. sub-neg98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + \left(\left(-ux\right) \cdot {\color{blue}{\left(maxCos + \left(-1\right)\right)}}^{2} - 2 \cdot maxCos\right)\right)} \]
    5. metadata-eval98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + \left(\left(-ux\right) \cdot {\left(maxCos + \color{blue}{-1}\right)}^{2} - 2 \cdot maxCos\right)\right)} \]
    6. +-commutative98.2%

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + \left(\left(-ux\right) \cdot {\color{blue}{\left(-1 + maxCos\right)}}^{2} - 2 \cdot maxCos\right)\right)} \]
  5. Simplified98.2%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - \left(2 \cdot maxCos + ux \cdot {\left(maxCos + -1\right)}^{2}\right)\right)} \]
  7. Add Preprocessing

Alternative 5: 95.5% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 + \frac{2}{ux}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 0.00170000002

    1. Initial program 57.8%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in ux around inf 98.5%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \color{blue}{\frac{\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos}{ux}}} \]
    5. Step-by-step derivation
      1. associate--l+98.5%

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\color{blue}{\left(-1 \cdot ux\right) \cdot {\left(maxCos - 1\right)}^{2}} - 2 \cdot maxCos\right)}{ux}} \]
      3. neg-mul-198.5%

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\color{blue}{\left(-ux\right)} \cdot {\left(maxCos - 1\right)}^{2} - 2 \cdot maxCos\right)}{ux}} \]
      4. sub-neg98.5%

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{{ux}^{2} \cdot \frac{2 + \left(\left(-ux\right) \cdot {\color{blue}{\left(maxCos + \left(-1\right)\right)}}^{2} - 2 \cdot maxCos\right)}{ux}} \]
      5. metadata-eval98.5%

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

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

      \[\leadsto \color{blue}{2 \cdot \left(\sqrt{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)} \]
    8. Step-by-step derivation
      1. associate--l+97.0%

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

        \[\leadsto 2 \cdot \left(\sqrt{ux \cdot \left(2 + \left(\color{blue}{\left(-1 \cdot ux\right) \cdot {\left(maxCos - 1\right)}^{2}} - 2 \cdot maxCos\right)\right)} \cdot \left(uy \cdot \pi\right)\right) \]
      3. neg-mul-197.0%

        \[\leadsto 2 \cdot \left(\sqrt{ux \cdot \left(2 + \left(\color{blue}{\left(-ux\right)} \cdot {\left(maxCos - 1\right)}^{2} - 2 \cdot maxCos\right)\right)} \cdot \left(uy \cdot \pi\right)\right) \]
      4. sub-neg97.0%

        \[\leadsto 2 \cdot \left(\sqrt{ux \cdot \left(2 + \left(\left(-ux\right) \cdot {\color{blue}{\left(maxCos + \left(-1\right)\right)}}^{2} - 2 \cdot maxCos\right)\right)} \cdot \left(uy \cdot \pi\right)\right) \]
      5. metadata-eval97.0%

        \[\leadsto 2 \cdot \left(\sqrt{ux \cdot \left(2 + \left(\left(-ux\right) \cdot {\left(maxCos + \color{blue}{-1}\right)}^{2} - 2 \cdot maxCos\right)\right)} \cdot \left(uy \cdot \pi\right)\right) \]
      6. +-commutative97.0%

        \[\leadsto 2 \cdot \left(\sqrt{ux \cdot \left(2 + \left(\left(-ux\right) \cdot {\color{blue}{\left(-1 + maxCos\right)}}^{2} - 2 \cdot maxCos\right)\right)} \cdot \left(uy \cdot \pi\right)\right) \]
    9. Simplified97.0%

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

    if 0.00170000002 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 58.6%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in ux around inf 97.6%

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

      \[\leadsto \color{blue}{\left(ux \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{2 \cdot \frac{1}{ux} - 1}} \]
    5. Step-by-step derivation
      1. associate-*l*95.3%

        \[\leadsto \color{blue}{ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{2 \cdot \frac{1}{ux} - 1}\right)} \]
      2. sub-neg95.3%

        \[\leadsto ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{2 \cdot \frac{1}{ux} + \left(-1\right)}}\right) \]
      3. associate-*r/95.3%

        \[\leadsto ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\frac{2 \cdot 1}{ux}} + \left(-1\right)}\right) \]
      4. metadata-eval95.3%

        \[\leadsto ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\frac{\color{blue}{2}}{ux} + \left(-1\right)}\right) \]
      5. metadata-eval95.3%

        \[\leadsto ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\frac{2}{ux} + \color{blue}{-1}}\right) \]
    6. Simplified95.3%

      \[\leadsto \color{blue}{ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\frac{2}{ux} + -1}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.0017000000225380063:\\ \;\;\;\;2 \cdot \left(\sqrt{ux \cdot \left(2 - \left(2 \cdot maxCos + ux \cdot {\left(maxCos + -1\right)}^{2}\right)\right)} \cdot \left(uy \cdot \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 + \frac{2}{ux}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 98.3% accurate, 1.0× speedup?

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

\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + \left(1 + \left(1 - maxCos\right)\right)\right) - maxCos\right)}
\end{array}
Derivation
  1. Initial program 58.1%

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

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. sub-neg58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
    3. +-commutative58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
    5. fma-define58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
  3. Simplified58.2%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in ux around inf 98.1%

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

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(1 + \left(-1 \cdot \left(maxCos - 1\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right)\right) - maxCos\right)}} \]
  7. Step-by-step derivation
    1. associate-+r+98.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{\left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right)} - maxCos\right)} \]
    2. sub-neg98.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(\left(1 + -1 \cdot \color{blue}{\left(maxCos + \left(-1\right)\right)}\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right) - maxCos\right)} \]
    3. metadata-eval98.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(\left(1 + -1 \cdot \left(maxCos + \color{blue}{-1}\right)\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right) - maxCos\right)} \]
    4. mul-1-neg98.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(\left(1 + \color{blue}{\left(-\left(maxCos + -1\right)\right)}\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right) - maxCos\right)} \]
    5. unsub-neg98.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(\color{blue}{\left(1 - \left(maxCos + -1\right)\right)} + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right) - maxCos\right)} \]
    6. sub-neg98.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(\left(1 - \left(maxCos + -1\right)\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \color{blue}{\left(maxCos + \left(-1\right)\right)}\right)\right) - maxCos\right)} \]
    7. metadata-eval98.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(\left(1 - \left(maxCos + -1\right)\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + \color{blue}{-1}\right)\right)\right) - maxCos\right)} \]
  8. Simplified98.2%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(\left(1 - \left(maxCos + -1\right)\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\right) - maxCos\right)}} \]
  9. Final simplification98.2%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + \left(1 + \left(1 - maxCos\right)\right)\right) - maxCos\right)} \]
  10. Add Preprocessing

Alternative 7: 98.3% accurate, 1.0× speedup?

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

\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(2 + ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right) - 2 \cdot maxCos\right)}
\end{array}
Derivation
  1. Initial program 58.1%

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

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. sub-neg58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
    3. +-commutative58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
    5. fma-define58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
  3. Simplified58.2%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in ux around inf 98.1%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 \cdot \frac{maxCos - 1}{ux} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)}} \]
  6. Step-by-step derivation
    1. add-exp-log97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-1 \cdot \frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    2. mul-1-neg97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \color{blue}{\left(-\frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    3. sub-neg97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{\color{blue}{maxCos + \left(-1\right)}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    4. metadata-eval97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{maxCos + \color{blue}{-1}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
  7. Applied egg-rr97.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-\frac{maxCos + -1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
  8. Taylor expanded in ux around 0 98.2%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)\right) - 2 \cdot maxCos\right)}} \]
  9. Final simplification98.2%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(2 + ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right) - 2 \cdot maxCos\right)} \]
  10. Add Preprocessing

Alternative 8: 95.4% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 + \frac{2}{ux}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 0.00170000002

    1. Initial program 57.8%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg57.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative57.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in57.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define57.9%

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

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ux around inf 98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 \cdot \frac{maxCos - 1}{ux} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)}} \]
    6. Step-by-step derivation
      1. add-exp-log97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-1 \cdot \frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      2. mul-1-neg97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \color{blue}{\left(-\frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      3. sub-neg97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{\color{blue}{maxCos + \left(-1\right)}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      4. metadata-eval97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{maxCos + \color{blue}{-1}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    7. Applied egg-rr97.7%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-\frac{maxCos + -1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    8. Taylor expanded in uy around 0 96.9%

      \[\leadsto \color{blue}{2 \cdot \left(\left(ux \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}\right)} \]
    9. Step-by-step derivation
      1. associate-*r*96.9%

        \[\leadsto \color{blue}{\left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}} \]
      2. +-commutative96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + 2 \cdot \frac{1}{ux}\right)} - 2 \cdot \frac{maxCos}{ux}} \]
      3. associate--l+96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(2 \cdot \frac{1}{ux} - 2 \cdot \frac{maxCos}{ux}\right)}} \]
      4. associate-*r/96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\color{blue}{\frac{2 \cdot 1}{ux}} - 2 \cdot \frac{maxCos}{ux}\right)} \]
      5. metadata-eval96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{\color{blue}{2}}{ux} - 2 \cdot \frac{maxCos}{ux}\right)} \]
      6. associate-*r/96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{2}{ux} - \color{blue}{\frac{2 \cdot maxCos}{ux}}\right)} \]
      7. div-sub96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \color{blue}{\frac{2 - 2 \cdot maxCos}{ux}}} \]
      8. *-commutative96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos - 1\right) \cdot \left(1 - maxCos\right)} + \frac{2 - 2 \cdot maxCos}{ux}} \]
      9. sub-neg96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos + \left(-1\right)\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
      10. metadata-eval96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(maxCos + \color{blue}{-1}\right) \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
      11. +-commutative96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(-1 + maxCos\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
    10. Simplified96.9%

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

    if 0.00170000002 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 58.6%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in ux around inf 97.6%

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

      \[\leadsto \color{blue}{\left(ux \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{2 \cdot \frac{1}{ux} - 1}} \]
    5. Step-by-step derivation
      1. associate-*l*95.3%

        \[\leadsto \color{blue}{ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{2 \cdot \frac{1}{ux} - 1}\right)} \]
      2. sub-neg95.3%

        \[\leadsto ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{2 \cdot \frac{1}{ux} + \left(-1\right)}}\right) \]
      3. associate-*r/95.3%

        \[\leadsto ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\frac{2 \cdot 1}{ux}} + \left(-1\right)}\right) \]
      4. metadata-eval95.3%

        \[\leadsto ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\frac{\color{blue}{2}}{ux} + \left(-1\right)}\right) \]
      5. metadata-eval95.3%

        \[\leadsto ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\frac{2}{ux} + \color{blue}{-1}}\right) \]
    6. Simplified95.3%

      \[\leadsto \color{blue}{ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\frac{2}{ux} + -1}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.4%

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

Alternative 9: 95.4% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 0.00170000002

    1. Initial program 57.8%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg57.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative57.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in57.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define57.9%

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

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ux around inf 98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 \cdot \frac{maxCos - 1}{ux} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)}} \]
    6. Step-by-step derivation
      1. add-exp-log97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-1 \cdot \frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      2. mul-1-neg97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \color{blue}{\left(-\frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      3. sub-neg97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{\color{blue}{maxCos + \left(-1\right)}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      4. metadata-eval97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{maxCos + \color{blue}{-1}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    7. Applied egg-rr97.7%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-\frac{maxCos + -1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    8. Taylor expanded in uy around 0 96.9%

      \[\leadsto \color{blue}{2 \cdot \left(\left(ux \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}\right)} \]
    9. Step-by-step derivation
      1. associate-*r*96.9%

        \[\leadsto \color{blue}{\left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}} \]
      2. +-commutative96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + 2 \cdot \frac{1}{ux}\right)} - 2 \cdot \frac{maxCos}{ux}} \]
      3. associate--l+96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(2 \cdot \frac{1}{ux} - 2 \cdot \frac{maxCos}{ux}\right)}} \]
      4. associate-*r/96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\color{blue}{\frac{2 \cdot 1}{ux}} - 2 \cdot \frac{maxCos}{ux}\right)} \]
      5. metadata-eval96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{\color{blue}{2}}{ux} - 2 \cdot \frac{maxCos}{ux}\right)} \]
      6. associate-*r/96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{2}{ux} - \color{blue}{\frac{2 \cdot maxCos}{ux}}\right)} \]
      7. div-sub96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \color{blue}{\frac{2 - 2 \cdot maxCos}{ux}}} \]
      8. *-commutative96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos - 1\right) \cdot \left(1 - maxCos\right)} + \frac{2 - 2 \cdot maxCos}{ux}} \]
      9. sub-neg96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos + \left(-1\right)\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
      10. metadata-eval96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(maxCos + \color{blue}{-1}\right) \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
      11. +-commutative96.9%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(-1 + maxCos\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
    10. Simplified96.9%

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

    if 0.00170000002 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 58.6%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg58.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative58.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in58.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define58.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
    3. Simplified58.6%

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

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + -1 \cdot \left(\left(1 + -1 \cdot ux\right) \cdot \left(1 - ux\right)\right)}} \]
    6. Taylor expanded in ux around 0 95.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 + -1 \cdot ux\right)}} \]
    7. Step-by-step derivation
      1. neg-mul-195.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(-ux\right)}\right)} \]
      2. unsub-neg95.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
    8. Simplified95.2%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.3%

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

Alternative 10: 89.4% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - maxCos\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 0.00800000038

    1. Initial program 58.5%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg58.5%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative58.5%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in58.5%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define58.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
    3. Simplified58.7%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ux around inf 98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 \cdot \frac{maxCos - 1}{ux} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)}} \]
    6. Step-by-step derivation
      1. add-exp-log97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-1 \cdot \frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      2. mul-1-neg97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \color{blue}{\left(-\frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      3. sub-neg97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{\color{blue}{maxCos + \left(-1\right)}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      4. metadata-eval97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{maxCos + \color{blue}{-1}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    7. Applied egg-rr97.7%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-\frac{maxCos + -1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    8. Taylor expanded in uy around 0 95.5%

      \[\leadsto \color{blue}{2 \cdot \left(\left(ux \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}\right)} \]
    9. Step-by-step derivation
      1. associate-*r*95.5%

        \[\leadsto \color{blue}{\left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}} \]
      2. +-commutative95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + 2 \cdot \frac{1}{ux}\right)} - 2 \cdot \frac{maxCos}{ux}} \]
      3. associate--l+95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(2 \cdot \frac{1}{ux} - 2 \cdot \frac{maxCos}{ux}\right)}} \]
      4. associate-*r/95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\color{blue}{\frac{2 \cdot 1}{ux}} - 2 \cdot \frac{maxCos}{ux}\right)} \]
      5. metadata-eval95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{\color{blue}{2}}{ux} - 2 \cdot \frac{maxCos}{ux}\right)} \]
      6. associate-*r/95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{2}{ux} - \color{blue}{\frac{2 \cdot maxCos}{ux}}\right)} \]
      7. div-sub95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \color{blue}{\frac{2 - 2 \cdot maxCos}{ux}}} \]
      8. *-commutative95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos - 1\right) \cdot \left(1 - maxCos\right)} + \frac{2 - 2 \cdot maxCos}{ux}} \]
      9. sub-neg95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos + \left(-1\right)\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
      10. metadata-eval95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(maxCos + \color{blue}{-1}\right) \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
      11. +-commutative95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(-1 + maxCos\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
    10. Simplified95.5%

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

    if 0.00800000038 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 56.8%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg56.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative56.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in56.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define56.9%

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

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ux around inf 97.4%

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

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)}} \]
    7. Step-by-step derivation
      1. sub-neg77.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \color{blue}{\left(maxCos + \left(-1\right)\right)}\right) - maxCos\right)} \]
      2. metadata-eval77.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos + \color{blue}{-1}\right)\right) - maxCos\right)} \]
      3. distribute-lft-in77.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(-1 \cdot maxCos + -1 \cdot -1\right)}\right) - maxCos\right)} \]
      4. metadata-eval77.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(-1 \cdot maxCos + \color{blue}{1}\right)\right) - maxCos\right)} \]
      5. +-commutative77.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 + -1 \cdot maxCos\right)}\right) - maxCos\right)} \]
      6. mul-1-neg77.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) - maxCos\right)} \]
      7. sub-neg77.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 - maxCos\right)}\right) - maxCos\right)} \]
    8. Simplified77.7%

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

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\color{blue}{2} - maxCos\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.9%

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

Alternative 11: 89.3% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{2 \cdot ux}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 uy #s(literal 2 binary32)) < 0.00800000038

    1. Initial program 58.5%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg58.5%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative58.5%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in58.5%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define58.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
    3. Simplified58.7%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ux around inf 98.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 \cdot \frac{maxCos - 1}{ux} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)}} \]
    6. Step-by-step derivation
      1. add-exp-log97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-1 \cdot \frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      2. mul-1-neg97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \color{blue}{\left(-\frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      3. sub-neg97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{\color{blue}{maxCos + \left(-1\right)}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
      4. metadata-eval97.7%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{maxCos + \color{blue}{-1}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    7. Applied egg-rr97.7%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-\frac{maxCos + -1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    8. Taylor expanded in uy around 0 95.5%

      \[\leadsto \color{blue}{2 \cdot \left(\left(ux \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}\right)} \]
    9. Step-by-step derivation
      1. associate-*r*95.5%

        \[\leadsto \color{blue}{\left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}} \]
      2. +-commutative95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + 2 \cdot \frac{1}{ux}\right)} - 2 \cdot \frac{maxCos}{ux}} \]
      3. associate--l+95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(2 \cdot \frac{1}{ux} - 2 \cdot \frac{maxCos}{ux}\right)}} \]
      4. associate-*r/95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\color{blue}{\frac{2 \cdot 1}{ux}} - 2 \cdot \frac{maxCos}{ux}\right)} \]
      5. metadata-eval95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{\color{blue}{2}}{ux} - 2 \cdot \frac{maxCos}{ux}\right)} \]
      6. associate-*r/95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{2}{ux} - \color{blue}{\frac{2 \cdot maxCos}{ux}}\right)} \]
      7. div-sub95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \color{blue}{\frac{2 - 2 \cdot maxCos}{ux}}} \]
      8. *-commutative95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos - 1\right) \cdot \left(1 - maxCos\right)} + \frac{2 - 2 \cdot maxCos}{ux}} \]
      9. sub-neg95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos + \left(-1\right)\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
      10. metadata-eval95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(maxCos + \color{blue}{-1}\right) \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
      11. +-commutative95.5%

        \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(-1 + maxCos\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
    10. Simplified95.5%

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

    if 0.00800000038 < (*.f32 uy #s(literal 2 binary32))

    1. Initial program 56.8%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg56.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative56.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in56.8%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define56.9%

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

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

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + -1 \cdot \left(\left(1 + -1 \cdot ux\right) \cdot \left(1 - ux\right)\right)}} \]
    6. Taylor expanded in ux around 0 75.8%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{2 \cdot ux}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.9%

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

Alternative 12: 76.4% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 36.1%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg36.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative36.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in36.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define36.3%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
    3. Simplified36.3%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ux around inf 98.0%

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

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)}} \]
    7. Step-by-step derivation
      1. sub-neg92.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \color{blue}{\left(maxCos + \left(-1\right)\right)}\right) - maxCos\right)} \]
      2. metadata-eval92.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos + \color{blue}{-1}\right)\right) - maxCos\right)} \]
      3. distribute-lft-in92.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(-1 \cdot maxCos + -1 \cdot -1\right)}\right) - maxCos\right)} \]
      4. metadata-eval92.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(-1 \cdot maxCos + \color{blue}{1}\right)\right) - maxCos\right)} \]
      5. +-commutative92.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 + -1 \cdot maxCos\right)}\right) - maxCos\right)} \]
      6. mul-1-neg92.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) - maxCos\right)} \]
      7. sub-neg92.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 - maxCos\right)}\right) - maxCos\right)} \]
    8. Simplified92.1%

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
    10. Step-by-step derivation
      1. associate-*r*75.5%

        \[\leadsto \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
    11. Simplified75.5%

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

    if 1.19999997e-4 < ux

    1. Initial program 89.1%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg89.1%

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

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in89.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define89.1%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
    3. Simplified89.3%

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

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + -1 \cdot \left(\left(1 + ux \cdot \left(maxCos - 1\right)\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}\right)} \]
    6. Simplified76.1%

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(-\left(1 + ux \cdot \left(-1 + maxCos\right)\right) \cdot \left(1 + \left(ux \cdot maxCos - ux\right)\right)\right)}\right)} \]
    7. Taylor expanded in uy around 0 76.1%

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

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

Alternative 13: 75.1% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 40.2%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg40.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative40.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in40.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define40.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
    3. Simplified40.2%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ux around inf 97.9%

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

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)}} \]
    7. Step-by-step derivation
      1. sub-neg89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \color{blue}{\left(maxCos + \left(-1\right)\right)}\right) - maxCos\right)} \]
      2. metadata-eval89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos + \color{blue}{-1}\right)\right) - maxCos\right)} \]
      3. distribute-lft-in89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(-1 \cdot maxCos + -1 \cdot -1\right)}\right) - maxCos\right)} \]
      4. metadata-eval89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(-1 \cdot maxCos + \color{blue}{1}\right)\right) - maxCos\right)} \]
      5. +-commutative89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 + -1 \cdot maxCos\right)}\right) - maxCos\right)} \]
      6. mul-1-neg89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) - maxCos\right)} \]
      7. sub-neg89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 - maxCos\right)}\right) - maxCos\right)} \]
    8. Simplified89.9%

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
    10. Step-by-step derivation
      1. associate-*r*74.2%

        \[\leadsto \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
    11. Simplified74.2%

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

    if 4.19999997e-4 < ux

    1. Initial program 91.6%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg91.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative91.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in91.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define91.8%

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

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

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + -1 \cdot \left(\left(1 + ux \cdot \left(maxCos - 1\right)\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}\right)} \]
    6. Simplified78.1%

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(-\left(1 + ux \cdot \left(-1 + maxCos\right)\right) \cdot \left(1 + \left(ux \cdot maxCos - ux\right)\right)\right)}\right)} \]
    7. Taylor expanded in maxCos around 0 74.9%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(-\left(1 + \color{blue}{-1 \cdot ux}\right) \cdot \left(1 + \left(ux \cdot maxCos - ux\right)\right)\right)}\right) \]
    8. Step-by-step derivation
      1. neg-mul-174.9%

        \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(-\left(1 + \color{blue}{\left(-ux\right)}\right) \cdot \left(1 + \left(ux \cdot maxCos - ux\right)\right)\right)}\right) \]
    9. Simplified74.9%

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

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

Alternative 14: 81.0% accurate, 1.8× speedup?

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

\\
\left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}}
\end{array}
Derivation
  1. Initial program 58.1%

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

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. sub-neg58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
    3. +-commutative58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
    5. fma-define58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
  3. Simplified58.2%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in ux around inf 98.1%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 \cdot \frac{maxCos - 1}{ux} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)}} \]
  6. Step-by-step derivation
    1. add-exp-log97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-1 \cdot \frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    2. mul-1-neg97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \color{blue}{\left(-\frac{maxCos - 1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    3. sub-neg97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{\color{blue}{maxCos + \left(-1\right)}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
    4. metadata-eval97.4%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(e^{\log \left(-\frac{maxCos + \color{blue}{-1}}{ux}\right)} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
  7. Applied egg-rr97.4%

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(\color{blue}{e^{\log \left(-\frac{maxCos + -1}{ux}\right)}} + \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \frac{1}{ux}\right)\right) - \frac{maxCos}{ux}\right)} \]
  8. Taylor expanded in uy around 0 80.4%

    \[\leadsto \color{blue}{2 \cdot \left(\left(ux \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}\right)} \]
  9. Step-by-step derivation
    1. associate-*r*80.4%

      \[\leadsto \color{blue}{\left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(2 \cdot \frac{1}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right) - 2 \cdot \frac{maxCos}{ux}}} \]
    2. +-commutative80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + 2 \cdot \frac{1}{ux}\right)} - 2 \cdot \frac{maxCos}{ux}} \]
    3. associate--l+80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(2 \cdot \frac{1}{ux} - 2 \cdot \frac{maxCos}{ux}\right)}} \]
    4. associate-*r/80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\color{blue}{\frac{2 \cdot 1}{ux}} - 2 \cdot \frac{maxCos}{ux}\right)} \]
    5. metadata-eval80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{\color{blue}{2}}{ux} - 2 \cdot \frac{maxCos}{ux}\right)} \]
    6. associate-*r/80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \left(\frac{2}{ux} - \color{blue}{\frac{2 \cdot maxCos}{ux}}\right)} \]
    7. div-sub80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) + \color{blue}{\frac{2 - 2 \cdot maxCos}{ux}}} \]
    8. *-commutative80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos - 1\right) \cdot \left(1 - maxCos\right)} + \frac{2 - 2 \cdot maxCos}{ux}} \]
    9. sub-neg80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(maxCos + \left(-1\right)\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
    10. metadata-eval80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(maxCos + \color{blue}{-1}\right) \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
    11. +-commutative80.4%

      \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\color{blue}{\left(-1 + maxCos\right)} \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
  10. Simplified80.4%

    \[\leadsto \color{blue}{\left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(-1 + maxCos\right) \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}}} \]
  11. Final simplification80.4%

    \[\leadsto \left(2 \cdot \left(ux \cdot \left(uy \cdot \pi\right)\right)\right) \cdot \sqrt{\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{2 - 2 \cdot maxCos}{ux}} \]
  12. Add Preprocessing

Alternative 15: 75.0% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 40.2%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg40.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative40.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in40.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define40.2%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
    3. Simplified40.2%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ux around inf 97.9%

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

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)}} \]
    7. Step-by-step derivation
      1. sub-neg89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \color{blue}{\left(maxCos + \left(-1\right)\right)}\right) - maxCos\right)} \]
      2. metadata-eval89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos + \color{blue}{-1}\right)\right) - maxCos\right)} \]
      3. distribute-lft-in89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(-1 \cdot maxCos + -1 \cdot -1\right)}\right) - maxCos\right)} \]
      4. metadata-eval89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(-1 \cdot maxCos + \color{blue}{1}\right)\right) - maxCos\right)} \]
      5. +-commutative89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 + -1 \cdot maxCos\right)}\right) - maxCos\right)} \]
      6. mul-1-neg89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) - maxCos\right)} \]
      7. sub-neg89.9%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 - maxCos\right)}\right) - maxCos\right)} \]
    8. Simplified89.9%

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
    10. Step-by-step derivation
      1. associate-*r*74.2%

        \[\leadsto \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
    11. Simplified74.2%

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

    if 4.19999997e-4 < ux

    1. Initial program 91.6%

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

        \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. sub-neg91.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
      3. +-commutative91.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
      4. distribute-rgt-neg-in91.6%

        \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
      5. fma-define91.8%

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

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

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + -1 \cdot \left(\left(1 + ux \cdot \left(maxCos - 1\right)\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}\right)} \]
    6. Simplified78.1%

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(-\left(1 + ux \cdot \left(-1 + maxCos\right)\right) \cdot \left(1 + \left(ux \cdot maxCos - ux\right)\right)\right)}\right)} \]
    7. Taylor expanded in maxCos around 0 74.3%

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

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

Alternative 16: 65.4% accurate, 1.9× speedup?

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

\\
\left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)}
\end{array}
Derivation
  1. Initial program 58.1%

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

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. sub-neg58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
    3. +-commutative58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
    5. fma-define58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
  3. Simplified58.2%

    \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), -1 - ux \cdot \left(maxCos + -1\right), 1\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in ux around inf 98.1%

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

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos - 1\right)\right) - maxCos\right)}} \]
  7. Step-by-step derivation
    1. sub-neg75.9%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \color{blue}{\left(maxCos + \left(-1\right)\right)}\right) - maxCos\right)} \]
    2. metadata-eval75.9%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + -1 \cdot \left(maxCos + \color{blue}{-1}\right)\right) - maxCos\right)} \]
    3. distribute-lft-in75.9%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(-1 \cdot maxCos + -1 \cdot -1\right)}\right) - maxCos\right)} \]
    4. metadata-eval75.9%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(-1 \cdot maxCos + \color{blue}{1}\right)\right) - maxCos\right)} \]
    5. +-commutative75.9%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 + -1 \cdot maxCos\right)}\right) - maxCos\right)} \]
    6. mul-1-neg75.9%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 + \color{blue}{\left(-maxCos\right)}\right)\right) - maxCos\right)} \]
    7. sub-neg75.9%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \color{blue}{\left(1 - maxCos\right)}\right) - maxCos\right)} \]
  8. Simplified75.9%

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

    \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
  10. Step-by-step derivation
    1. associate-*r*64.7%

      \[\leadsto \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
  11. Simplified64.7%

    \[\leadsto \color{blue}{\left(\left(2 \cdot uy\right) \cdot \pi\right)} \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
  12. Final simplification64.7%

    \[\leadsto \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)} \]
  13. Add Preprocessing

Alternative 17: 65.4% accurate, 2.0× speedup?

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

\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)}\right)
\end{array}
Derivation
  1. Initial program 58.1%

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

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. sub-neg58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
    3. +-commutative58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
    5. fma-define58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
  3. Simplified58.2%

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + -1 \cdot \left(\left(1 + ux \cdot \left(maxCos - 1\right)\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}\right)} \]
  6. Simplified51.0%

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(-\left(1 + ux \cdot \left(-1 + maxCos\right)\right) \cdot \left(1 + \left(ux \cdot maxCos - ux\right)\right)\right)}\right)} \]
  7. Taylor expanded in ux around 0 64.7%

    \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)} \]
  8. Step-by-step derivation
    1. *-commutative64.7%

      \[\leadsto 2 \cdot \color{blue}{\left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)} \]
    2. *-commutative64.7%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(2 - 2 \cdot maxCos\right) \cdot ux}}\right) \]
    3. cancel-sign-sub-inv64.7%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(2 + \left(-2\right) \cdot maxCos\right)} \cdot ux}\right) \]
    4. metadata-eval64.7%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\left(2 + \color{blue}{-2} \cdot maxCos\right) \cdot ux}\right) \]
    5. *-commutative64.7%

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\left(2 + \color{blue}{maxCos \cdot -2}\right) \cdot ux}\right) \]
  9. Simplified64.7%

    \[\leadsto 2 \cdot \color{blue}{\left(\left(uy \cdot \pi\right) \cdot \sqrt{\left(2 + maxCos \cdot -2\right) \cdot ux}\right)} \]
  10. Final simplification64.7%

    \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)}\right) \]
  11. Add Preprocessing

Alternative 18: 7.1% accurate, 223.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (ux uy maxCos) :precision binary32 0.0)
float code(float ux, float uy, float maxCos) {
	return 0.0f;
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = 0.0e0
end function
function code(ux, uy, maxCos)
	return Float32(0.0)
end
function tmp = code(ux, uy, maxCos)
	tmp = single(0.0);
end
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 58.1%

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

      \[\leadsto \sin \color{blue}{\left(uy \cdot \left(2 \cdot \pi\right)\right)} \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. sub-neg58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{1 + \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}} \]
    3. +-commutative58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) + 1}} \]
    4. distribute-rgt-neg-in58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)} + 1} \]
    5. fma-define58.1%

      \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(1 - ux\right) + ux \cdot maxCos, -\left(\left(1 - ux\right) + ux \cdot maxCos\right), 1\right)}} \]
  3. Simplified58.2%

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + -1 \cdot \left(\left(1 + ux \cdot \left(maxCos - 1\right)\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}\right)} \]
  6. Simplified51.0%

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(-\left(1 + ux \cdot \left(-1 + maxCos\right)\right) \cdot \left(1 + \left(ux \cdot maxCos - ux\right)\right)\right)}\right)} \]
  7. Taylor expanded in ux around 0 7.1%

    \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(-\color{blue}{1}\right)}\right) \]
  8. Taylor expanded in uy around 0 7.1%

    \[\leadsto \color{blue}{0} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024155 
(FPCore (ux uy maxCos)
  :name "UniformSampleCone, y"
  :precision binary32
  :pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
  (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))