UniformSampleCone, y

Percentage Accurate: 58.2% → 98.3%
Time: 8.1s
Alternatives: 21
Speedup: 4.8×

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 21 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.2% 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\\ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \end{array} \]
(FPCore (ux uy maxCos)
  :precision binary32
  :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))))
  (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* t_0 t_0))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = (single(1.0) - ux) + (ux * maxCos);
	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0)));
end
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}

Alternative 1: 98.3% accurate, 0.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(2 \cdot \frac{1}{ux}, {ux}^{2}, \left(\mathsf{neg}\left(\mathsf{fma}\left(2, \frac{maxCos}{ux}, {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot {ux}^{2}\right)} \]
    8. mult-flip-revN/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(\frac{2}{ux}, ux \cdot ux, \left(\mathsf{neg}\left(\mathsf{fma}\left(2, \frac{maxCos}{ux}, {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot {ux}^{2}\right)} \]
  6. Applied rewrites98.2%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.3% accurate, 0.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)\]
\[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(\frac{2}{ux}, ux \cdot ux, \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) - \frac{maxCos + maxCos}{ux}\right) \cdot \left(ux \cdot 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)))
  (*
 (sin (* (* uy 2.0) PI))
 (sqrt
  (fma
   (/ 2.0 ux)
   (* ux ux)
   (*
    (- (* (- 1.0 maxCos) (- maxCos 1.0)) (/ (+ maxCos maxCos) ux))
    (* ux ux))))))
