UniformSampleCone, x

Percentage Accurate: 58.0% → 99.1%
Time: 5.0s
Alternatives: 13
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
  :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)))
  (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 13 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: 58.0% accurate, 1.0× speedup?

\[\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
  :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)))
  (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, 0.9× speedup?

\[\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 := ux - maxCos \cdot ux\\ \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right) \cdot \sqrt{\left(t\_0 - 0\right) \cdot \left(-\left(t\_0 - 2\right)\right)} \end{array} \]
(FPCore (ux uy maxCos)
  :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)))
  (let* ((t_0 (- ux (* maxCos ux))))
  (*
   (sin (fma (- PI) (+ uy uy) (* PI 0.5)))
   (sqrt (* (- t_0 0.0) (- (- t_0 2.0)))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = ux - (maxCos * ux);
	return sinf(fmaf(-((float) M_PI), (uy + uy), (((float) M_PI) * 0.5f))) * sqrtf(((t_0 - 0.0f) * -(t_0 - 2.0f)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(ux - Float32(maxCos * ux))
	return Float32(sin(fma(Float32(-Float32(pi)), Float32(uy + uy), Float32(Float32(pi) * Float32(0.5)))) * sqrt(Float32(Float32(t_0 - Float32(0.0)) * Float32(-Float32(t_0 - Float32(2.0))))))
end
\begin{array}{l}
t_0 := ux - maxCos \cdot ux\\
\sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right) \cdot \sqrt{\left(t\_0 - 0\right) \cdot \left(-\left(t\_0 - 2\right)\right)}
\end{array}
Derivation
  1. Initial program 58.0%

    \[\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. sqr-neg-revN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. 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(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + 1\right) \cdot \left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)}\right)} \]
    6. distribute-rgt-neg-inN/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
    7. lower-*.f32N/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
  3. Applied rewrites98.9%

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

      \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\right)\right)} \]
  5. Applied rewrites99.1%

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

Alternative 2: 98.9% accurate, 1.1× speedup?

