UniformSampleCone, y

Percentage Accurate: 57.6% → 98.4%
Time: 18.5s
Alternatives: 19
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 19 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.6% 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.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{2 \cdot \pi}\\
\sin \left(t\_0 \cdot \left(uy \cdot t\_0\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(\left(1 - maxCos\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right)\right)\right)\right) - maxCos\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

    \[\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)}} \]
  6. Step-by-step derivation
    1. add-sqr-sqrt98.3%

      \[\leadsto \sin \left(uy \cdot \color{blue}{\left(\sqrt{2 \cdot \pi} \cdot \sqrt{2 \cdot \pi}\right)}\right) \cdot \sqrt{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)} \]
    2. associate-*r*98.6%

      \[\leadsto \sin \color{blue}{\left(\left(uy \cdot \sqrt{2 \cdot \pi}\right) \cdot \sqrt{2 \cdot \pi}\right)} \cdot \sqrt{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. Applied egg-rr98.6%

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

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

\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) - \frac{-1 + \left(maxCos + \left(-1 + maxCos\right)\right)}{ux}\right)}
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.3% accurate, 1.0× speedup?

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

\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + \frac{1 + \left(1 - maxCos\right)}{ux}\right) - maxCos\right)}
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

    \[\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)}} \]
  6. Taylor expanded in ux around -inf 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.3% accurate, 1.0× speedup?

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

\\
\sqrt{ux \cdot \left(\left(1 + \left(\left(1 - maxCos\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right)\right)\right)\right) - maxCos\right)} \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

    \[\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)}} \]
  6. Final simplification98.3%

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

Alternative 5: 96.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 55.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*55.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-neg55.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. +-commutative55.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-in55.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-define55.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. Simplified55.1%

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

      \[\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)}} \]
    6. Taylor expanded in ux around -inf 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999995e-4 < (*.f32 uy #s(literal 2 binary32))

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

        \[\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.8%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 + ux \cdot \left(maxCos + -1\right), -1 + ux \cdot \left(1 - maxCos\right), 1\right)}} \]
    4. Add Preprocessing
    5. 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(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)}} \]
    6. Taylor expanded in ux around -inf 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.00019999999494757503:\\ \;\;\;\;2 \cdot \left(\sqrt{ux \cdot \left(ux \cdot \left(\left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + 2 \cdot \frac{1}{ux}\right) - \frac{maxCos}{ux}\right) - maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(ux \cdot \left(-1 - \frac{-2}{ux}\right) - maxCos\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(2 + \left(ux \cdot \left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right)\right) - 2 \cdot maxCos\right)\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sin (* uy (* 2.0 PI)))
  (sqrt
   (*
    ux
    (+ 2.0 (- (* ux (* (- 1.0 maxCos) (+ -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 * ((1.0f - maxCos) * (-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(2.0) + Float32(Float32(ux * Float32(Float32(Float32(1.0) - maxCos) * 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 * ((single(1.0) - maxCos) * (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(2 + \left(ux \cdot \left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right)\right) - 2 \cdot maxCos\right)\right)}
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 + maxCos\right) \cdot \left(1 - maxCos\right) - \frac{\left(maxCos - \left(1 - maxCos\right)\right) + -1}{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. Step-by-step derivation
    1. associate--l+98.2%

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

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

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

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

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

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

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

Alternative 7: 96.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 55.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*55.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-neg55.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. +-commutative55.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-in55.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-define55.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. Simplified55.1%

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

      \[\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)}} \]
    6. Taylor expanded in ux around -inf 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999995e-4 < (*.f32 uy #s(literal 2 binary32))

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

        \[\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.8%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 + ux \cdot \left(maxCos + -1\right), -1 + ux \cdot \left(1 - maxCos\right), 1\right)}} \]
    4. Add Preprocessing
    5. 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(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)}} \]
    6. Taylor expanded in maxCos around 0 92.5%

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

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

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

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

Alternative 8: 95.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.00019999999494757503:\\ \;\;\;\;2 \cdot \left(\sqrt{ux \cdot \left(ux \cdot \left(\left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + 2 \cdot \frac{1}{ux}\right) - \frac{maxCos}{ux}\right) - maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)\\ \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.00019999999494757503)
   (*
    2.0
    (*
     (sqrt
      (*
       ux
       (-
        (*
         ux
         (-
          (+ (* (- 1.0 maxCos) (+ -1.0 maxCos)) (* 2.0 (/ 1.0 ux)))
          (/ maxCos ux)))
        maxCos)))
     (* uy PI)))
   (* (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.00019999999494757503f) {
		tmp = 2.0f * (sqrtf((ux * ((ux * ((((1.0f - maxCos) * (-1.0f + maxCos)) + (2.0f * (1.0f / ux))) - (maxCos / ux))) - maxCos))) * (uy * ((float) M_PI)));
	} 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.00019999999494757503))
		tmp = Float32(Float32(2.0) * Float32(sqrt(Float32(ux * Float32(Float32(ux * Float32(Float32(Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(-1.0) + maxCos)) + Float32(Float32(2.0) * Float32(Float32(1.0) / ux))) - Float32(maxCos / ux))) - maxCos))) * Float32(uy * Float32(pi))));
	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.00019999999494757503))
		tmp = single(2.0) * (sqrt((ux * ((ux * ((((single(1.0) - maxCos) * (single(-1.0) + maxCos)) + (single(2.0) * (single(1.0) / ux))) - (maxCos / ux))) - maxCos))) * (uy * single(pi)));
	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.00019999999494757503:\\