float code(float ux, float uy, float maxCos) {
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(fmaf((2.0f / ux), (ux * ux), ((((1.0f - maxCos) * (maxCos - 1.0f)) - ((maxCos + maxCos) / ux)) * (ux * ux))));
}
function code(ux, uy, maxCos)
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(fma(Float32(Float32(2.0) / ux), Float32(ux * ux), Float32(Float32(Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos - Float32(1.0))) - Float32(Float32(maxCos + maxCos) / ux)) * Float32(ux * ux)))))
end
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(\frac{2}{ux}, ux \cdot ux, \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right) - \frac{maxCos + maxCos}{ux}\right) \cdot \left(ux \cdot ux\right)\right)}
Derivation
  1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(2 \cdot \frac{1}{ux}, {ux}^{2}, \left(\mathsf{neg}\left(\mathsf{fma}\left(2, \frac{maxCos}{ux}, {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot {ux}^{2}\right)} \]
    8. mult-flip-revN/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(\frac{2}{ux}, ux \cdot ux, \left(\mathsf{neg}\left(\mathsf{fma}\left(2, \frac{maxCos}{ux}, {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot {ux}^{2}\right)} \]
  6. Applied rewrites98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(2 \cdot \frac{1}{ux}, {ux}^{2}, \left(\mathsf{neg}\left(\mathsf{fma}\left(2, \frac{maxCos}{ux}, {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot {ux}^{2}\right)} \]
    8. mult-flip-revN/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(\frac{2}{ux}, ux \cdot ux, \left(\mathsf{neg}\left(\mathsf{fma}\left(2, \frac{maxCos}{ux}, {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot {ux}^{2}\right)} \]
  6. Applied rewrites98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sin \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 ux around 0

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

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

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

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

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

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

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

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

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

Alternative 5: 98.3% 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 := ux - maxCos \cdot ux\\ \sin \left(\left(uy \cdot 2\right) \cdot \pi\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 (* (* uy 2.0) PI)) (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(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((t_0 - 0.0f) * -(t_0 - 2.0f)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(ux - Float32(maxCos * ux))
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(t_0 - Float32(0.0)) * Float32(-Float32(t_0 - Float32(2.0))))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = ux - (maxCos * ux);
	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt(((t_0 - single(0.0)) * -(t_0 - single(2.0))));
end
\begin{array}{l}
t_0 := ux - maxCos \cdot ux\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(t\_0 - 0\right) \cdot \left(-\left(t\_0 - 2\right)\right)}
\end{array}
Derivation
  1. Initial program 58.2%

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

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

    \[\leadsto \sin \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. Add Preprocessing

Alternative 6: 98.2% 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)\]
\[\sqrt{\left|maxCos \cdot ux - ux\right|} \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right|} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\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 (fabs (- (* maxCos ux) ux)))
 (* (sqrt (fabs (- (fma maxCos ux 2.0) ux))) (sin (* PI (+ uy uy))))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(fabsf(((maxCos * ux) - ux))) * (sqrtf(fabsf((fmaf(maxCos, ux, 2.0f) - ux))) * sinf((((float) M_PI) * (uy + uy))));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(abs(Float32(Float32(maxCos * ux) - ux))) * Float32(sqrt(abs(Float32(fma(maxCos, ux, Float32(2.0)) - ux))) * sin(Float32(Float32(pi) * Float32(uy + uy)))))
end
\sqrt{\left|maxCos \cdot ux - ux\right|} \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right|} \cdot \sin \left(\pi \cdot \left(uy + uy\right)\right)\right)
Derivation
  1. Initial program 58.2%

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

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

    \[\leadsto \sin \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-*.f32N/A

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

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

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

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

      \[\leadsto \color{blue}{\left(\sqrt{\left|\left(ux - maxCos \cdot ux\right) - 0\right|} \cdot \sqrt{\left|-\left(\left(ux - maxCos \cdot ux\right) - 2\right)\right|}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \]
    6. associate-*l*N/A

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

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

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

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

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

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

    \[\leadsto \sin \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-*.f32N/A

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

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

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

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

Alternative 8: 97.0% 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.004000000189989805:\\ \;\;\;\;\sqrt{\left|ux - maxCos \cdot ux\right|} \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right|} \cdot \left(\mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333\right) \cdot \pi, \pi \cdot \pi, \pi + \pi\right) \cdot uy\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \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.004000000189989805)
  (*
   (sqrt (fabs (- ux (* maxCos ux))))
   (*
    (sqrt (fabs (- (fma maxCos ux 2.0) ux)))
    (*
     (fma
      (* (* (* uy uy) -1.3333333333333333) PI)
      (* PI PI)
      (+ PI PI))
     uy)))
  (* (sin (* (* uy 2.0) PI)) (sqrt (* ux (- 2.0 ux))))))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if (uy <= 0.004000000189989805f) {
		tmp = sqrtf(fabsf((ux - (maxCos * ux)))) * (sqrtf(fabsf((fmaf(maxCos, ux, 2.0f) - ux))) * (fmaf((((uy * uy) * -1.3333333333333333f) * ((float) M_PI)), (((float) M_PI) * ((float) M_PI)), (((float) M_PI) + ((float) M_PI))) * uy));
	} else {
		tmp = sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * (2.0f - ux)));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	tmp = Float32(0.0)
	if (uy <= Float32(0.004000000189989805))
		tmp = Float32(sqrt(abs(Float32(ux - Float32(maxCos * ux)))) * Float32(sqrt(abs(Float32(fma(maxCos, ux, Float32(2.0)) - ux))) * Float32(fma(Float32(Float32(Float32(uy * uy) * Float32(-1.3333333333333333)) * Float32(pi)), Float32(Float32(pi) * Float32(pi)), Float32(Float32(pi) + Float32(pi))) * uy)));
	else
		tmp = Float32(sin(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.004000000189989805:\\
\;\;\;\;\sqrt{\left|ux - maxCos \cdot ux\right|} \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right|} \cdot \left(\mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333\right) \cdot \pi, \pi \cdot \pi, \pi + \pi\right) \cdot uy\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\sin \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 < 0.00400000019

    1. Initial program 58.2%

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

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

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

      \[\leadsto \color{blue}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\pi}^{3}\right) + 2 \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)} \]
    5. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto \left(uy \cdot \color{blue}{\left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\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)} \]
      2. lower-fma.f32N/A

        \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{{uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-*.f32N/A

        \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
      4. lower-pow.f32N/A

        \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
      5. lower-pow.f32N/A

        \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-PI.f32N/A

        \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
      7. lower-*.f32N/A

        \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
      8. lower-PI.f3289.0%

        \[\leadsto \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
    6. Applied rewrites89.0%

      \[\leadsto \color{blue}{\left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
    7. Applied rewrites88.9%

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

    if 0.00400000019 < uy

    1. Initial program 58.2%

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

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

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

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

      \[\leadsto \sin \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 9: 96.7% 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)\]
\[\sin \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)))
  (*
 (sin (* (* uy 2.0) PI))
 (sqrt (* (- (- ux (* maxCos ux)) 0.0) (- 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((((ux - (maxCos * ux)) - 0.0f) * (2.0f - ux)));
}
function code(ux, uy, maxCos)
	return Float32(sin(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 = sin(((uy * single(2.0)) * single(pi))) * sqrt((((ux - (maxCos * ux)) - single(0.0)) * (single(2.0) - ux)));
end
\sin \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.2%

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

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

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

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

    \[\leadsto \sin \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 10: 89.0% accurate, 1.4× 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)\]
\[\left(\left(\mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333\right) \cdot \pi, \pi \cdot \pi, \pi + \pi\right) \cdot uy\right) \cdot \sqrt{\left|ux - maxCos \cdot ux\right|}\right) \cdot \sqrt{\left|\mathsf{fma}\left(maxCos, ux, 2\right) - 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)))
  (*
 (*
  (*
   (fma (* (* (* uy uy) -1.3333333333333333) PI) (* PI PI) (+ PI PI))
   uy)
  (sqrt (fabs (- ux (* maxCos ux)))))
 (sqrt (fabs (- (fma maxCos ux 2.0) ux)))))
float code(float ux, float uy, float maxCos) {
	return ((fmaf((((uy * uy) * -1.3333333333333333f) * ((float) M_PI)), (((float) M_PI) * ((float) M_PI)), (((float) M_PI) + ((float) M_PI))) * uy) * sqrtf(fabsf((ux - (maxCos * ux))))) * sqrtf(fabsf((fmaf(maxCos, ux, 2.0f) - ux)));
}
function code(ux, uy, maxCos)
	return Float32(Float32(Float32(fma(Float32(Float32(Float32(uy * uy) * Float32(-1.3333333333333333)) * Float32(pi)), Float32(Float32(pi) * Float32(pi)), Float32(Float32(pi) + Float32(pi))) * uy) * sqrt(abs(Float32(ux - Float32(maxCos * ux))))) * sqrt(abs(Float32(fma(maxCos, ux, Float32(2.0)) - ux))))
end
\left(\left(\mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333\right) \cdot \pi, \pi \cdot \pi, \pi + \pi\right) \cdot uy\right) \cdot \sqrt{\left|ux - maxCos \cdot ux\right|}\right) \cdot \sqrt{\left|\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right|}
Derivation
  1. Initial program 58.2%

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

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

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

    \[\leadsto \color{blue}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\pi}^{3}\right) + 2 \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)} \]
  5. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \color{blue}{\left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    2. lower-fma.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{{uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    4. lower-pow.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    5. lower-pow.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-PI.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    7. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    8. lower-PI.f3289.0%

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
  6. Applied rewrites89.0%

    \[\leadsto \color{blue}{\left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
  7. Applied rewrites88.8%

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

Alternative 11: 88.9% accurate, 1.4× 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|ux - maxCos \cdot ux\right|} \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right|} \cdot \left(\mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333\right) \cdot \pi, \pi \cdot \pi, \pi + \pi\right) \cdot 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 (fabs (- ux (* maxCos ux))))
 (*
  (sqrt (fabs (- (fma maxCos ux 2.0) ux)))
  (*
   (fma (* (* (* uy uy) -1.3333333333333333) PI) (* PI PI) (+ PI PI))
   uy))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(fabsf((ux - (maxCos * ux)))) * (sqrtf(fabsf((fmaf(maxCos, ux, 2.0f) - ux))) * (fmaf((((uy * uy) * -1.3333333333333333f) * ((float) M_PI)), (((float) M_PI) * ((float) M_PI)), (((float) M_PI) + ((float) M_PI))) * uy));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(abs(Float32(ux - Float32(maxCos * ux)))) * Float32(sqrt(abs(Float32(fma(maxCos, ux, Float32(2.0)) - ux))) * Float32(fma(Float32(Float32(Float32(uy * uy) * Float32(-1.3333333333333333)) * Float32(pi)), Float32(Float32(pi) * Float32(pi)), Float32(Float32(pi) + Float32(pi))) * uy)))
