UniformSampleCone, y

Percentage Accurate: 57.2% → 98.3%
Time: 18.4s
Alternatives: 18
Speedup: 4.5×

Specification

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

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

Initial Program: 57.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Alternative 1: 98.3% accurate, 1.0× speedup?

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

\\
\sqrt{\mathsf{fma}\left(ux \cdot ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

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

Alternative 2: 97.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 59.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. Add Preprocessing
    3. Taylor expanded in ux around inf

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
      2. unpow2N/A

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

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
      8. distribute-lft-neg-inN/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
      10. associate-+l+N/A

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

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

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

        \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
    7. Applied egg-rr98.4%

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

      \[\leadsto \color{blue}{uy \cdot \left(\frac{-4}{3} \cdot \left(\left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right) + 2 \cdot \left(\mathsf{PI}\left(\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)\right)} \]
    9. Simplified98.3%

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

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

    1. Initial program 64.4%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
      2. unpow2N/A

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

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
      8. distribute-lft-neg-inN/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
      10. associate-+l+N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(-2 \cdot \frac{maxCos}{ux} + 2 \cdot \frac{1}{ux}\right)\right)}} \]
    5. Simplified98.2%

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

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

        \[\leadsto \color{blue}{{\left(\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)\right)}^{\frac{1}{2}}} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \]
      3. unpow-prod-downN/A

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

        \[\leadsto \color{blue}{{\left(ux \cdot ux\right)}^{\frac{1}{2}} \cdot \left({\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)}^{\frac{1}{2}} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)\right)} \]
      5. pow2N/A

        \[\leadsto {\color{blue}{\left({ux}^{2}\right)}}^{\frac{1}{2}} \cdot \left({\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)}^{\frac{1}{2}} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
      6. pow-powN/A

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

        \[\leadsto {ux}^{\color{blue}{1}} \cdot \left({\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)}^{\frac{1}{2}} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)\right) \]
      8. unpow1N/A

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

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

        \[\leadsto ux \cdot \color{blue}{\left({\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)}^{\frac{1}{2}} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)\right)} \]
    7. Applied egg-rr98.0%

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

      \[\leadsto ux \cdot \left(\color{blue}{\sqrt{2 \cdot \frac{1}{ux} - 1}} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    9. Step-by-step derivation
      1. sqrt-lowering-sqrt.f32N/A

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

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

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

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

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

        \[\leadsto ux \cdot \left(\sqrt{\frac{\color{blue}{2}}{ux} + -1} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
      7. /-lowering-/.f3294.8

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

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

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

Alternative 3: 97.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 59.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. Add Preprocessing
    3. Taylor expanded in ux around inf

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
      2. unpow2N/A

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

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
      8. distribute-lft-neg-inN/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
      10. associate-+l+N/A

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

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

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

        \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
    7. Applied egg-rr98.4%

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

      \[\leadsto \color{blue}{uy \cdot \left(\frac{-4}{3} \cdot \left(\left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right) + 2 \cdot \left(\mathsf{PI}\left(\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)\right)} \]
    9. Simplified98.3%

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

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

    1. Initial program 64.4%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
      2. unpow2N/A

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

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
      8. distribute-lft-neg-inN/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
      10. associate-+l+N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(-2 \cdot \frac{maxCos}{ux} + 2 \cdot \frac{1}{ux}\right)\right)}} \]
    5. Simplified98.2%

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

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

        \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
    7. Applied egg-rr97.9%

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

      \[\leadsto \sqrt{\color{blue}{-1 \cdot {ux}^{2} + 2 \cdot ux}} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(ux, 2, \color{blue}{\mathsf{neg}\left({ux}^{2}\right)}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
      5. unpow2N/A

        \[\leadsto \sqrt{\mathsf{fma}\left(ux, 2, \mathsf{neg}\left(\color{blue}{ux \cdot ux}\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
      6. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{\mathsf{fma}\left(ux, 2, \color{blue}{ux \cdot \left(\mathsf{neg}\left(ux\right)\right)}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
      7. mul-1-negN/A

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

        \[\leadsto \sqrt{\mathsf{fma}\left(ux, 2, \color{blue}{ux \cdot \left(-1 \cdot ux\right)}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
      9. mul-1-negN/A

        \[\leadsto \sqrt{\mathsf{fma}\left(ux, 2, ux \cdot \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
      10. neg-lowering-neg.f3294.7

        \[\leadsto \sqrt{\mathsf{fma}\left(ux, 2, ux \cdot \color{blue}{\left(-ux\right)}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
    10. Simplified94.7%

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

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

Alternative 4: 98.3% accurate, 1.0× speedup?

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

\\
\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \mathsf{fma}\left(ux, 2 - maxCos, -2\right), 2 - ux\right)}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

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

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

      \[\leadsto \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)}} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    3. +-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \color{blue}{\left(maxCos - 1\right) \cdot \left(1 + -1 \cdot maxCos\right)}, -2 \cdot maxCos\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. sub-negN/A

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \color{blue}{\left(1 - maxCos\right)}, -2 \cdot maxCos\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    15. *-lowering-*.f3298.3

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

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

    \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 + \left(-1 \cdot ux + maxCos \cdot \left(\left(-1 \cdot \left(maxCos \cdot ux\right) + 2 \cdot ux\right) - 2\right)\right)\right)}} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
  12. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \color{blue}{\mathsf{fma}\left(ux, 2 + -1 \cdot maxCos, -2\right)}, 2 + -1 \cdot ux\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    14. mul-1-negN/A

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

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \mathsf{fma}\left(ux, \color{blue}{2 - maxCos}, -2\right), 2 + -1 \cdot ux\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    17. mul-1-negN/A

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \mathsf{fma}\left(ux, 2 - maxCos, -2\right), 2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    18. unsub-negN/A

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \mathsf{fma}\left(ux, 2 - maxCos, -2\right), \color{blue}{2 - ux}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    19. --lowering--.f3298.3

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \mathsf{fma}\left(ux, 2 - maxCos, -2\right), \color{blue}{2 - ux}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
  13. Simplified98.3%

    \[\leadsto \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(maxCos, \mathsf{fma}\left(ux, 2 - maxCos, -2\right), 2 - ux\right)}} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
  14. Final simplification98.3%

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

Alternative 5: 97.6% accurate, 1.1× speedup?

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

\\
\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \mathsf{fma}\left(2, ux, -2\right), 2 - ux\right)}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

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

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

      \[\leadsto \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)}} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    3. +-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \color{blue}{\left(maxCos - 1\right) \cdot \left(1 + -1 \cdot maxCos\right)}, -2 \cdot maxCos\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. sub-negN/A

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \color{blue}{\left(1 - maxCos\right)}, -2 \cdot maxCos\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    15. *-lowering-*.f3298.3

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

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

    \[\leadsto \sqrt{ux \cdot \color{blue}{\left(2 + \left(-1 \cdot ux + maxCos \cdot \left(2 \cdot ux - 2\right)\right)\right)}} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
  12. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \color{blue}{\mathsf{fma}\left(2, ux, -2\right)}, 2 + -1 \cdot ux\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. mul-1-negN/A

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \mathsf{fma}\left(2, ux, -2\right), \color{blue}{2 - ux}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    11. --lowering--.f3297.4

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(maxCos, \mathsf{fma}\left(2, ux, -2\right), \color{blue}{2 - ux}\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
  13. Simplified97.4%

    \[\leadsto \sqrt{ux \cdot \color{blue}{\mathsf{fma}\left(maxCos, \mathsf{fma}\left(2, ux, -2\right), 2 - ux\right)}} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
  14. Final simplification97.4%

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

Alternative 6: 97.0% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 59.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. Add Preprocessing
    3. Taylor expanded in ux around inf

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
      2. unpow2N/A

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

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
      8. distribute-lft-neg-inN/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
      10. associate-+l+N/A

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

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

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

        \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
    7. Applied egg-rr98.4%

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

      \[\leadsto \color{blue}{uy \cdot \left(\frac{-4}{3} \cdot \left(\left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right) + 2 \cdot \left(\mathsf{PI}\left(\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)\right)} \]
    9. Simplified98.3%

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

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

    1. Initial program 64.4%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
    4. Step-by-step derivation
      1. sub-negN/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
      3. unpow2N/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
      5. mul-1-negN/A

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
      8. mul-1-negN/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
      9. neg-sub0N/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{0 - \left(1 - ux\right)}, 1\right)} \]
      11. --lowering--.f3262.4

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, 0 - \color{blue}{\left(1 - ux\right)}, 1\right)} \]
    5. Simplified62.4%

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)} \]
      3. unsub-negN/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
      4. --lowering--.f3294.7

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

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

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

Alternative 7: 94.0% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 59.3%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
      2. unpow2N/A

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

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
      8. distribute-lft-neg-inN/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
      10. associate-+l+N/A

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

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

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

        \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
    7. Applied egg-rr98.4%

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

      \[\leadsto \color{blue}{uy \cdot \left(\frac{-4}{3} \cdot \left(\left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right) + 2 \cdot \left(\mathsf{PI}\left(\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)\right)} \]
    9. Simplified97.9%

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

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

    1. Initial program 64.4%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
    4. Step-by-step derivation
      1. sub-negN/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
      3. unpow2N/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
      5. mul-1-negN/A

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
      8. mul-1-negN/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
      9. neg-sub0N/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{0 - \left(1 - ux\right)}, 1\right)} \]
      11. --lowering--.f3262.1

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, 0 - \color{blue}{\left(1 - ux\right)}, 1\right)} \]
    5. Simplified62.1%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{2 \cdot ux}} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot 2}} \]
      2. *-lowering-*.f3270.5

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

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

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