\[\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)\]
\[\sqrt{\mathsf{fma}\left(ux, maxCos, 2 - ux\right) \cdot \left(ux - maxCos \cdot ux\right)} \cdot \cos \left(\pi \cdot \left(uy + uy\right)\right) \]
(FPCore (ux uy maxCos)
  :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)))
  (*
 (sqrt (* (fma ux maxCos (- 2.0 ux)) (- ux (* maxCos ux))))
 (cos (* PI (+ uy uy)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((fmaf(ux, maxCos, (2.0f - ux)) * (ux - (maxCos * ux)))) * cosf((((float) M_PI) * (uy + uy)));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(Float32(fma(ux, maxCos, Float32(Float32(2.0) - ux)) * Float32(ux - Float32(maxCos * ux)))) * cos(Float32(Float32(pi) * Float32(uy + uy))))
end
\sqrt{\mathsf{fma}\left(ux, maxCos, 2 - ux\right) \cdot \left(ux - maxCos \cdot ux\right)} \cdot \cos \left(\pi \cdot \left(uy + uy\right)\right)
Derivation
  1. Initial program 58.0%

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

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

      \[\leadsto \cos \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. add-cube-cbrtN/A

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

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

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

      \[\leadsto \cos \left(\left(\sqrt[3]{\color{blue}{\pi}} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    8. pow1/3N/A

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

      \[\leadsto \cos \left(\left({\pi}^{\frac{1}{3}} \cdot \sqrt[3]{\color{blue}{\pi}}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    10. pow1/3N/A

      \[\leadsto \cos \left(\left({\pi}^{\frac{1}{3}} \cdot \color{blue}{{\pi}^{\frac{1}{3}}}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    11. pow-prod-upN/A

      \[\leadsto \cos \left(\color{blue}{{\pi}^{\left(\frac{1}{3} + \frac{1}{3}\right)}} \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    12. lower-pow.f32N/A

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

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

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

      \[\leadsto \cos \left({\pi}^{\frac{2}{3}} \cdot \left(\sqrt[3]{\color{blue}{\pi}} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    16. lower-cbrt.f3258.0%

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

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

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

      \[\leadsto \cos \left({\pi}^{\frac{2}{3}} \cdot \left(\sqrt[3]{\pi} \cdot \color{blue}{\left(uy + uy\right)}\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    20. lower-+.f3258.0%

      \[\leadsto \cos \left({\pi}^{0.6666666666666666} \cdot \left(\sqrt[3]{\pi} \cdot \color{blue}{\left(uy + uy\right)}\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  3. Applied rewrites58.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.9% accurate, 1.1× speedup?

\[\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)\]
\[\sqrt{\left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right) \cdot \left(ux - maxCos \cdot ux\right)} \cdot \cos \left(\pi \cdot \left(uy + uy\right)\right) \]
(FPCore (ux uy maxCos)
  :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)))
  (*
 (sqrt (* (- (fma maxCos ux 2.0) ux) (- ux (* maxCos ux))))
 (cos (* PI (+ uy uy)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(((fmaf(maxCos, ux, 2.0f) - ux) * (ux - (maxCos * ux)))) * cosf((((float) M_PI) * (uy + uy)));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(Float32(Float32(fma(maxCos, ux, Float32(2.0)) - ux) * Float32(ux - Float32(maxCos * ux)))) * cos(Float32(Float32(pi) * Float32(uy + uy))))
end
\sqrt{\left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right) \cdot \left(ux - maxCos \cdot ux\right)} \cdot \cos \left(\pi \cdot \left(uy + uy\right)\right)
Derivation
  1. Initial program 58.0%

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

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

      \[\leadsto \cos \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. add-cube-cbrtN/A

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

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

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

      \[\leadsto \cos \left(\left(\sqrt[3]{\color{blue}{\pi}} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    8. pow1/3N/A

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

      \[\leadsto \cos \left(\left({\pi}^{\frac{1}{3}} \cdot \sqrt[3]{\color{blue}{\pi}}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    10. pow1/3N/A

      \[\leadsto \cos \left(\left({\pi}^{\frac{1}{3}} \cdot \color{blue}{{\pi}^{\frac{1}{3}}}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    11. pow-prod-upN/A

      \[\leadsto \cos \left(\color{blue}{{\pi}^{\left(\frac{1}{3} + \frac{1}{3}\right)}} \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    12. lower-pow.f32N/A

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

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

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

      \[\leadsto \cos \left({\pi}^{\frac{2}{3}} \cdot \left(\sqrt[3]{\color{blue}{\pi}} \cdot \left(uy \cdot 2\right)\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    16. lower-cbrt.f3258.0%

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

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

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

      \[\leadsto \cos \left({\pi}^{\frac{2}{3}} \cdot \left(\sqrt[3]{\pi} \cdot \color{blue}{\left(uy + uy\right)}\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    20. lower-+.f3258.0%

      \[\leadsto \cos \left({\pi}^{0.6666666666666666} \cdot \left(\sqrt[3]{\pi} \cdot \color{blue}{\left(uy + uy\right)}\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  3. Applied rewrites58.0%

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

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

Alternative 4: 97.5% accurate, 1.1× speedup?

\[\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)\]
\[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(2 - ux\right)} \]
(FPCore (ux uy maxCos)
  :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 (* (- (- ux (* maxCos ux)) 0.0) (- 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
	return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((((ux - (maxCos * ux)) - 0.0f) * (2.0f - ux)));
}
function code(ux, uy, maxCos)
	return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(Float32(ux - Float32(maxCos * ux)) - Float32(0.0)) * Float32(Float32(2.0) - ux))))
end
function tmp = code(ux, uy, maxCos)
	tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((((ux - (maxCos * ux)) - single(0.0)) * (single(2.0) - ux)));
end
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(2 - ux\right)}
Derivation
  1. Initial program 58.0%

    \[\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. sqr-neg-revN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. 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(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + 1\right) \cdot \left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)}\right)} \]
    6. distribute-rgt-neg-inN/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
    7. lower-*.f32N/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
  3. Applied rewrites98.9%

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

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

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

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

Alternative 5: 96.4% accurate, 0.7× speedup?

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

\mathbf{else}:\\
\;\;\;\;\sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}\\


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

    1. Initial program 58.0%

      \[\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. sqr-neg-revN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
      5. 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(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + 1\right) \cdot \left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)}\right)} \]
      6. distribute-rgt-neg-inN/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
      7. lower-*.f32N/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
    3. Applied rewrites98.9%

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

        \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\right)\right)} \]
    5. Applied rewrites99.1%

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

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

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

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

      \[\leadsto \sin \left(\mathsf{fma}\left(-\pi, uy + uy, \pi \cdot 0.5\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \]

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

    1. Initial program 58.0%

      \[\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{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      2. sqr-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)} \]
      8. lower-+.f32N/A

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

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

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

Alternative 6: 96.3% accurate, 1.1× speedup?

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

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


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

    1. Initial program 58.0%

      \[\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{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      2. sqr-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)} \]
      8. lower-+.f32N/A

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

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

      \[\leadsto \color{blue}{\sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}} \]

    if 2.20000002e-4 < uy

    1. Initial program 58.0%

      \[\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. sqr-neg-revN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
      5. 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(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + 1\right) \cdot \left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)}\right)} \]
      6. distribute-rgt-neg-inN/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
      7. lower-*.f32N/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
    3. Applied rewrites98.9%

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

        \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \pi\right)} \cdot \sqrt{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\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{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\right)\right)} \]
    5. Applied rewrites99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 96.3% accurate, 1.2× speedup?

\[\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} \mathbf{if}\;uy \leq 0.00022000000171829015:\\ \;\;\;\;\sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\ \end{array} \]
(FPCore (ux uy maxCos)
  :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)))
  (if (<= uy 0.00022000000171829015)
  (sqrt
   (-
    ux
    (fma
     maxCos
     ux
     (* (- (* maxCos ux) ux) (- (+ 1.0 (* maxCos ux)) ux)))))
  (* (cos (* (* uy 2.0) PI)) (sqrt (* ux (- 2.0 ux))))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if (uy <= 0.00022000000171829015f) {
		tmp = sqrtf((ux - fmaf(maxCos, ux, (((maxCos * ux) - ux) * ((1.0f + (maxCos * ux)) - ux)))));
	} else {
		tmp = cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * (2.0f - ux)));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	tmp = Float32(0.0)
	if (uy <= Float32(0.00022000000171829015))
		tmp = sqrt(Float32(ux - fma(maxCos, ux, Float32(Float32(Float32(maxCos * ux) - ux) * Float32(Float32(Float32(1.0) + Float32(maxCos * ux)) - ux)))));
	else
		tmp = Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux * Float32(Float32(2.0) - ux))));
	end
	return tmp
end
\begin{array}{l}
\mathbf{if}\;uy \leq 0.00022000000171829015:\\
\;\;\;\;\sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}\\

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


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

    1. Initial program 58.0%

      \[\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{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
      2. sqr-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)} \]
      8. lower-+.f32N/A

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

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

      \[\leadsto \color{blue}{\sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}} \]

    if 2.20000002e-4 < uy

    1. Initial program 58.0%

      \[\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. sqr-neg-revN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
      5. 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(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) + 1\right) \cdot \left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)}\right)} \]
      6. distribute-rgt-neg-inN/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
      7. lower-*.f32N/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(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) - 1\right)\right)\right)}} \]
    3. Applied rewrites98.9%

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

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \]
    5. 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 - ux\right)}} \]
      2. lower--.f3292.6%

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

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