end
\sqrt{\left|ux - maxCos \cdot ux\right|} \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right|} \cdot \left(\mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333\right) \cdot \pi, \pi \cdot \pi, \pi + \pi\right) \cdot uy\right)\right)
Derivation
  1. Initial program 58.2%

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

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

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

    \[\leadsto \color{blue}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\pi}^{3}\right) + 2 \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)} \]
  5. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \color{blue}{\left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    2. lower-fma.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{{uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    4. lower-pow.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    5. lower-pow.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-PI.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    7. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    8. lower-PI.f3289.0%

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
  6. Applied rewrites89.0%

    \[\leadsto \color{blue}{\left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
  7. Applied rewrites88.9%

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

Alternative 12: 88.8% accurate, 1.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 - maxCos \cdot ux\right)} \cdot \left(\mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333\right) \cdot \pi, \pi \cdot \pi, \pi + \pi\right) \cdot uy\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))))
 (*
  (fma (* (* (* uy uy) -1.3333333333333333) PI) (* PI PI) (+ PI PI))
  uy)))
float code(float ux, float uy, float maxCos) {
	return sqrtf(((fmaf(maxCos, ux, 2.0f) - ux) * (ux - (maxCos * ux)))) * (fmaf((((uy * uy) * -1.3333333333333333f) * ((float) M_PI)), (((float) M_PI) * ((float) M_PI)), (((float) M_PI) + ((float) M_PI))) * uy);
}
function code(ux, uy, maxCos)
	return Float32(sqrt(Float32(Float32(fma(maxCos, ux, Float32(2.0)) - ux) * Float32(ux - Float32(maxCos * ux)))) * Float32(fma(Float32(Float32(Float32(uy * uy) * Float32(-1.3333333333333333)) * Float32(pi)), Float32(Float32(pi) * Float32(pi)), Float32(Float32(pi) + Float32(pi))) * uy))