Alternative 8: 89.2% accurate, 1.8× speedup?

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

\\
uy \cdot \left(\sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(-2, maxCos, 2\right), \left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)} \cdot \mathsf{fma}\left(-1.3333333333333333, \left(uy \cdot uy\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

    \[\leadsto \color{blue}{uy \cdot \left(\frac{-4}{3} \cdot \left(\left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right) + 2 \cdot \left(\mathsf{PI}\left(\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)\right)} \]
  9. Simplified90.1%

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

Alternative 9: 89.2% accurate, 1.9× speedup?

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

\\
\sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(uy \cdot uy\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

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

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

      \[\leadsto \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)}} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    3. +-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \color{blue}{\left(maxCos - 1\right) \cdot \left(1 + -1 \cdot maxCos\right)}, -2 \cdot maxCos\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. sub-negN/A

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \color{blue}{\left(1 - maxCos\right)}, -2 \cdot maxCos\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    15. *-lowering-*.f3298.3

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

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

    \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot maxCos\right)\right)} \cdot \color{blue}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
  12. Step-by-step derivation
    1. *-lowering-*.f32N/A

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot maxCos\right)\right)} \cdot \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) \]
    4. unpow2N/A

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot maxCos\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{\left(uy \cdot uy\right)} \cdot {\mathsf{PI}\left(\right)}^{3}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    6. cube-multN/A

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

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot maxCos\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \left(uy \cdot uy\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{2 \cdot \mathsf{PI}\left(\right)}\right)\right) \]
    13. PI-lowering-PI.f3290.0

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot maxCos\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(uy \cdot uy\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \color{blue}{\pi}\right)\right) \]
  13. Simplified90.0%

    \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot maxCos\right)\right)} \cdot \color{blue}{\left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(uy \cdot uy\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \pi\right)\right)} \]
  14. Final simplification90.0%

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