Alternative 8: 79.7% accurate, 2.5× speedup?

\[\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)\]
\[\sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)} \]
(FPCore (ux uy maxCos)
  :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)))
  (sqrt
 (-
  ux
  (fma
   maxCos
   ux
   (* (- (* maxCos ux) ux) (- (+ 1.0 (* maxCos ux)) ux))))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux - fmaf(maxCos, ux, (((maxCos * ux) - ux) * ((1.0f + (maxCos * ux)) - ux)))));
}
function code(ux, uy, maxCos)
	return sqrt(Float32(ux - fma(maxCos, ux, Float32(Float32(Float32(maxCos * ux) - ux) * Float32(Float32(Float32(1.0) + Float32(maxCos * ux)) - ux)))))
end
\sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)}
Derivation
  1. Initial program 58.0%

    \[\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{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
    2. sqr-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)} \]
    8. lower-+.f32N/A

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

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

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

Alternative 9: 79.7% accurate, 3.1× speedup?

\[\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)\]
\[\sqrt{\left(1 + \mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right) \cdot \left(ux - maxCos \cdot ux\right)} \]
(FPCore (ux uy maxCos)
  :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)))
  (sqrt (* (+ 1.0 (fma maxCos ux (- 1.0 ux))) (- ux (* maxCos ux)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(((1.0f + fmaf(maxCos, ux, (1.0f - ux))) * (ux - (maxCos * ux))));
}
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(Float32(1.0) + fma(maxCos, ux, Float32(Float32(1.0) - ux))) * Float32(ux - Float32(maxCos * ux))))
end
\sqrt{\left(1 + \mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right) \cdot \left(ux - maxCos \cdot ux\right)}
Derivation
  1. Initial program 58.0%

    \[\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 uy around 0

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

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

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

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

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

      \[\leadsto \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \]
    6. lower-*.f3249.6%

      \[\leadsto \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \]
  4. Applied rewrites49.6%

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

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

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

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

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

      \[\leadsto \sqrt{1 \cdot 1 - {\left(\left(maxCos \cdot ux + 1\right) - ux\right)}^{2}} \]
    6. associate-+r-N/A

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 \cdot 1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    15. difference-of-squares-revN/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\left(1 + \left(1 - \left(ux - maxCos \cdot ux\right)\right)\right) \cdot \left(ux - maxCos \cdot ux\right)} \]
    11. associate--r-N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 79.7% accurate, 3.5× speedup?