end
\sqrt{\left(\mathsf{fma}\left(maxCos, ux, 2\right) - ux\right) \cdot \left(ux - maxCos \cdot ux\right)} \cdot \left(\mathsf{fma}\left(\left(\left(uy \cdot uy\right) \cdot -1.3333333333333333\right) \cdot \pi, \pi \cdot \pi, \pi + \pi\right) \cdot uy\right)
Derivation
  1. Initial program 58.2%

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

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

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

    \[\leadsto \color{blue}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\pi}^{3}\right) + 2 \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)} \]
  5. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \color{blue}{\left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    2. lower-fma.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{{uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    4. lower-pow.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    5. lower-pow.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-PI.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    7. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    8. lower-PI.f3289.0%

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
  6. Applied rewrites89.0%

    \[\leadsto \color{blue}{\left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
  7. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \color{blue}{\left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \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)}} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\sqrt{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \pi\right)\right)} \]
    3. lower-*.f3289.0%

      \[\leadsto \color{blue}{\sqrt{\left(\left(ux - maxCos \cdot ux\right) - 0\right) \cdot \left(-\left(\left(ux - maxCos \cdot ux\right) - 2\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \pi\right)\right)} \]
  8. Applied rewrites89.0%

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

Alternative 13: 81.3% accurate, 2.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} t_0 := ux - maxCos \cdot ux\\ \left(uy \cdot \left(2 \cdot \pi\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))))
  (* (* uy (* 2.0 PI)) (sqrt (* (- t_0 0.0) (- (- t_0 2.0)))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = ux - (maxCos * ux);
	return (uy * (2.0f * ((float) M_PI))) * sqrtf(((t_0 - 0.0f) * -(t_0 - 2.0f)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(ux - Float32(maxCos * ux))
	return Float32(Float32(uy * Float32(Float32(2.0) * Float32(pi))) * sqrt(Float32(Float32(t_0 - Float32(0.0)) * Float32(-Float32(t_0 - Float32(2.0))))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = ux - (maxCos * ux);
	tmp = (uy * (single(2.0) * single(pi))) * sqrt(((t_0 - single(0.0)) * -(t_0 - single(2.0))));
end
\begin{array}{l}
t_0 := ux - maxCos \cdot ux\\
\left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(t\_0 - 0\right) \cdot \left(-\left(t\_0 - 2\right)\right)}
\end{array}
Derivation
  1. Initial program 58.2%

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

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

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

    \[\leadsto \color{blue}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\pi}^{3}\right) + 2 \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)} \]
  5. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \color{blue}{\left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    2. lower-fma.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{{uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{3}}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    4. lower-pow.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    5. lower-pow.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{3}}, 2 \cdot \mathsf{PI}\left(\right)\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. lower-PI.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    7. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, {uy}^{2} \cdot {\pi}^{3}, 2 \cdot \mathsf{PI}\left(\right)\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)} \]
    8. lower-PI.f3289.0%

      \[\leadsto \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
  6. Applied rewrites89.0%

    \[\leadsto \color{blue}{\left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, {uy}^{2} \cdot {\pi}^{3}, 2 \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)} \]
  7. Taylor expanded in uy around 0

    \[\leadsto \left(uy \cdot \left(2 \cdot \color{blue}{\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)} \]
  8. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto \left(uy \cdot \left(2 \cdot \mathsf{PI}\left(\right)\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)} \]
    2. lower-PI.f3281.3%

      \[\leadsto \left(uy \cdot \left(2 \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)} \]
  9. Applied rewrites81.3%

    \[\leadsto \left(uy \cdot \left(2 \cdot \color{blue}{\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)} \]
  10. Add Preprocessing

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
  4. Applied rewrites50.9%

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

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

Alternative 15: 75.6% 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} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \leq 0.019999999552965164:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(uy + uy\right) \cdot \sqrt{\mathsf{fma}\left(ux - \mathsf{fma}\left(maxCos, ux, 1\right), 1 - ux, 1\right)}\right) \cdot \pi\\ \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))))
  (if (<= (sqrt (- 1.0 (* t_0 t_0))) 0.019999999552965164)
    (*
     2.0
     (*
      uy
      (*
       PI
       (* (sqrt (fabs (fma maxCos 2.0 -2.0))) (sqrt (fabs ux))))))
    (*
     (*
      (+ uy uy)
      (sqrt (fma (- ux (fma maxCos ux 1.0)) (- 1.0 ux) 1.0)))
     PI))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	float tmp;
	if (sqrtf((1.0f - (t_0 * t_0))) <= 0.019999999552965164f) {
		tmp = 2.0f * (uy * (((float) M_PI) * (sqrtf(fabsf(fmaf(maxCos, 2.0f, -2.0f))) * sqrtf(fabsf(ux)))));
	} else {
		tmp = ((uy + uy) * sqrtf(fmaf((ux - fmaf(maxCos, ux, 1.0f)), (1.0f - ux), 1.0f))) * ((float) M_PI);
	}
	return tmp;
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	tmp = Float32(0.0)
	if (sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))) <= Float32(0.019999999552965164))
		tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * Float32(sqrt(abs(fma(maxCos, Float32(2.0), Float32(-2.0)))) * sqrt(abs(ux))))));
	else
		tmp = Float32(Float32(Float32(uy + uy) * sqrt(fma(Float32(ux - fma(maxCos, ux, Float32(1.0))), Float32(Float32(1.0) - ux), Float32(1.0)))) * Float32(pi));
	end
	return tmp