Alternative 10: 89.2% accurate, 2.0× speedup?

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

\\
\left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(uy \cdot uy\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \color{blue}{\left(1 - maxCos\right)}, maxCos \cdot -2 + 2\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. accelerator-lowering-fma.f3298.2

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

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

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \color{blue}{\left(uy \cdot \left(\frac{-4}{3} \cdot \left({uy}^{2} \cdot {\mathsf{PI}\left(\right)}^{3}\right) + 2 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
  11. Step-by-step derivation
    1. *-lowering-*.f32N/A

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

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \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) \]
    4. unpow2N/A

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \color{blue}{\left(uy \cdot uy\right)} \cdot {\mathsf{PI}\left(\right)}^{3}, 2 \cdot \mathsf{PI}\left(\right)\right)\right) \]
    6. cube-multN/A

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

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(\frac{-4}{3}, \left(uy \cdot uy\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), \color{blue}{2 \cdot \mathsf{PI}\left(\right)}\right)\right) \]
    13. PI-lowering-PI.f3289.9

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

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \color{blue}{\left(uy \cdot \mathsf{fma}\left(-1.3333333333333333, \left(uy \cdot uy\right) \cdot \left(\pi \cdot \left(\pi \cdot \pi\right)\right), 2 \cdot \pi\right)\right)} \]
  13. Final simplification89.9%

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

Alternative 11: 81.6% accurate, 2.6× speedup?

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