\;\;\;\;2 \cdot \left(\sqrt{ux \cdot \left(ux \cdot \left(\left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + 2 \cdot \frac{1}{ux}\right) - \frac{maxCos}{ux}\right) - maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)\\

\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)) < 1.99999995e-4

    1. Initial program 55.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*55.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-neg55.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. +-commutative55.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-in55.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-define55.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. Simplified55.1%

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

      \[\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)}} \]
    6. Taylor expanded in ux around -inf 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999995e-4 < (*.f32 uy #s(literal 2 binary32))

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

        \[\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.8%

      \[\leadsto \color{blue}{\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 + ux \cdot \left(maxCos + -1\right), -1 + ux \cdot \left(1 - maxCos\right), 1\right)}} \]
    4. Add Preprocessing
    5. 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(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)}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt98.2%

        \[\leadsto \sin \left(uy \cdot \color{blue}{\left(\sqrt{2 \cdot \pi} \cdot \sqrt{2 \cdot \pi}\right)}\right) \cdot \sqrt{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)} \]
      2. associate-*r*98.3%

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

      \[\leadsto \sin \color{blue}{\left(\left(uy \cdot \sqrt{2 \cdot \pi}\right) \cdot \sqrt{2 \cdot \pi}\right)} \cdot \sqrt{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)} \]
    8. Taylor expanded in maxCos around 0 91.8%

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

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

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

        \[\leadsto \sqrt{ux \cdot \left(2 - ux\right)} \cdot \sin \left(uy \cdot \left(\pi \cdot \color{blue}{\left(\sqrt{2} \cdot \sqrt{2}\right)}\right)\right) \]
      4. rem-square-sqrt92.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.00019999999494757503:\\ \;\;\;\;2 \cdot \left(\sqrt{ux \cdot \left(ux \cdot \left(\left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + 2 \cdot \frac{1}{ux}\right) - \frac{maxCos}{ux}\right) - maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)\\ \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 9: 89.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.0031999999191612005:\\ \;\;\;\;2 \cdot \left(\sqrt{ux \cdot \left(ux \cdot \left(\left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + 2 \cdot \frac{1}{ux}\right) - \frac{maxCos}{ux}\right) - maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{2 \cdot ux}\\ \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (if (<= (* uy 2.0) 0.0031999999191612005)
   (*
    2.0
    (*
     (sqrt
      (*
       ux
       (-
        (*
         ux
         (-
          (+ (* (- 1.0 maxCos) (+ -1.0 maxCos)) (* 2.0 (/ 1.0 ux)))
          (/ maxCos ux)))
        maxCos)))
     (* uy PI)))
   (* (sin (* 2.0 (* uy PI))) (sqrt (* 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if ((uy * 2.0f) <= 0.0031999999191612005f) {
		tmp = 2.0f * (sqrtf((ux * ((ux * ((((1.0f - maxCos) * (-1.0f + maxCos)) + (2.0f * (1.0f / ux))) - (maxCos / ux))) - maxCos))) * (uy * ((float) M_PI)));
	} else {
		tmp = sinf((2.0f * (uy * ((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.0031999999191612005))
		tmp = Float32(Float32(2.0) * Float32(sqrt(Float32(ux * Float32(Float32(ux * Float32(Float32(Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(-1.0) + maxCos)) + Float32(Float32(2.0) * Float32(Float32(1.0) / ux))) - Float32(maxCos / ux))) - maxCos))) * Float32(uy * Float32(pi))));
	else
		tmp = Float32(sin(Float32(Float32(2.0) * Float32(uy * 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.0031999999191612005))
		tmp = single(2.0) * (sqrt((ux * ((ux * ((((single(1.0) - maxCos) * (single(-1.0) + maxCos)) + (single(2.0) * (single(1.0) / ux))) - (maxCos / ux))) - maxCos))) * (uy * single(pi)));
	else
		tmp = sin((single(2.0) * (uy * 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.0031999999191612005:\\
\;\;\;\;2 \cdot \left(\sqrt{ux \cdot \left(ux \cdot \left(\left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + 2 \cdot \frac{1}{ux}\right) - \frac{maxCos}{ux}\right) - maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\sin \left(2 \cdot \left(uy \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.00319999992

    1. Initial program 55.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*55.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-neg55.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. +-commutative55.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-in55.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-define55.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. Simplified55.7%

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

      \[\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)}} \]
    6. Taylor expanded in ux around -inf 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 58.4%

      \[\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 78.0%

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

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

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

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

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

Alternative 10: 81.1% accurate, 1.7× speedup?

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

\\
2 \cdot \left(\sqrt{ux \cdot \left(ux \cdot \left(\left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + 2 \cdot \frac{1}{ux}\right) - \frac{maxCos}{ux}\right) - maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

    \[\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)}} \]
  6. Taylor expanded in ux around -inf 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 76.6% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 36.0%

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

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

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

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

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

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

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

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

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

    if 1.50000007e-4 < ux

    1. Initial program 87.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*87.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-neg87.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. +-commutative87.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-in87.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-define87.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. Simplified87.7%

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

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

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

Alternative 12: 81.2% accurate, 1.8× speedup?

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

\\
2 \cdot \left(\sqrt{ux \cdot \left(\left(1 + \left(\left(1 - maxCos\right) + ux \cdot \left(\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right)\right)\right)\right) - maxCos\right)} \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

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

    \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\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)}}\right) \]
  7. Final simplification80.5%

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

Alternative 13: 81.1% accurate, 1.8× speedup?

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

\\
\left(2 \cdot \left(\pi \cdot \left(uy \cdot ux\right)\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(-1 + maxCos\right) + \frac{2 + maxCos \cdot -2}{ux}}
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{{ux}^{2} \cdot \left(\left(-1 + maxCos\right) \cdot \left(1 - maxCos\right) - \frac{\left(maxCos - \left(1 - maxCos\right)\right) + -1}{ux}\right)}} \]
  8. Taylor expanded in uy around 0 80.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*80.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. associate-*r*80.5%

      \[\leadsto \left(2 \cdot \color{blue}{\left(\left(ux \cdot uy\right) \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}} \]
    3. +-commutative80.5%

      \[\leadsto \left(2 \cdot \left(\left(ux \cdot uy\right) \cdot \pi\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}} \]
    4. associate--l+80.5%

      \[\leadsto \left(2 \cdot \left(\left(ux \cdot uy\right) \cdot \pi\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)}} \]
    5. sub-neg80.5%

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

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

      \[\leadsto \left(2 \cdot \left(\left(ux \cdot uy\right) \cdot \pi\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)} \]
    8. metadata-eval80.5%

      \[\leadsto \left(2 \cdot \left(\left(ux \cdot uy\right) \cdot \pi\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)} \]
    9. associate-*r/80.5%

      \[\leadsto \left(2 \cdot \left(\left(ux \cdot uy\right) \cdot \pi\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)} \]
    10. div-sub80.5%

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

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

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

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

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

Alternative 14: 75.4% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 37.3%

      \[\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*37.3%

        \[\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-neg37.3%

        \[\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. +-commutative37.3%

        \[\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-in37.3%

        \[\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-define37.4%

        \[\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. Simplified37.5%

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

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

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

    if 2.37999993e-4 < ux

    1. Initial program 88.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*88.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-neg88.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. +-commutative88.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-in88.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-define88.5%

        \[\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. Simplified88.5%

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

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

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

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

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

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

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

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

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

Alternative 15: 75.4% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 37.3%

      \[\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 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \sqrt{ux \cdot \left(\left(-\color{blue}{maxCos \cdot 2}\right) + 2\right)}\right) \cdot \left(uy \cdot \pi\right) \]
      13. distribute-rgt-neg-in76.3%

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

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

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

    if 2.37999993e-4 < ux

    1. Initial program 88.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*88.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-neg88.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. +-commutative88.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-in88.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-define88.5%

        \[\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. Simplified88.5%

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

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

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

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

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

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

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

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

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

Alternative 16: 75.4% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 37.3%

      \[\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 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \sqrt{ux \cdot \left(\left(-\color{blue}{maxCos \cdot 2}\right) + 2\right)}\right) \cdot \left(uy \cdot \pi\right) \]
      13. distribute-rgt-neg-in76.3%

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

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

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

    if 2.37999993e-4 < ux

    1. Initial program 88.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*88.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-neg88.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. +-commutative88.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-in88.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-define88.5%

        \[\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. Simplified88.5%

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

      \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(1 + ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 1\right)}\right)} \]
    6. Step-by-step derivation
      1. add-cube-cbrt74.9%

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

        \[\leadsto 2 \cdot \left(\color{blue}{{\left(\sqrt[3]{uy \cdot \pi}\right)}^{3}} \cdot \sqrt{1 + \left(1 + ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 1\right)}\right) \]
    7. Applied egg-rr75.0%

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

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

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

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

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

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

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

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

Alternative 17: 65.8% accurate, 2.0× speedup?

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

\\
\left(uy \cdot \pi\right) \cdot \left(2 \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)}\right)
\end{array}
Derivation
  1. Initial program 56.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. Add Preprocessing
  3. Taylor expanded in ux around 0 77.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(2 \cdot \sqrt{\left(\color{blue}{\left(-2\right)} \cdot maxCos\right) \cdot ux + 2 \cdot ux}\right) \cdot \left(uy \cdot \pi\right) \]
    10. distribute-lft-neg-in66.2%

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

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

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

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

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

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

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

Alternative 18: 63.2% accurate, 2.0× speedup?

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

\\
\left(uy \cdot \pi\right) \cdot \left(2 \cdot \sqrt{2 \cdot ux}\right)
\end{array}
Derivation
  1. Initial program 56.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. Add Preprocessing
  3. Taylor expanded in ux around 0 77.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(2 \cdot \sqrt{\left(\color{blue}{\left(-2\right)} \cdot maxCos\right) \cdot ux + 2 \cdot ux}\right) \cdot \left(uy \cdot \pi\right) \]
    10. distribute-lft-neg-in66.2%

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

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

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

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

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

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

    \[\leadsto \left(2 \cdot \sqrt{\color{blue}{2 \cdot ux}}\right) \cdot \left(uy \cdot \pi\right) \]
  8. Final simplification63.4%

    \[\leadsto \left(uy \cdot \pi\right) \cdot \left(2 \cdot \sqrt{2 \cdot ux}\right) \]
  9. Add Preprocessing

Alternative 19: 7.1% accurate, 2.1× speedup?

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

\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{0}\right)
\end{array}
Derivation
  1. Initial program 56.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*56.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-neg56.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. +-commutative56.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-in56.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-define56.5%

      \[\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.6%

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

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

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

    \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{0}\right) \]
  8. Add Preprocessing

Reproduce

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