end
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \leq 0.019999999552965164:\\
\;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))) < 0.0199999996

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. Applied rewrites50.9%

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)\right) \]
      4. lower-*.f3265.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{neg}\left(\left(2 \cdot maxCos - 2\right)\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      9. fabs-negN/A

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\left(maxCos + maxCos\right) - 2\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      14. sub-flipN/A

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\left(maxCos + maxCos\right) + \left(\mathsf{neg}\left(2\right)\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      16. count-2-revN/A

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|maxCos \cdot 2 + \left(\mathsf{neg}\left(2\right)\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      18. metadata-evalN/A

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      21. lower-fabs.f3265.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
    9. Applied rewrites65.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]

    if 0.0199999996 < (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))))

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. Applied rewrites50.9%

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sin \cos^{-1} \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)\right)\right) \]
    6. Applied rewrites50.9%

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

      \[\leadsto \left(\left(uy + uy\right) \cdot \sqrt{\mathsf{fma}\left(ux - \mathsf{fma}\left(maxCos, ux, 1\right), 1 - ux, 1\right)}\right) \cdot \pi \]
    8. Step-by-step derivation
      1. lower--.f3249.5%

        \[\leadsto \left(\left(uy + uy\right) \cdot \sqrt{\mathsf{fma}\left(ux - \mathsf{fma}\left(maxCos, ux, 1\right), 1 - ux, 1\right)}\right) \cdot \pi \]
    9. Applied rewrites49.5%

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