\\
\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \mathsf{fma}\left(-2, maxCos, 2\right), \left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(2 + -2 \cdot maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos - 1\right)\right)}\right)} \]
  9. Simplified82.4%

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

Alternative 12: 81.6% accurate, 2.6× speedup?

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

\\
\sqrt{\mathsf{fma}\left(ux \cdot ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \left(2 \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

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

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

      \[\leadsto \sqrt{\mathsf{fma}\left(ux \cdot ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux\right)} \cdot \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    3. PI-lowering-PI.f3282.4

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

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

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

Alternative 13: 81.6% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
t_0 := ux \cdot \left(1 - maxCos\right)\\
\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(t\_0, \mathsf{fma}\left(ux, maxCos + -1, 1\right), t\_0\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
  4. Step-by-step derivation
    1. associate-*r*N/A

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)} \]
  5. Simplified52.9%

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot \left(maxCos + -1\right) + 1\right)\right) + -1 \cdot \left(ux \cdot \left(maxCos + -1\right) + 1\right)}} \cdot \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
  7. Applied egg-rr52.6%

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{-1 \cdot \left(ux \cdot \left(maxCos - 1\right)\right) + \left(1 + ux \cdot \left(maxCos - 1\right)\right) \cdot \left(ux + -1 \cdot \left(maxCos \cdot ux\right)\right)}\right)} \]
  9. Step-by-step derivation
    1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right)} \cdot \left(1 + ux \cdot \left(maxCos - 1\right)\right) + -1 \cdot \left(ux \cdot \left(maxCos - 1\right)\right)} \]
    12. mul-1-negN/A

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

      \[\leadsto \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right) \cdot \left(1 + ux \cdot \left(maxCos - 1\right)\right) + \color{blue}{ux \cdot \left(\mathsf{neg}\left(\left(maxCos - 1\right)\right)\right)}} \]
    14. sub-negN/A

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

      \[\leadsto \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 + -1 \cdot maxCos\right)\right) \cdot \left(1 + ux \cdot \left(maxCos - 1\right)\right) + ux \cdot \left(\mathsf{neg}\left(\left(maxCos + \color{blue}{-1}\right)\right)\right)} \]
  10. Simplified82.4%

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

Alternative 14: 81.6% accurate, 2.8× speedup?

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

\\
\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right)\right)}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

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

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

      \[\leadsto \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)}} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    3. +-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \color{blue}{\left(maxCos - 1\right) \cdot \left(1 + -1 \cdot maxCos\right)}, -2 \cdot maxCos\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. sub-negN/A

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \color{blue}{\left(1 - maxCos\right)}, -2 \cdot maxCos\right)\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    15. *-lowering-*.f3298.3

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(2 + \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), -2 \cdot maxCos\right)\right)} \cdot \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    3. PI-lowering-PI.f3282.4

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

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

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

Alternative 15: 81.6% accurate, 2.9× speedup?

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

\\
\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\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)}} \]
    2. unpow2N/A

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \left(\mathsf{neg}\left(2 \cdot \frac{maxCos}{ux}\right)\right)\right)} + 2 \cdot \frac{1}{ux}\right)} \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{neg}\left({\left(maxCos - 1\right)}^{2}\right)\right) + \color{blue}{-2} \cdot \frac{maxCos}{ux}\right) + 2 \cdot \frac{1}{ux}\right)} \]
    10. associate-+l+N/A

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

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

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

      \[\leadsto \color{blue}{\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right) + \frac{maxCos \cdot -2 + 2}{ux}\right)} \cdot \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  7. Applied egg-rr98.3%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \color{blue}{\left(1 - maxCos\right)}, maxCos \cdot -2 + 2\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    9. accelerator-lowering-fma.f3298.2

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    3. PI-lowering-PI.f3282.3

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

    \[\leadsto \sqrt{ux \cdot \mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  13. Final simplification82.3%

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

Alternative 16: 81.5% accurate, 3.0× speedup?

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

\\
\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \mathsf{fma}\left(maxCos + -1, \mathsf{fma}\left(ux, 1 - maxCos, -1\right), 1 - maxCos\right)}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
  4. Step-by-step derivation
    1. associate-*r*N/A

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)} \]
  5. Simplified52.9%

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot \left(maxCos + -1\right) + 1\right)\right) + -1 \cdot \left(ux \cdot \left(maxCos + -1\right) + 1\right)}} \cdot \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
  7. Applied egg-rr52.6%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{ux \cdot \left(\left(1 + -1 \cdot maxCos\right) + \left(ux \cdot \left(\left(1 + -1 \cdot maxCos\right) \cdot \left(maxCos - 1\right)\right) + \color{blue}{\left(\left(\mathsf{neg}\left(maxCos\right)\right) + \left(\mathsf{neg}\left(-1\right)\right)\right)}\right)\right)} \cdot \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
    8. mul-1-negN/A

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

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

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

      \[\leadsto \sqrt{ux \cdot \color{blue}{\left(\left(\left(1 + -1 \cdot maxCos\right) + ux \cdot \left(\left(1 + -1 \cdot maxCos\right) \cdot \left(maxCos - 1\right)\right)\right) + \left(1 + -1 \cdot maxCos\right)\right)}} \cdot \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
  10. Simplified82.3%

    \[\leadsto \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(maxCos + -1, \mathsf{fma}\left(ux, 1 - maxCos, -1\right), 1 - maxCos\right)}} \cdot \left(2 \cdot \left(uy \cdot \pi\right)\right) \]
  11. Final simplification82.3%

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

