UniformSampleCone, x

Percentage Accurate: 57.6% → 99.1%
Time: 1.1min
Alternatives: 15
Speedup: 5.9×

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} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \cos \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.0 ux) (* ux maxCos))))
  (* (cos (* (* 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 cosf(((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(cos(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 = cos(((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\\
\cos \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 15 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 57.6% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \cos \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.0 ux) (* ux maxCos))))
  (* (cos (* (* 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 cosf(((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(cos(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 = cos(((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\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}

Alternative 1: 99.1% accurate, 1.1× speedup?

\[\sin \left(\pi \cdot \mathsf{fma}\left(uy, -2, 0.5\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (sin (* PI (fma uy -2.0 0.5)))
 (sqrt (* (fma ux (- 1.0 maxCos) -2.0) (* ux (- maxCos 1.0))))))
float code(float ux, float uy, float maxCos) {
	return sinf((((float) M_PI) * fmaf(uy, -2.0f, 0.5f))) * sqrtf((fmaf(ux, (1.0f - maxCos), -2.0f) * (ux * (maxCos - 1.0f))));
}
function code(ux, uy, maxCos)
	return Float32(sin(Float32(Float32(pi) * fma(uy, Float32(-2.0), Float32(0.5)))) * sqrt(Float32(fma(ux, Float32(Float32(1.0) - maxCos), Float32(-2.0)) * Float32(ux * Float32(maxCos - Float32(1.0))))))
end
\sin \left(\pi \cdot \mathsf{fma}\left(uy, -2, 0.5\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)}
Derivation
  1. Initial program 57.6%

    \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
    2. sub-negate-revN/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
    4. difference-of-sqr-1N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
    5. distribute-lft-neg-inN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
    6. distribute-neg-outN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
    7. sub-flipN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
    11. sub-flipN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
    12. associate-+l+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
    13. associate--r+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
    14. metadata-evalN/A

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

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  4. Taylor expanded in ux around 0

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \color{blue}{\left(maxCos - 1\right)}\right)} \]
    2. lower--.f3298.9%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - \color{blue}{1}\right)\right)} \]
  6. Applied rewrites98.9%

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

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    2. cos-neg-revN/A

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

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

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

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

      \[\leadsto \sin \left(\left(\mathsf{neg}\left(\color{blue}{\pi \cdot \left(uy \cdot 2\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    7. distribute-rgt-neg-outN/A

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

      \[\leadsto \sin \left(\pi \cdot \left(\mathsf{neg}\left(\color{blue}{uy \cdot 2}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    9. distribute-rgt-neg-outN/A

      \[\leadsto \sin \left(\pi \cdot \color{blue}{\left(uy \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    10. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \left(uy \cdot \color{blue}{-2}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    11. lift-PI.f32N/A

      \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \frac{\color{blue}{\pi}}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    12. mult-flipN/A

      \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    13. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \pi \cdot \color{blue}{\frac{1}{2}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    14. distribute-lft-outN/A

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

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

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

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

Alternative 2: 98.9% accurate, 1.1× speedup?

\[\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (cos (* (+ uy uy) PI))
 (sqrt (* (fma ux (- 1.0 maxCos) -2.0) (* ux (- maxCos 1.0))))))
float code(float ux, float uy, float maxCos) {
	return cosf(((uy + uy) * ((float) M_PI))) * sqrtf((fmaf(ux, (1.0f - maxCos), -2.0f) * (ux * (maxCos - 1.0f))));
}
function code(ux, uy, maxCos)
	return Float32(cos(Float32(Float32(uy + uy) * Float32(pi))) * sqrt(Float32(fma(ux, Float32(Float32(1.0) - maxCos), Float32(-2.0)) * Float32(ux * Float32(maxCos - Float32(1.0))))))
end
\cos \left(\left(uy + uy\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)}
Derivation
  1. Initial program 57.6%

    \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
    2. sub-negate-revN/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
    4. difference-of-sqr-1N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
    5. distribute-lft-neg-inN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
    6. distribute-neg-outN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
    7. sub-flipN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
    11. sub-flipN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
    12. associate-+l+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
    13. associate--r+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
    14. metadata-evalN/A

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

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  4. Taylor expanded in ux around 0

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \color{blue}{\left(maxCos - 1\right)}\right)} \]
    2. lower--.f3298.9%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - \color{blue}{1}\right)\right)} \]
  6. Applied rewrites98.9%

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

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

      \[\leadsto \cos \left(\color{blue}{\left(2 \cdot uy\right)} \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    3. count-2-revN/A

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

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

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

Alternative 3: 97.7% accurate, 1.1× speedup?

\[\sin \left(\pi \cdot \mathsf{fma}\left(uy, -2, 0.5\right)\right) \cdot \sqrt{\left(ux - 2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (sin (* PI (fma uy -2.0 0.5)))
 (sqrt (* (- ux 2.0) (* ux (- maxCos 1.0))))))
float code(float ux, float uy, float maxCos) {
	return sinf((((float) M_PI) * fmaf(uy, -2.0f, 0.5f))) * sqrtf(((ux - 2.0f) * (ux * (maxCos - 1.0f))));
}
function code(ux, uy, maxCos)
	return Float32(sin(Float32(Float32(pi) * fma(uy, Float32(-2.0), Float32(0.5)))) * sqrt(Float32(Float32(ux - Float32(2.0)) * Float32(ux * Float32(maxCos - Float32(1.0))))))
end
\sin \left(\pi \cdot \mathsf{fma}\left(uy, -2, 0.5\right)\right) \cdot \sqrt{\left(ux - 2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)}
Derivation
  1. Initial program 57.6%

    \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
    2. sub-negate-revN/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
    4. difference-of-sqr-1N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
    5. distribute-lft-neg-inN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
    6. distribute-neg-outN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
    7. sub-flipN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
    11. sub-flipN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
    12. associate-+l+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
    13. associate--r+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
    14. metadata-evalN/A

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

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  4. Taylor expanded in ux around 0

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \color{blue}{\left(maxCos - 1\right)}\right)} \]
    2. lower--.f3298.9%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - \color{blue}{1}\right)\right)} \]
  6. Applied rewrites98.9%

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

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    2. cos-neg-revN/A

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

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

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

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

      \[\leadsto \sin \left(\left(\mathsf{neg}\left(\color{blue}{\pi \cdot \left(uy \cdot 2\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    7. distribute-rgt-neg-outN/A

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

      \[\leadsto \sin \left(\pi \cdot \left(\mathsf{neg}\left(\color{blue}{uy \cdot 2}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    9. distribute-rgt-neg-outN/A

      \[\leadsto \sin \left(\pi \cdot \color{blue}{\left(uy \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    10. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \left(uy \cdot \color{blue}{-2}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    11. lift-PI.f32N/A

      \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \frac{\color{blue}{\pi}}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    12. mult-flipN/A

      \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    13. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \pi \cdot \color{blue}{\frac{1}{2}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    14. distribute-lft-outN/A

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

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

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

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

    \[\leadsto \sin \left(\pi \cdot \mathsf{fma}\left(uy, -2, 0.5\right)\right) \cdot \sqrt{\color{blue}{\left(ux - 2\right)} \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
  10. Step-by-step derivation
    1. lower--.f3297.7%

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

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

Alternative 4: 97.6% accurate, 1.2× speedup?

\[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - 2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (cos (* (* uy 2.0) PI))
 (sqrt (* (- ux 2.0) (* ux (- maxCos 1.0))))))
float code(float ux, float uy, float maxCos) {
	return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((ux - 2.0f) * (ux * (maxCos - 1.0f))));
}
function code(ux, uy, maxCos)
	return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(ux - Float32(2.0)) * Float32(ux * Float32(maxCos - Float32(1.0))))))
end
function tmp = code(ux, uy, maxCos)
	tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt(((ux - single(2.0)) * (ux * (maxCos - single(1.0)))));
end
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - 2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)}
Derivation
  1. Initial program 57.6%

    \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
    2. sub-negate-revN/A

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
    4. difference-of-sqr-1N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
    5. distribute-lft-neg-inN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
    6. distribute-neg-outN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
    7. sub-flipN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
    11. sub-flipN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
    12. associate-+l+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
    13. associate--r+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
    14. metadata-evalN/A

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

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

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

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
  4. Taylor expanded in ux around 0

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \color{blue}{\left(maxCos - 1\right)}\right)} \]
    2. lower--.f3298.9%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - \color{blue}{1}\right)\right)} \]
  6. Applied rewrites98.9%

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

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

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

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

Alternative 5: 96.4% accurate, 1.1× speedup?

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

\mathbf{else}:\\
\;\;\;\;\sin \left(\pi \cdot \mathsf{fma}\left(uy, -2, 0.5\right)\right) \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}\\


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

    1. Initial program 57.6%

      \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      2. sub-negate-revN/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
      4. difference-of-sqr-1N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
      6. distribute-neg-outN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
      7. sub-flipN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      11. sub-flipN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      12. associate-+l+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
      13. associate--r+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
      14. metadata-evalN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    4. Taylor expanded in uy around 0

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

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

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

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

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

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

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      7. lower--.f3279.7%

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
    6. Applied rewrites79.7%

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

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      2. sub-flipN/A

        \[\leadsto \sqrt{\left(maxCos \cdot ux + \left(\mathsf{neg}\left(ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      3. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) + maxCos \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      4. add-flipN/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      5. mul-1-negN/A

        \[\leadsto \sqrt{\left(-1 \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      7. lift-*.f32N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      8. distribute-lft-neg-outN/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos\right)\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      9. distribute-rgt-out--N/A

        \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) - \left(\mathsf{neg}\left(maxCos\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      10. add-flipN/A

        \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) + maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      11. +-commutativeN/A

        \[\leadsto \sqrt{\left(ux \cdot \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      12. sub-flipN/A

        \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      13. lift--.f32N/A

        \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      14. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      15. lower-*.f3279.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
    8. Applied rewrites79.7%

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

    if 1.95000001e-4 < uy

    1. Initial program 57.6%

      \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      2. sub-negate-revN/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
      4. difference-of-sqr-1N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
      6. distribute-neg-outN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
      7. sub-flipN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      11. sub-flipN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      12. associate-+l+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
      13. associate--r+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
      14. metadata-evalN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    4. Taylor expanded in ux around 0

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \color{blue}{\left(maxCos - 1\right)}\right)} \]
      2. lower--.f3298.9%

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - \color{blue}{1}\right)\right)} \]
    6. Applied rewrites98.9%

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

        \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      2. cos-neg-revN/A

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

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

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

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

        \[\leadsto \sin \left(\left(\mathsf{neg}\left(\color{blue}{\pi \cdot \left(uy \cdot 2\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      7. distribute-rgt-neg-outN/A

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

        \[\leadsto \sin \left(\pi \cdot \left(\mathsf{neg}\left(\color{blue}{uy \cdot 2}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      9. distribute-rgt-neg-outN/A

        \[\leadsto \sin \left(\pi \cdot \color{blue}{\left(uy \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      10. metadata-evalN/A

        \[\leadsto \sin \left(\pi \cdot \left(uy \cdot \color{blue}{-2}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      11. lift-PI.f32N/A

        \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \frac{\color{blue}{\pi}}{2}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      12. mult-flipN/A

        \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      13. metadata-evalN/A

        \[\leadsto \sin \left(\pi \cdot \left(uy \cdot -2\right) + \pi \cdot \color{blue}{\frac{1}{2}}\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      14. distribute-lft-outN/A

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

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

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

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

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

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

        \[\leadsto \sin \left(\pi \cdot \mathsf{fma}\left(uy, -2, \frac{1}{2}\right)\right) \cdot \sqrt{-1 \cdot \left(ux \cdot \color{blue}{\left(ux - 2\right)}\right)} \]
      3. lower--.f3292.8%

        \[\leadsto \sin \left(\pi \cdot \mathsf{fma}\left(uy, -2, 0.5\right)\right) \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - \color{blue}{2}\right)\right)} \]
    11. Applied rewrites92.8%

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

Alternative 6: 96.3% accurate, 1.2× speedup?

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

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


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

    1. Initial program 57.6%

      \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      2. sub-negate-revN/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
      4. difference-of-sqr-1N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
      6. distribute-neg-outN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
      7. sub-flipN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      11. sub-flipN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      12. associate-+l+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
      13. associate--r+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
      14. metadata-evalN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    4. Taylor expanded in uy around 0

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

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

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

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

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

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

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      7. lower--.f3279.7%

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
    6. Applied rewrites79.7%

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

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      2. sub-flipN/A

        \[\leadsto \sqrt{\left(maxCos \cdot ux + \left(\mathsf{neg}\left(ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      3. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) + maxCos \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      4. add-flipN/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      5. mul-1-negN/A

        \[\leadsto \sqrt{\left(-1 \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      7. lift-*.f32N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      8. distribute-lft-neg-outN/A

        \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos\right)\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      9. distribute-rgt-out--N/A

        \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) - \left(\mathsf{neg}\left(maxCos\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      10. add-flipN/A

        \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) + maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      11. +-commutativeN/A

        \[\leadsto \sqrt{\left(ux \cdot \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      12. sub-flipN/A

        \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      13. lift--.f32N/A

        \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      14. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      15. lower-*.f3279.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
    8. Applied rewrites79.7%

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

    if 1.95000001e-4 < uy

    1. Initial program 57.6%

      \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      2. sub-negate-revN/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
      4. difference-of-sqr-1N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
      6. distribute-neg-outN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
      7. sub-flipN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      11. sub-flipN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      12. associate-+l+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
      13. associate--r+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
      14. metadata-evalN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    4. Taylor expanded in uy around 0

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

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

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

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

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

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

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      7. lower--.f3279.7%

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
    6. Applied rewrites79.7%

      \[\leadsto \color{blue}{\sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)}} \]
    7. Applied rewrites21.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)} \]
      9. lower--.f3292.7%

        \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)} \]
    10. Applied rewrites92.7%

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

Alternative 7: 90.3% accurate, 0.7× speedup?

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

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


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

    1. Initial program 57.6%

      \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      2. sub-negate-revN/A

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
      4. difference-of-sqr-1N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
      6. distribute-neg-outN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
      7. sub-flipN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      11. sub-flipN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
      12. associate-+l+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
      13. associate--r+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
      14. metadata-evalN/A

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

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

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
    4. Taylor expanded in ux around 0

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{-2} \cdot \left(maxCos \cdot ux - ux\right)} \]
    5. Step-by-step derivation
      1. Applied rewrites76.4%

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

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

          \[\leadsto \cos \left(\color{blue}{\left(2 \cdot uy\right)} \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(maxCos \cdot ux - ux\right)} \]
        3. count-2-revN/A

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

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

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

      if 0.999996483 < (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32)))

      1. Initial program 57.6%

        \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negate-revN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
        4. difference-of-sqr-1N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
        5. distribute-lft-neg-inN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
        6. distribute-neg-outN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
        7. sub-flipN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        11. sub-flipN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        12. associate-+l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
        13. associate--r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
        14. metadata-evalN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      4. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lower--.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. Applied rewrites79.7%

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        2. sub-flipN/A

          \[\leadsto \sqrt{\left(maxCos \cdot ux + \left(\mathsf{neg}\left(ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        3. +-commutativeN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) + maxCos \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        4. add-flipN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        5. mul-1-negN/A

          \[\leadsto \sqrt{\left(-1 \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        6. metadata-evalN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lift-*.f32N/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        8. distribute-lft-neg-outN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos\right)\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        9. distribute-rgt-out--N/A

          \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) - \left(\mathsf{neg}\left(maxCos\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        10. add-flipN/A

          \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) + maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        11. +-commutativeN/A

          \[\leadsto \sqrt{\left(ux \cdot \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        12. sub-flipN/A

          \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        13. lift--.f32N/A

          \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        14. *-commutativeN/A

          \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        15. lower-*.f3279.7%

          \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      8. Applied rewrites79.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
    6. Recombined 2 regimes into one program.
    7. Add Preprocessing

    Alternative 8: 89.2% accurate, 0.7× speedup?

    \[\begin{array}{l} t_0 := \cos \left(\left(uy \cdot 2\right) \cdot \pi\right)\\ \mathbf{if}\;t\_0 \leq 0.9999399781227112:\\ \;\;\;\;t\_0 \cdot \sqrt{ux \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)}\\ \end{array} \]
    (FPCore (ux uy maxCos)
      :precision binary32
      (let* ((t_0 (cos (* (* uy 2.0) PI))))
      (if (<= t_0 0.9999399781227112)
        (* t_0 (sqrt (* ux 2.0)))
        (sqrt (* (* (- maxCos 1.0) ux) (- (* ux (- 1.0 maxCos)) 2.0))))))
    float code(float ux, float uy, float maxCos) {
    	float t_0 = cosf(((uy * 2.0f) * ((float) M_PI)));
    	float tmp;
    	if (t_0 <= 0.9999399781227112f) {
    		tmp = t_0 * sqrtf((ux * 2.0f));
    	} else {
    		tmp = sqrtf((((maxCos - 1.0f) * ux) * ((ux * (1.0f - maxCos)) - 2.0f)));
    	}
    	return tmp;
    }
    
    function code(ux, uy, maxCos)
    	t_0 = cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi)))
    	tmp = Float32(0.0)
    	if (t_0 <= Float32(0.9999399781227112))
    		tmp = Float32(t_0 * sqrt(Float32(ux * Float32(2.0))));
    	else
    		tmp = sqrt(Float32(Float32(Float32(maxCos - Float32(1.0)) * ux) * Float32(Float32(ux * Float32(Float32(1.0) - maxCos)) - Float32(2.0))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(ux, uy, maxCos)
    	t_0 = cos(((uy * single(2.0)) * single(pi)));
    	tmp = single(0.0);
    	if (t_0 <= single(0.9999399781227112))
    		tmp = t_0 * sqrt((ux * single(2.0)));
    	else
    		tmp = sqrt((((maxCos - single(1.0)) * ux) * ((ux * (single(1.0) - maxCos)) - single(2.0))));
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    t_0 := \cos \left(\left(uy \cdot 2\right) \cdot \pi\right)\\
    \mathbf{if}\;t\_0 \leq 0.9999399781227112:\\
    \;\;\;\;t\_0 \cdot \sqrt{ux \cdot 2}\\
    
    \mathbf{else}:\\
    \;\;\;\;\sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)}\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) < 0.999939978

      1. Initial program 57.6%

        \[\cos \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 \cos \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 \cos \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 \cos \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 \cos \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 \cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot 2} \]
      6. Step-by-step derivation
        1. Applied rewrites72.8%

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot 2} \]

        if 0.999939978 < (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32)))

        1. Initial program 57.6%

          \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
          2. sub-negate-revN/A

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

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
          4. difference-of-sqr-1N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
          5. distribute-lft-neg-inN/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
          6. distribute-neg-outN/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
          7. sub-flipN/A

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

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

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

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
          11. sub-flipN/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
          12. associate-+l+N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
          13. associate--r+N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
          14. metadata-evalN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
        4. Taylor expanded in uy around 0

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

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

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

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

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

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

            \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          7. lower--.f3279.7%

            \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        6. Applied rewrites79.7%

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

            \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          2. sub-flipN/A

            \[\leadsto \sqrt{\left(maxCos \cdot ux + \left(\mathsf{neg}\left(ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          3. +-commutativeN/A

            \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) + maxCos \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          4. add-flipN/A

            \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          5. mul-1-negN/A

            \[\leadsto \sqrt{\left(-1 \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          6. metadata-evalN/A

            \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          7. lift-*.f32N/A

            \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          8. distribute-lft-neg-outN/A

            \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos\right)\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          9. distribute-rgt-out--N/A

            \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) - \left(\mathsf{neg}\left(maxCos\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          10. add-flipN/A

            \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) + maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          11. +-commutativeN/A

            \[\leadsto \sqrt{\left(ux \cdot \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          12. sub-flipN/A

            \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          13. lift--.f32N/A

            \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          14. *-commutativeN/A

            \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
          15. lower-*.f3279.7%

            \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        8. Applied rewrites79.7%

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

      Alternative 9: 79.7% accurate, 3.4× speedup?

      \[\sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (sqrt (* (* (- maxCos 1.0) ux) (- (* ux (- 1.0 maxCos)) 2.0))))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf((((maxCos - 1.0f) * ux) * ((ux * (1.0f - maxCos)) - 2.0f)));
      }
      
      real(4) function code(ux, uy, maxcos)
      use fmin_fmax_functions
          real(4), intent (in) :: ux
          real(4), intent (in) :: uy
          real(4), intent (in) :: maxcos
          code = sqrt((((maxcos - 1.0e0) * ux) * ((ux * (1.0e0 - maxcos)) - 2.0e0)))
      end function
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(Float32(Float32(maxCos - Float32(1.0)) * ux) * Float32(Float32(ux * Float32(Float32(1.0) - maxCos)) - Float32(2.0))))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = sqrt((((maxCos - single(1.0)) * ux) * ((ux * (single(1.0) - maxCos)) - single(2.0))));
      end
      
      \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)}
      
      Derivation
      1. Initial program 57.6%

        \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negate-revN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
        4. difference-of-sqr-1N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
        5. distribute-lft-neg-inN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
        6. distribute-neg-outN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
        7. sub-flipN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        11. sub-flipN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        12. associate-+l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
        13. associate--r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
        14. metadata-evalN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      4. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lower--.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. Applied rewrites79.7%

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        2. sub-flipN/A

          \[\leadsto \sqrt{\left(maxCos \cdot ux + \left(\mathsf{neg}\left(ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        3. +-commutativeN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) + maxCos \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        4. add-flipN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        5. mul-1-negN/A

          \[\leadsto \sqrt{\left(-1 \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        6. metadata-evalN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lift-*.f32N/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        8. distribute-lft-neg-outN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(1\right)\right) \cdot ux - \left(\mathsf{neg}\left(maxCos\right)\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        9. distribute-rgt-out--N/A

          \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) - \left(\mathsf{neg}\left(maxCos\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        10. add-flipN/A

          \[\leadsto \sqrt{\left(ux \cdot \left(\left(\mathsf{neg}\left(1\right)\right) + maxCos\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        11. +-commutativeN/A

          \[\leadsto \sqrt{\left(ux \cdot \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        12. sub-flipN/A

          \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        13. lift--.f32N/A

          \[\leadsto \sqrt{\left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        14. *-commutativeN/A

          \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        15. lower-*.f3279.7%

          \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      8. Applied rewrites79.7%

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

      Alternative 10: 79.7% accurate, 3.5× speedup?

      \[\sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (sqrt (* (* (- maxCos 1.0) ux) (- ux (fma maxCos ux 2.0)))))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf((((maxCos - 1.0f) * ux) * (ux - fmaf(maxCos, ux, 2.0f))));
      }
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(Float32(Float32(maxCos - Float32(1.0)) * ux) * Float32(ux - fma(maxCos, ux, Float32(2.0)))))
      end
      
      \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)}
      
      Derivation
      1. Initial program 57.6%

        \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negate-revN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
        4. difference-of-sqr-1N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
        5. distribute-lft-neg-inN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
        6. distribute-neg-outN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
        7. sub-flipN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        11. sub-flipN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        12. associate-+l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
        13. associate--r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
        14. metadata-evalN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      4. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lower--.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. Applied rewrites79.7%

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 - maxCos\right) \cdot ux - 2\right)} \]
        5. sub-flipN/A

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + \left(\mathsf{neg}\left(maxCos\right)\right)\right) \cdot ux - 2\right)} \]
        6. +-commutativeN/A

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(\left(\left(\mathsf{neg}\left(maxCos\right)\right) + 1\right) \cdot ux - 2\right)} \]
        7. distribute-rgt1-inN/A

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(\left(ux + \left(\mathsf{neg}\left(maxCos\right)\right) \cdot ux\right) - 2\right)} \]
        8. fp-cancel-sub-sign-invN/A

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(\left(ux - maxCos \cdot ux\right) - 2\right)} \]
        10. associate--l-N/A

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux - \left(maxCos \cdot ux + 2\right)\right)} \]
        12. lift-*.f32N/A

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux - \left(maxCos \cdot ux + 2\right)\right)} \]
        13. lower-fma.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
      8. Applied rewrites79.7%

        \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
      9. Step-by-step derivation
        1. remove-double-negN/A

          \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        2. lift--.f32N/A

          \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(maxCos \cdot ux - ux\right)\right)\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        3. sub-negate-revN/A

          \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(ux - maxCos \cdot ux\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        4. sub-flipN/A

          \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(ux + \left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        5. distribute-neg-inN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(ux\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        6. lift-neg.f32N/A

          \[\leadsto \sqrt{\left(\left(-ux\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        7. lift-*.f32N/A

          \[\leadsto \sqrt{\left(\left(-ux\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(maxCos \cdot ux\right)\right)\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        8. distribute-lft-neg-outN/A

          \[\leadsto \sqrt{\left(\left(-ux\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(maxCos\right)\right) \cdot ux\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        9. distribute-rgt-neg-inN/A

          \[\leadsto \sqrt{\left(\left(-ux\right) + \left(\mathsf{neg}\left(maxCos\right)\right) \cdot \left(\mathsf{neg}\left(ux\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        10. lift-neg.f32N/A

          \[\leadsto \sqrt{\left(\left(-ux\right) + \left(\mathsf{neg}\left(maxCos\right)\right) \cdot \left(-ux\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        11. distribute-rgt1-inN/A

          \[\leadsto \sqrt{\left(\left(\left(\mathsf{neg}\left(maxCos\right)\right) + 1\right) \cdot \left(-ux\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        12. +-commutativeN/A

          \[\leadsto \sqrt{\left(\left(1 + \left(\mathsf{neg}\left(maxCos\right)\right)\right) \cdot \left(-ux\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        13. sub-flipN/A

          \[\leadsto \sqrt{\left(\left(1 - maxCos\right) \cdot \left(-ux\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        14. lift--.f32N/A

          \[\leadsto \sqrt{\left(\left(1 - maxCos\right) \cdot \left(-ux\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        15. lift-neg.f32N/A

          \[\leadsto \sqrt{\left(\left(1 - maxCos\right) \cdot \left(\mathsf{neg}\left(ux\right)\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        16. distribute-rgt-neg-inN/A

          \[\leadsto \sqrt{\left(\mathsf{neg}\left(\left(1 - maxCos\right) \cdot ux\right)\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        17. distribute-lft-neg-outN/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(\left(1 - maxCos\right)\right)\right) \cdot ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        18. lift--.f32N/A

          \[\leadsto \sqrt{\left(\left(\mathsf{neg}\left(\left(1 - maxCos\right)\right)\right) \cdot ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        19. sub-negate-revN/A

          \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        20. lift--.f32N/A

          \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
        21. lower-*.f3279.7%

          \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
      10. Applied rewrites79.7%

        \[\leadsto \sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right)} \]
      11. Add Preprocessing

      Alternative 11: 75.3% accurate, 5.9× speedup?

      \[\sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)} \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (sqrt (* -1.0 (* ux (- ux 2.0)))))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf((-1.0f * (ux * (ux - 2.0f))));
      }
      
      real(4) function code(ux, uy, maxcos)
      use fmin_fmax_functions
          real(4), intent (in) :: ux
          real(4), intent (in) :: uy
          real(4), intent (in) :: maxcos
          code = sqrt(((-1.0e0) * (ux * (ux - 2.0e0))))
      end function
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(Float32(-1.0) * Float32(ux * Float32(ux - Float32(2.0)))))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = sqrt((single(-1.0) * (ux * (ux - single(2.0)))));
      end
      
      \sqrt{-1 \cdot \left(ux \cdot \left(ux - 2\right)\right)}
      
      Derivation
      1. Initial program 57.6%

        \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negate-revN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
        4. difference-of-sqr-1N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
        5. distribute-lft-neg-inN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
        6. distribute-neg-outN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
        7. sub-flipN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        11. sub-flipN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        12. associate-+l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
        13. associate--r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
        14. metadata-evalN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      4. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lower--.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. Applied rewrites79.7%

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

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

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

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

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

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

      Alternative 12: 64.3% accurate, 5.9× speedup?

      \[\sqrt{-2 \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (sqrt (* -2.0 (* ux (- maxCos 1.0)))))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf((-2.0f * (ux * (maxCos - 1.0f))));
      }
      
      real(4) function code(ux, uy, maxcos)
      use fmin_fmax_functions
          real(4), intent (in) :: ux
          real(4), intent (in) :: uy
          real(4), intent (in) :: maxcos
          code = sqrt(((-2.0e0) * (ux * (maxcos - 1.0e0))))
      end function
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(Float32(-2.0) * Float32(ux * Float32(maxCos - Float32(1.0)))))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = sqrt((single(-2.0) * (ux * (maxCos - single(1.0)))));
      end
      
      \sqrt{-2 \cdot \left(ux \cdot \left(maxCos - 1\right)\right)}
      
      Derivation
      1. Initial program 57.6%

        \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negate-revN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
        4. difference-of-sqr-1N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
        5. distribute-lft-neg-inN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
        6. distribute-neg-outN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
        7. sub-flipN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        11. sub-flipN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        12. associate-+l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
        13. associate--r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
        14. metadata-evalN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      4. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lower--.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. Applied rewrites79.7%

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

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

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

          \[\leadsto \sqrt{-2 \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
        3. lower--.f3264.3%

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

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

      Alternative 13: 21.5% accurate, 6.1× speedup?

      \[\sqrt{\left(uy + uy\right) - uy \cdot uy} \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (sqrt (- (+ uy uy) (* uy uy))))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf(((uy + uy) - (uy * uy)));
      }
      
      real(4) function code(ux, uy, maxcos)
      use fmin_fmax_functions
          real(4), intent (in) :: ux
          real(4), intent (in) :: uy
          real(4), intent (in) :: maxcos
          code = sqrt(((uy + uy) - (uy * uy)))
      end function
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(Float32(uy + uy) - Float32(uy * uy)))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = sqrt(((uy + uy) - (uy * uy)));
      end
      
      \sqrt{\left(uy + uy\right) - uy \cdot uy}
      
      Derivation
      1. Initial program 57.6%

        \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negate-revN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
        4. difference-of-sqr-1N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
        5. distribute-lft-neg-inN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
        6. distribute-neg-outN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
        7. sub-flipN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        11. sub-flipN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        12. associate-+l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
        13. associate--r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
        14. metadata-evalN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      4. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lower--.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. Applied rewrites79.7%

        \[\leadsto \color{blue}{\sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)}} \]
      7. Applied rewrites21.5%

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

      Alternative 14: 21.5% accurate, 7.9× speedup?

      \[\sqrt{\left(2 - uy\right) \cdot uy} \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (sqrt (* (- 2.0 uy) uy)))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf(((2.0f - uy) * uy));
      }
      
      real(4) function code(ux, uy, maxcos)
      use fmin_fmax_functions
          real(4), intent (in) :: ux
          real(4), intent (in) :: uy
          real(4), intent (in) :: maxcos
          code = sqrt(((2.0e0 - uy) * uy))
      end function
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(Float32(Float32(2.0) - uy) * uy))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = sqrt(((single(2.0) - uy) * uy));
      end
      
      \sqrt{\left(2 - uy\right) \cdot uy}
      
      Derivation
      1. Initial program 57.6%

        \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negate-revN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
        4. difference-of-sqr-1N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
        5. distribute-lft-neg-inN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
        6. distribute-neg-outN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
        7. sub-flipN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        11. sub-flipN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        12. associate-+l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
        13. associate--r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
        14. metadata-evalN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      4. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lower--.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. Applied rewrites79.7%

        \[\leadsto \color{blue}{\sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)}} \]
      7. Applied rewrites21.5%

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

      Alternative 15: 21.5% accurate, 11.3× speedup?

      \[\sqrt{2 \cdot uy} \]
      (FPCore (ux uy maxCos)
        :precision binary32
        (sqrt (* 2.0 uy)))
      float code(float ux, float uy, float maxCos) {
      	return sqrtf((2.0f * uy));
      }
      
      real(4) function code(ux, uy, maxcos)
      use fmin_fmax_functions
          real(4), intent (in) :: ux
          real(4), intent (in) :: uy
          real(4), intent (in) :: maxcos
          code = sqrt((2.0e0 * uy))
      end function
      
      function code(ux, uy, maxCos)
      	return sqrt(Float32(Float32(2.0) * uy))
      end
      
      function tmp = code(ux, uy, maxCos)
      	tmp = sqrt((single(2.0) * uy));
      end
      
      \sqrt{2 \cdot uy}
      
      Derivation
      1. Initial program 57.6%

        \[\cos \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 \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
        2. sub-negate-revN/A

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} - 1\right)\right)} \]
        4. difference-of-sqr-1N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\color{blue}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}\right)} \]
        5. distribute-lft-neg-inN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left(\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) + 1\right)\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)}} \]
        6. distribute-neg-outN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) - 1\right)} \]
        7. sub-flipN/A

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

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

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

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        11. sub-flipN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)} + ux \cdot maxCos\right)\right)\right)\right)} \]
        12. associate-+l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\left(1 - \color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)\right)} \]
        13. associate--r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(1 - 1\right) - \left(\left(\mathsf{neg}\left(ux\right)\right) + ux \cdot maxCos\right)\right)}\right)\right)} \]
        14. metadata-evalN/A

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

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

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

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 - maxCos, -2\right) \cdot \left(maxCos \cdot ux - ux\right)}} \]
      4. Taylor expanded in uy around 0

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

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

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

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

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

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

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
        7. lower--.f3279.7%

          \[\leadsto \sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)} \]
      6. Applied rewrites79.7%

        \[\leadsto \color{blue}{\sqrt{\left(maxCos \cdot ux - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right) - 2\right)}} \]
      7. Applied rewrites21.5%

        \[\leadsto \sqrt{\left(2 - uy\right) \cdot uy} \]
      8. Taylor expanded in uy around 0

        \[\leadsto \sqrt{2 \cdot uy} \]
      9. Step-by-step derivation
        1. lower-sqrt.f32N/A

          \[\leadsto \sqrt{2 \cdot uy} \]
        2. lower-*.f3221.5%

          \[\leadsto \sqrt{2 \cdot uy} \]
      10. Applied rewrites21.5%

        \[\leadsto \sqrt{2 \cdot uy} \]
      11. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2025322 
      (FPCore (ux uy maxCos)
        :name "UniformSampleCone, x"
        :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)))
        (* (cos (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))