Alternative 16: 75.4% accurate, 1.3× 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\\ \mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \leq 0.019999999552965164:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux - 1\right)}\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 (+ (- 1.0 ux) (* ux maxCos))))
  (if (<= (sqrt (- 1.0 (* t_0 t_0))) 0.019999999552965164)
    (*
     2.0
     (*
      uy
      (*
       PI
       (* (sqrt (fabs (fma maxCos 2.0 -2.0))) (sqrt (fabs ux))))))
    (* 2.0 (* uy (* PI (sqrt (+ 1.0 (* (- 1.0 ux) (- ux 1.0))))))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	float tmp;
	if (sqrtf((1.0f - (t_0 * t_0))) <= 0.019999999552965164f) {
		tmp = 2.0f * (uy * (((float) M_PI) * (sqrtf(fabsf(fmaf(maxCos, 2.0f, -2.0f))) * sqrtf(fabsf(ux)))));
	} else {
		tmp = 2.0f * (uy * (((float) M_PI) * sqrtf((1.0f + ((1.0f - ux) * (ux - 1.0f))))));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	tmp = Float32(0.0)
	if (sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))) <= Float32(0.019999999552965164))
		tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * Float32(sqrt(abs(fma(maxCos, Float32(2.0), Float32(-2.0)))) * sqrt(abs(ux))))));
	else
		tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) - ux) * Float32(ux - Float32(1.0))))))));
	end
	return tmp
end
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \leq 0.019999999552965164:\\
\;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))) < 0.0199999996

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. Applied rewrites50.9%

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)\right) \]
      4. lower-*.f3265.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{neg}\left(\left(2 \cdot maxCos - 2\right)\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      9. fabs-negN/A

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\left(maxCos + maxCos\right) - 2\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      14. sub-flipN/A

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\left(maxCos + maxCos\right) + \left(\mathsf{neg}\left(2\right)\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      16. count-2-revN/A

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|maxCos \cdot 2 + \left(\mathsf{neg}\left(2\right)\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      18. metadata-evalN/A

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
      21. lower-fabs.f3265.5%

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]
    9. Applied rewrites65.5%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, -2\right)\right|} \cdot \sqrt{\left|ux\right|}\right)\right)\right) \]

    if 0.0199999996 < (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))))

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. Applied rewrites50.9%

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sin \cos^{-1} \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)\right)\right) \]
    6. Applied rewrites50.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 75.4% accurate, 1.3× 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\\ \mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \leq 0.019999999552965164:\\ \;\;\;\;\left(\left(uy + uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \cdot \pi\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux - 1\right)}\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 (+ (- 1.0 ux) (* ux maxCos))))
  (if (<= (sqrt (- 1.0 (* t_0 t_0))) 0.019999999552965164)
    (* (* (+ uy uy) (sqrt (* (fma -2.0 maxCos 2.0) ux))) PI)
    (* 2.0 (* uy (* PI (sqrt (+ 1.0 (* (- 1.0 ux) (- ux 1.0))))))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	float tmp;
	if (sqrtf((1.0f - (t_0 * t_0))) <= 0.019999999552965164f) {
		tmp = ((uy + uy) * sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux))) * ((float) M_PI);
	} else {
		tmp = 2.0f * (uy * (((float) M_PI) * sqrtf((1.0f + ((1.0f - ux) * (ux - 1.0f))))));
	}
	return tmp;
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	tmp = Float32(0.0)
	if (sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))) <= Float32(0.019999999552965164))
		tmp = Float32(Float32(Float32(uy + uy) * sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux))) * Float32(pi));
	else
		tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) - ux) * Float32(ux - Float32(1.0))))))));
	end
	return tmp