Alternative 17: 77.3% accurate, 4.5× speedup?

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

\\
\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - ux, ux\right)}
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)} \]
  4. Step-by-step derivation
    1. associate-*r*N/A

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)} \]
  5. Simplified52.9%

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\left(1 + \left(\left(\mathsf{neg}\left(ux\right)\right) \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot \left(maxCos + -1\right) + 1\right)\right) + -1 \cdot \left(ux \cdot \left(maxCos + -1\right) + 1\right)}} \cdot \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \]
  7. Applied egg-rr52.6%

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux + ux \cdot \left(1 + -1 \cdot ux\right)}\right)} \]
  9. Step-by-step derivation
    1. associate-*r*N/A

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

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

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

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

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

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

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

      \[\leadsto \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(ux, 1 + -1 \cdot ux, ux\right)}} \]
    9. mul-1-negN/A

      \[\leadsto \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}, ux\right)} \]
    10. sub-negN/A

      \[\leadsto \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{1 - ux}, ux\right)} \]
    11. --lowering--.f3277.1

      \[\leadsto \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \color{blue}{1 - ux}, ux\right)} \]
  10. Simplified77.1%

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

Alternative 18: 30.8% accurate, 6.0× speedup?

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

\\
2 \cdot \left(\pi \cdot \left(uy \cdot \sqrt{ux}\right)\right)
\end{array}
Derivation
  1. Initial program 60.1%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - {\left(1 - ux\right)}^{2}}} \]
  4. Step-by-step derivation
    1. sub-negN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(1 - ux\right)}^{2}\right)\right) + 1}} \]
    3. unpow2N/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(1 - ux\right) \cdot \left(\mathsf{neg}\left(\left(1 - ux\right)\right)\right)} + 1} \]
    5. mul-1-negN/A

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\color{blue}{1 - ux}, -1 \cdot \left(1 - ux\right), 1\right)} \]
    8. mul-1-negN/A

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
    9. neg-sub0N/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{0 - \left(1 - ux\right)}, 1\right)} \]
    11. --lowering--.f3257.4

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, 0 - \color{blue}{\left(1 - ux\right)}, 1\right)} \]
  5. Simplified57.4%

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(1 - ux, \color{blue}{-1}, 1\right)} \]
  7. Step-by-step derivation
    1. Simplified27.0%

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 + \left(\mathsf{neg}\left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)}\right)\right)}\right) \]
      8. mul-1-negN/A

        \[\leadsto 2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 + \left(\mathsf{neg}\left(\left(1 + \color{blue}{-1 \cdot ux}\right)\right)\right)}\right) \]
      9. unsub-negN/A

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

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

        \[\leadsto 2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)}\right) \]
      12. sub-negN/A

        \[\leadsto 2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(1 - ux\right)}}\right) \]
      13. --lowering--.f3226.2

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\left(\sqrt{\color{blue}{0} + ux} \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \]
      7. +-lft-identityN/A

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

        \[\leadsto 2 \cdot \left(\left(\color{blue}{\sqrt{ux}} \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \]
      9. PI-lowering-PI.f3230.7

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

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

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

    Reproduce

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