UniformSampleCone, y

Percentage Accurate: 57.4% → 98.3%
Time: 9.0s
Alternatives: 12
Speedup: 5.0×

Specification

?
\[\left(\left(\frac{2328306437}{10000000000000000000} \leq ux \land ux \leq 1\right) \land \left(\frac{2328306437}{10000000000000000000} \leq uy \land uy \leq 1\right)\right) \land \left(0 \leq maxCos \land maxCos \leq 1\right)\]
\[\begin{array}{l} t_0 := \left(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} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (let* ((t_0 (+ (- 1 ux) (* ux maxCos))))
  (* (sin (* (* uy 2) PI)) (sqrt (- 1 (* 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}
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}

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 12 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.4% accurate, 1.0× speedup?

\[\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} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (let* ((t_0 (+ (- 1 ux) (* ux maxCos))))
  (* (sin (* (* uy 2) PI)) (sqrt (- 1 (* 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}
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}

Alternative 1: 98.3% accurate, 0.8× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\left(-\left(\left(ux - maxCos \cdot ux\right) - 0\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)} \]
  4. Step-by-step derivation
    1. lift-neg.f32N/A

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(ux - maxCos \cdot ux\right) - 0\right)\right)\right)} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    2. lift--.f32N/A

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(ux - maxCos \cdot ux\right) - 0\right)}\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    3. sub-negateN/A

      \[\leadsto \sqrt{\color{blue}{\left(0 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    4. flip--N/A

      \[\leadsto \sqrt{\color{blue}{\frac{0 \cdot 0 - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}{0 + \left(ux - maxCos \cdot ux\right)}} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    5. lower-unsound-+.f64N/A

      \[\leadsto \sqrt{\frac{0 \cdot 0 - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}{\color{blue}{0 + \left(ux - maxCos \cdot ux\right)}} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    6. lower-+.f64N/A

      \[\leadsto \sqrt{\frac{0 \cdot 0 - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}{\color{blue}{0 + \left(ux - maxCos \cdot ux\right)}} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    7. +-commutativeN/A

      \[\leadsto \sqrt{\frac{0 \cdot 0 - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}{\color{blue}{\left(ux - maxCos \cdot ux\right) + 0}} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    8. +-rgt-identityN/A

      \[\leadsto \sqrt{\frac{0 \cdot 0 - \left(ux - maxCos \cdot ux\right) \cdot \left(ux - maxCos \cdot ux\right)}{\color{blue}{ux - maxCos \cdot ux}} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    9. lower-unsound-/.f32N/A

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

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

Alternative 2: 98.3% accurate, 0.9× speedup?

\[\sqrt{\frac{\left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right) - ux \cdot ux}{maxCos \cdot ux + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (sqrt
  (*
   (/
    (- (* (* maxCos ux) (* maxCos ux)) (* ux ux))
    (+ (* maxCos ux) ux))
   (- (- ux (* maxCos ux)) 2)))
 (sin (* PI (+ uy uy)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((((((maxCos * ux) * (maxCos * ux)) - (ux * ux)) / ((maxCos * ux) + ux)) * ((ux - (maxCos * ux)) - 2.0f))) * sinf((((float) M_PI) * (uy + uy)));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(Float32(Float32(Float32(Float32(Float32(maxCos * ux) * Float32(maxCos * ux)) - Float32(ux * ux)) / Float32(Float32(maxCos * ux) + ux)) * Float32(Float32(ux - Float32(maxCos * ux)) - Float32(2.0)))) * sin(Float32(Float32(pi) * Float32(uy + uy))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((((((maxCos * ux) * (maxCos * ux)) - (ux * ux)) / ((maxCos * ux) + ux)) * ((ux - (maxCos * ux)) - single(2.0)))) * sin((single(pi) * (uy + uy)));
end
\sqrt{\frac{\left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right) - ux \cdot ux}{maxCos \cdot ux + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)
Derivation
  1. Initial program 57.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. Step-by-step derivation
    1. lift-*.f32N/A

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

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

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

    \[\leadsto \color{blue}{\sqrt{\left(-\left(\left(ux - maxCos \cdot ux\right) - 0\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)} \]
  4. Step-by-step derivation
    1. lift-neg.f32N/A

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(ux - maxCos \cdot ux\right) - 0\right)\right)\right)} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    2. lift--.f32N/A

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(ux - maxCos \cdot ux\right) - 0\right)}\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    3. --rgt-identityN/A

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(ux - maxCos \cdot ux\right)}\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    4. lift--.f32N/A

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

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    6. *-commutativeN/A

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

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(ux - \color{blue}{ux \cdot maxCos}\right)\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    8. sub-negate-revN/A

      \[\leadsto \sqrt{\color{blue}{\left(ux \cdot maxCos - ux\right)} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    9. flip--N/A

      \[\leadsto \sqrt{\color{blue}{\frac{\left(ux \cdot maxCos\right) \cdot \left(ux \cdot maxCos\right) - ux \cdot ux}{ux \cdot maxCos + ux}} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    10. lower-unsound-/.f32N/A

      \[\leadsto \sqrt{\color{blue}{\frac{\left(ux \cdot maxCos\right) \cdot \left(ux \cdot maxCos\right) - ux \cdot ux}{ux \cdot maxCos + ux}} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    11. lower-unsound--.f32N/A

      \[\leadsto \sqrt{\frac{\color{blue}{\left(ux \cdot maxCos\right) \cdot \left(ux \cdot maxCos\right) - ux \cdot ux}}{ux \cdot maxCos + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    12. lower-unsound-*.f32N/A

      \[\leadsto \sqrt{\frac{\color{blue}{\left(ux \cdot maxCos\right) \cdot \left(ux \cdot maxCos\right)} - ux \cdot ux}{ux \cdot maxCos + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    13. lift-*.f32N/A

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

      \[\leadsto \sqrt{\frac{\color{blue}{\left(maxCos \cdot ux\right)} \cdot \left(ux \cdot maxCos\right) - ux \cdot ux}{ux \cdot maxCos + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    15. lift-*.f32N/A

      \[\leadsto \sqrt{\frac{\color{blue}{\left(maxCos \cdot ux\right)} \cdot \left(ux \cdot maxCos\right) - ux \cdot ux}{ux \cdot maxCos + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    16. lift-*.f32N/A

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

      \[\leadsto \sqrt{\frac{\left(maxCos \cdot ux\right) \cdot \color{blue}{\left(maxCos \cdot ux\right)} - ux \cdot ux}{ux \cdot maxCos + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    18. lift-*.f32N/A

      \[\leadsto \sqrt{\frac{\left(maxCos \cdot ux\right) \cdot \color{blue}{\left(maxCos \cdot ux\right)} - ux \cdot ux}{ux \cdot maxCos + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    19. lower-unsound-*.f32N/A

      \[\leadsto \sqrt{\frac{\left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right) - \color{blue}{ux \cdot ux}}{ux \cdot maxCos + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    20. lower-unsound-+.f3298.2%

      \[\leadsto \sqrt{\frac{\left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right) - ux \cdot ux}{\color{blue}{ux \cdot maxCos + ux}} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    21. lift-*.f32N/A

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

      \[\leadsto \sqrt{\frac{\left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right) - ux \cdot ux}{\color{blue}{maxCos \cdot ux} + ux} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    23. lift-*.f3298.2%

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

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

Alternative 3: 98.2% accurate, 1.1× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\left(-\left(\left(ux - maxCos \cdot ux\right) - 0\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)} \]
  4. Step-by-step derivation
    1. lift-neg.f32N/A

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(ux - maxCos \cdot ux\right) - 0\right)\right)\right)} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    2. lift--.f32N/A

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(\left(ux - maxCos \cdot ux\right) - 0\right)}\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    3. --rgt-identityN/A

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\color{blue}{\left(ux - maxCos \cdot ux\right)}\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    4. lift--.f32N/A

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

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(ux - \color{blue}{maxCos \cdot ux}\right)\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    6. *-commutativeN/A

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

      \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(ux - \color{blue}{ux \cdot maxCos}\right)\right)\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    8. sub-negate-revN/A

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

      \[\leadsto \sqrt{\color{blue}{\left(ux \cdot maxCos - ux\right)} \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    10. lift-*.f32N/A

      \[\leadsto \sqrt{\left(\color{blue}{ux \cdot maxCos} - ux\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    11. *-commutativeN/A

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

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

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

Alternative 4: 97.1% accurate, 1.1× speedup?

\[\sqrt{\left(-\left(\left(ux - maxCos \cdot ux\right) - 0\right)\right) \cdot \left(ux - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (sqrt (* (- (- (- ux (* maxCos ux)) 0)) (- ux 2)))
 (sin (* PI (+ uy uy)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((-((ux - (maxCos * ux)) - 0.0f) * (ux - 2.0f))) * sinf((((float) M_PI) * (uy + uy)));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(Float32(Float32(-Float32(Float32(ux - Float32(maxCos * ux)) - Float32(0.0))) * Float32(ux - Float32(2.0)))) * sin(Float32(Float32(pi) * Float32(uy + uy))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((-((ux - (maxCos * ux)) - single(0.0)) * (ux - single(2.0)))) * sin((single(pi) * (uy + uy)));
end
\sqrt{\left(-\left(\left(ux - maxCos \cdot ux\right) - 0\right)\right) \cdot \left(ux - 2\right)} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)
Derivation
  1. Initial program 57.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. Step-by-step derivation
    1. lift-*.f32N/A

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

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

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

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

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

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

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

Alternative 5: 92.4% accurate, 1.1× speedup?

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

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

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

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

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

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

      \[\leadsto \sqrt{-1 \cdot \color{blue}{\left(ux \cdot \left(ux - 2\right)\right)}} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right) \]
    2. lower-*.f32N/A

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

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

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

Alternative 6: 90.7% accurate, 1.1× speedup?

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

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


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

    1. Initial program 57.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. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}}\right)\right) \]
      5. lower-sqrt.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      6. lower-*.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      7. lower--.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      8. lower-+.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      9. lower-*.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      10. lower--.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      11. lower-*.f3281.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
    6. Applied rewrites81.5%

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

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

    if 0.00159999996 < uy

    1. Initial program 57.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. Taylor expanded in ux around 0

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)}} \]
      2. lower--.f32N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - \color{blue}{2 \cdot maxCos}\right)} \]
      3. lower-*.f3276.4%

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

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

        \[\leadsto \color{blue}{\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right)} \]
      3. lower-*.f3276.4%

        \[\leadsto \color{blue}{\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right)} \]
      4. lift-*.f32N/A

        \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)}} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot \color{blue}{ux}} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \]
      6. lower-*.f3276.4%

        \[\leadsto \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot \color{blue}{ux}} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \]
      7. lift-*.f32N/A

        \[\leadsto \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \]
      8. count-2-revN/A

        \[\leadsto \sqrt{\left(2 - \left(maxCos + maxCos\right)\right) \cdot ux} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \]
      9. lower-+.f3276.4%

        \[\leadsto \sqrt{\left(2 - \left(maxCos + maxCos\right)\right) \cdot ux} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \]
      10. lower-+.f32N/A

        \[\leadsto \sqrt{\left(2 - \left(maxCos + maxCos\right)\right) \cdot ux} \cdot \sin \mathsf{Rewrite=>}\left(lift-*.f32, \left(\left(uy \cdot 2\right) \cdot \pi\right)\right) \]
      11. lower-+.f32N/A

        \[\leadsto \sqrt{\left(2 - \left(maxCos + maxCos\right)\right) \cdot ux} \cdot \sin \left(\mathsf{Rewrite=>}\left(lift-*.f32, \left(uy \cdot 2\right)\right) \cdot \pi\right) \]
      12. lower-+.f32N/A

        \[\leadsto \sqrt{\left(2 - \left(maxCos + maxCos\right)\right) \cdot ux} \cdot \sin \mathsf{Rewrite=>}\left(associate-*l*, \left(uy \cdot \left(2 \cdot \pi\right)\right)\right) \]
      13. lower-+.f32N/A

        \[\leadsto \sqrt{\left(2 - \left(maxCos + maxCos\right)\right) \cdot ux} \cdot \sin \mathsf{Rewrite=>}\left(*-commutative, \left(\left(2 \cdot \pi\right) \cdot uy\right)\right) \]
      14. lower-+.f32N/A

        \[\leadsto \sqrt{\left(2 - \left(maxCos + maxCos\right)\right) \cdot ux} \cdot \sin \mathsf{Rewrite=>}\left(lower-*.f32, \left(\left(2 \cdot \pi\right) \cdot uy\right)\right) \]
    6. Applied rewrites76.4%

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

Alternative 7: 89.7% accurate, 1.1× speedup?

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

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


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

    1. Initial program 57.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. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}}\right)\right) \]
      5. lower-sqrt.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      6. lower-*.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      7. lower--.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      8. lower-+.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      9. lower-*.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      10. lower--.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      11. lower-*.f3281.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
    6. Applied rewrites81.5%

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

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

    if 0.00400000019 < uy

    1. Initial program 57.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. Taylor expanded in ux around 0

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - 2 \cdot maxCos\right)}} \]
      2. lower--.f32N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - \color{blue}{2 \cdot maxCos}\right)} \]
      3. lower-*.f3276.4%

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot 2} \]
    6. Step-by-step derivation
      1. Applied rewrites72.9%

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot 2} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 8: 81.4% accurate, 3.3× speedup?

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}}\right)\right) \]
      5. lower-sqrt.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      6. lower-*.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      7. lower--.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      8. lower-+.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      9. lower-*.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      10. lower--.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      11. lower-*.f3281.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
    6. Applied rewrites81.5%

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

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

    Alternative 9: 80.7% accurate, 3.7× speedup?

    \[2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - 2\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
    (FPCore (ux uy maxCos)
      :precision binary32
      (* 2 (* uy (* PI (sqrt (* (- ux 2) (- (* maxCos ux) ux)))))))
    float code(float ux, float uy, float maxCos) {
    	return 2.0f * (uy * (((float) M_PI) * sqrtf(((ux - 2.0f) * ((maxCos * ux) - ux)))));
    }
    
    function code(ux, uy, maxCos)
    	return Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(ux - Float32(2.0)) * Float32(Float32(maxCos * ux) - ux))))))
    end
    
    function tmp = code(ux, uy, maxCos)
    	tmp = single(2.0) * (uy * (single(pi) * sqrt(((ux - single(2.0)) * ((maxCos * ux) - ux)))));
    end
    
    2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - 2\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right)
    
    Derivation
    1. Initial program 57.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. Step-by-step derivation
      1. lift-*.f32N/A

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}}\right)\right) \]
      5. lower-sqrt.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      6. lower-*.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      7. lower--.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      8. lower-+.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      9. lower-*.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      10. lower--.f32N/A

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      11. lower-*.f3281.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
    6. Applied rewrites81.5%

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

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

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

      Alternative 10: 77.3% accurate, 3.7× speedup?

      \[2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(\left(ux - 1\right) - 1\right)\right)}\right)\right) \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (* 2 (* uy (* PI (sqrt (* -1 (* ux (- (- ux 1) 1))))))))
      float code(float ux, float uy, float maxCos) {
      	return 2.0f * (uy * (((float) M_PI) * sqrtf((-1.0f * (ux * ((ux - 1.0f) - 1.0f))))));
      }
      
      function code(ux, uy, maxCos)
      	return Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(-1.0) * Float32(ux * Float32(Float32(ux - Float32(1.0)) - Float32(1.0))))))))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = single(2.0) * (uy * (single(pi) * sqrt((single(-1.0) * (ux * ((ux - single(1.0)) - single(1.0)))))));
      end
      
      2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(\left(ux - 1\right) - 1\right)\right)}\right)\right)
      
      Derivation
      1. Initial program 57.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. Step-by-step derivation
        1. lift-*.f32N/A

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

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

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

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

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

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

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

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

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}}\right)\right) \]
        5. lower-sqrt.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        6. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        7. lower--.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        8. lower-+.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        9. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        10. lower--.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        11. lower-*.f3281.5%

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      6. Applied rewrites81.5%

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

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

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

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        3. lower-sqrt.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        4. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        5. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        6. lower--.f3277.3%

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
      9. Applied rewrites77.3%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \color{blue}{\sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}}\right)\right) \]
      10. Step-by-step derivation
        1. lift--.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        2. metadata-evalN/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - \left(1 + 1\right)\right)\right)}\right)\right) \]
        3. associate--r+N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(\left(ux - 1\right) - 1\right)\right)}\right)\right) \]
        4. lower--.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(\left(ux - 1\right) - 1\right)\right)}\right)\right) \]
        5. lower--.f3277.3%

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(\left(ux - 1\right) - 1\right)\right)}\right)\right) \]
      11. Applied rewrites77.3%

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

      Alternative 11: 77.3% accurate, 4.9× speedup?

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

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

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

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

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

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

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

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

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

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}}\right)\right) \]
        5. lower-sqrt.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        6. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        7. lower--.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        8. lower-+.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        9. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        10. lower--.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        11. lower-*.f3281.5%

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      6. Applied rewrites81.5%

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

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

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

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        3. lower-sqrt.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        4. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        5. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        6. lower--.f3277.3%

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
      9. Applied rewrites77.3%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \color{blue}{\sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}}\right)\right) \]
      10. Step-by-step derivation
        1. lift-*.f32N/A

          \[\leadsto 2 \cdot \color{blue}{\left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right)} \]
        2. lift-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \color{blue}{\left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)}\right) \]
        3. associate-*r*N/A

          \[\leadsto \left(2 \cdot uy\right) \cdot \color{blue}{\left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)} \]
        4. count-2N/A

          \[\leadsto \left(uy + uy\right) \cdot \left(\color{blue}{\pi} \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right) \]
        5. lift-+.f32N/A

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

          \[\leadsto \left(uy + uy\right) \cdot \color{blue}{\left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)} \]
        7. lift-*.f32N/A

          \[\leadsto \left(uy + uy\right) \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right) \]
        8. *-commutativeN/A

          \[\leadsto \left(uy + uy\right) \cdot \left(\sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)} \cdot \pi\right) \]
        9. lower-*.f3277.3%

          \[\leadsto \left(uy + uy\right) \cdot \left(\sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)} \cdot \pi\right) \]
      11. Applied rewrites77.3%

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

      Alternative 12: 63.2% accurate, 5.0× speedup?

      \[2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right) \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (* 2 (* uy (* PI (sqrt (* 2 ux))))))
      float code(float ux, float uy, float maxCos) {
      	return 2.0f * (uy * (((float) M_PI) * sqrtf((2.0f * ux))));
      }
      
      function code(ux, uy, maxCos)
      	return Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(2.0) * ux)))))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = single(2.0) * (uy * (single(pi) * sqrt((single(2.0) * ux))));
      end
      
      2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right)
      
      Derivation
      1. Initial program 57.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. Step-by-step derivation
        1. lift-*.f32N/A

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

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

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

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

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

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

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

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

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\color{blue}{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}}\right)\right) \]
        5. lower-sqrt.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        6. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        7. lower--.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        8. lower-+.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        9. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        10. lower--.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
        11. lower-*.f3281.5%

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - \left(2 + maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux - ux\right)}\right)\right) \]
      6. Applied rewrites81.5%

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

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

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

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        3. lower-sqrt.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        4. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        5. lower-*.f32N/A

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
        6. lower--.f3277.3%

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\right)\right) \]
      9. Applied rewrites77.3%

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right) \]
      11. Step-by-step derivation
        1. lower-*.f3263.2%

          \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right) \]
      12. Applied rewrites63.2%

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

      Reproduce

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