end
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \leq 0.019999999552965164:\\
\;\;\;\;\left(\left(uy + uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \cdot \pi\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))) < 0.0199999996

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. Applied rewrites50.9%

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)\right) \]
      4. lower-*.f3265.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0199999996 < (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))))

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. Applied rewrites50.9%

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sin \cos^{-1} \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)\right)\right) \]
    6. Applied rewrites50.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 75.4% accurate, 2.6× 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}\;ux \leq 0.00019999999494757503:\\ \;\;\;\;\left(\left(uy + uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \cdot \pi\\ \mathbf{else}:\\ \;\;\;\;\left(\left(uy + uy\right) \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux - 1\right)}\right) \cdot \pi\\ \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 (<= ux 0.00019999999494757503)
  (* (* (+ uy uy) (sqrt (* (fma -2.0 maxCos 2.0) ux))) PI)
  (* (* (+ uy uy) (sqrt (+ 1.0 (* (- 1.0 ux) (- ux 1.0))))) PI)))
float code(float ux, float uy, float maxCos) {
	float tmp;
	if (ux <= 0.00019999999494757503f) {
		tmp = ((uy + uy) * sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux))) * ((float) M_PI);
	} else {
		tmp = ((uy + uy) * sqrtf((1.0f + ((1.0f - ux) * (ux - 1.0f))))) * ((float) M_PI);
	}
	return tmp;
}
function code(ux, uy, maxCos)
	tmp = Float32(0.0)
	if (ux <= Float32(0.00019999999494757503))
		tmp = Float32(Float32(Float32(uy + uy) * sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux))) * Float32(pi));
	else
		tmp = Float32(Float32(Float32(uy + uy) * sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) - ux) * Float32(ux - Float32(1.0)))))) * Float32(pi));
	end
	return tmp
end
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00019999999494757503:\\
\;\;\;\;\left(\left(uy + uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\right) \cdot \pi\\

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


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

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. Applied rewrites50.9%

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)\right) \]
      4. lower-*.f3265.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999995e-4 < ux

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. Applied rewrites50.9%

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sin \cos^{-1} \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)\right)\right) \]
    6. Applied rewrites50.9%

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

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

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

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

        \[\leadsto \left(\left(uy + uy\right) \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux - 1\right)}\right) \cdot \pi \]
      4. lower--.f3249.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
  4. Applied rewrites50.9%

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)\right) \]
    4. lower-*.f3265.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
  4. Applied rewrites50.9%

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)\right) \]
    4. lower-*.f3265.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 21: 62.8% 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)\]
\[\left(\left(uy + uy\right) \cdot \sqrt{ux + ux}\right) \cdot \pi \]
(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)))
  (* (* (+ uy uy) (sqrt (+ ux ux))) PI))
float code(float ux, float uy, float maxCos) {
	return ((uy + uy) * sqrtf((ux + ux))) * ((float) M_PI);
}
function code(ux, uy, maxCos)
	return Float32(Float32(Float32(uy + uy) * sqrt(Float32(ux + ux))) * Float32(pi))
end
function tmp = code(ux, uy, maxCos)
	tmp = ((uy + uy) * sqrt((ux + ux))) * single(pi);
end
\left(\left(uy + uy\right) \cdot \sqrt{ux + ux}\right) \cdot \pi
Derivation
  1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
  4. Applied rewrites50.9%

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)\right) \]
    4. lower-*.f3265.4%

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right) \]
  10. Applied rewrites62.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(uy + uy\right) \cdot \sqrt{2 \cdot ux}\right) \cdot \color{blue}{\pi} \]
  12. Applied rewrites62.8%

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

Reproduce

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