\[\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)\]
\[\sqrt{\mathsf{fma}\left(ux, maxCos, 2 - ux\right) \cdot \left(ux - maxCos \cdot ux\right)} \]
(FPCore (ux uy maxCos)
  :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)))
  (sqrt (* (fma ux maxCos (- 2.0 ux)) (- ux (* maxCos ux)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((fmaf(ux, maxCos, (2.0f - ux)) * (ux - (maxCos * ux))));
}
function code(ux, uy, maxCos)
	return sqrt(Float32(fma(ux, maxCos, Float32(Float32(2.0) - ux)) * Float32(ux - Float32(maxCos * ux))))
end
\sqrt{\mathsf{fma}\left(ux, maxCos, 2 - ux\right) \cdot \left(ux - maxCos \cdot ux\right)}
Derivation
  1. Initial program 58.0%

    \[\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 uy around 0

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

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

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

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

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

      \[\leadsto \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \]
    6. lower-*.f3249.6%

      \[\leadsto \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \]
  4. Applied rewrites49.6%

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

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

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

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

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

      \[\leadsto \sqrt{1 \cdot 1 - {\left(\left(maxCos \cdot ux + 1\right) - ux\right)}^{2}} \]
    6. associate-+r-N/A

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 \cdot 1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    15. difference-of-squares-revN/A

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 79.7% accurate, 3.5× speedup?

\[\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)\]
\[\sqrt{\left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right)} \]
(FPCore (ux uy maxCos)
  :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)))
  (sqrt (* (- (fma maxCos ux 2.0) ux) (* ux (- 1.0 maxCos)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(((fmaf(maxCos, ux, 2.0f) - ux) * (ux * (1.0f - maxCos))));
}
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(fma(maxCos, ux, Float32(2.0)) - ux) * Float32(ux * Float32(Float32(1.0) - maxCos))))
end
\sqrt{\left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right)}
Derivation
  1. Initial program 58.0%

    \[\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 uy around 0

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

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

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

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

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

      \[\leadsto \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \]
    6. lower-*.f3249.6%

      \[\leadsto \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \]
  4. Applied rewrites49.6%

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

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

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

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

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

      \[\leadsto \sqrt{1 \cdot 1 - {\left(\left(maxCos \cdot ux + 1\right) - ux\right)}^{2}} \]
    6. associate-+r-N/A

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{1 \cdot 1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    15. difference-of-squares-revN/A

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

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

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

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

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

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

Alternative 12: 75.4% accurate, 4.8× speedup?

\[\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)\]
\[\sqrt{ux - -1 \cdot \left(ux \cdot \left(1 - ux\right)\right)} \]
(FPCore (ux uy maxCos)
  :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)))
  (sqrt (- ux (* -1.0 (* ux (- 1.0 ux))))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux - (-1.0f * (ux * (1.0f - ux)))));
}
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((ux - ((-1.0e0) * (ux * (1.0e0 - ux)))))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(ux - Float32(Float32(-1.0) * Float32(ux * Float32(Float32(1.0) - ux)))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((ux - (single(-1.0) * (ux * (single(1.0) - ux)))));
end
\sqrt{ux - -1 \cdot \left(ux \cdot \left(1 - ux\right)\right)}
Derivation
  1. Initial program 58.0%

    \[\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{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
    2. sqr-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)} \]
    8. lower-+.f32N/A

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

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

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

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

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

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

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

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

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

Alternative 13: 64.1% accurate, 5.9× speedup?

\[\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)\]
\[\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)} \]
(FPCore (ux uy maxCos)
  :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)))
  (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux * (2.0f - (2.0f * maxCos))));
}
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((ux * (2.0e0 - (2.0e0 * maxcos))))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((ux * (single(2.0) - (single(2.0) * maxCos))));
end
\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}
Derivation
  1. Initial program 58.0%

    \[\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{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
    2. sqr-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux - \mathsf{fma}\left(maxCos, ux, \left(maxCos \cdot ux - ux\right) \cdot \left(\left(1 + maxCos \cdot ux\right) - ux\right)\right)} \]
    8. lower-+.f32N/A

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

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

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

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

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

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

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

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

Reproduce

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