UniformSampleCone, y

Percentage Accurate: 57.1% → 98.3%
Time: 18.7s
Alternatives: 19
Speedup: 5.0×

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

\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)}
\end{array}
Derivation
  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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Step-by-step derivation
    1. associate-+r+N/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
    3. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
    4. accelerator-lowering-fma.f32N/A

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

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

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

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

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

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

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

Alternative 2: 98.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sin \left(\left(uy \cdot 2\right) \cdot \pi\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
 (*
  (sin (* (* uy 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 sinf(((uy * 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(sin(Float32(Float32(uy * 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}

\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\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 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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Add Preprocessing

Alternative 3: 97.7% accurate, 1.0× speedup?

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

\\
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 - ux\right)\right)}
\end{array}
Derivation
  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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Taylor expanded in maxCos around 0

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \color{blue}{\left(2 + -1 \cdot ux\right)}\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(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)\right)} \]
    9. neg-lowering-neg.f3297.8

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

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

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

Alternative 4: 97.7% accurate, 1.0× speedup?

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

\\
\sqrt{\mathsf{fma}\left(ux, 2 - ux, ux \cdot \left(maxCos \cdot \mathsf{fma}\left(ux, 2, -2\right)\right)\right)} \cdot \sin \left(uy \cdot \left(2 \cdot \pi\right)\right)
\end{array}
Derivation
  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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Taylor expanded in maxCos around 0

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \color{blue}{\left(2 + -1 \cdot ux\right)}\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(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)\right)} \]
    9. neg-lowering-neg.f3297.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.1% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.02800000086426735:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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)\\

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


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

    1. Initial program 58.9%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
      2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
    6. Step-by-step derivation
      1. associate-+r+N/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
      3. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
      4. accelerator-lowering-fma.f32N/A

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

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

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

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

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

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

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

      \[\leadsto \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)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
    9. Step-by-step derivation
      1. *-lowering-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
      13. PI-lowering-PI.f3298.6

        \[\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 \color{blue}{\pi}\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
    10. Simplified98.6%

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

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

    1. Initial program 61.7%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
      2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
    6. Taylor expanded in maxCos around 0

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

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

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \color{blue}{\left(2 + -1 \cdot ux\right)}\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(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)\right)} \]
      9. neg-lowering-neg.f3297.6

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{ux \cdot \left(2 - ux\right)} \cdot \sin \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \]
      8. PI-lowering-PI.f3291.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.02800000086426735:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{ux \cdot \left(2 - ux\right)} \cdot \sin \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 89.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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
   (fma
    (fma ux (* (+ maxCos -1.0) (- 1.0 maxCos)) (* maxCos -2.0))
    ux
    (* 2.0 ux)))
  (* uy (fma -1.3333333333333333 (* (* uy uy) (* PI (* PI PI))) (* 2.0 PI)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(fmaf(fmaf(ux, ((maxCos + -1.0f) * (1.0f - maxCos)), (maxCos * -2.0f)), ux, (2.0f * ux))) * (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(fma(fma(ux, Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos)), Float32(maxCos * Float32(-2.0))), ux, Float32(Float32(2.0) * ux))) * 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{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\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 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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Step-by-step derivation
    1. associate-+r+N/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
    3. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
    4. accelerator-lowering-fma.f32N/A

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

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

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

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

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

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

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

    \[\leadsto \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)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
  9. Step-by-step derivation
    1. *-lowering-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
    13. PI-lowering-PI.f3292.1

      \[\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 \color{blue}{\pi}\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
  10. Simplified92.1%

    \[\leadsto \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)} \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \]
  11. Final simplification92.1%

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

Alternative 7: 89.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \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 \pi\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sqrt
   (* ux (fma ux (* (+ maxCos -1.0) (- 1.0 maxCos)) (fma maxCos -2.0 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 * fmaf(ux, ((maxCos + -1.0f) * (1.0f - maxCos)), fmaf(maxCos, -2.0f, 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 * fma(ux, Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos)), fma(maxCos, Float32(-2.0), 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 \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 \pi\right)\right)
\end{array}
Derivation
  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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Taylor expanded in uy around 0

    \[\leadsto \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)} \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)} \]
  7. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \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)} \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)} \]
    2. accelerator-lowering-fma.f32N/A

      \[\leadsto \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) \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)} \]
    3. *-lowering-*.f32N/A

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

      \[\leadsto \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) \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)} \]
    5. *-lowering-*.f32N/A

      \[\leadsto \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) \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)} \]
    6. cube-multN/A

      \[\leadsto \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) \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)} \]
    7. *-lowering-*.f32N/A

      \[\leadsto \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) \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)} \]
    8. PI-lowering-PI.f32N/A

      \[\leadsto \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) \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)} \]
    9. *-lowering-*.f32N/A

      \[\leadsto \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) \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)} \]
    10. PI-lowering-PI.f32N/A

      \[\leadsto \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) \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)} \]
    11. PI-lowering-PI.f32N/A

      \[\leadsto \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) \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)} \]
    12. *-lowering-*.f32N/A

      \[\leadsto \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) \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)} \]
    13. PI-lowering-PI.f3292.0

      \[\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 \color{blue}{\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)} \]
  8. Simplified92.0%

    \[\leadsto \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)} \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)} \]
  9. Final simplification92.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 \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) \]
  10. Add Preprocessing

Alternative 8: 84.2% accurate, 2.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(\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}\right) \cdot \sqrt{2}\\


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

    1. Initial program 59.8%

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
      2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
    6. Step-by-step derivation
      1. associate-+r+N/A

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
      3. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
      4. accelerator-lowering-fma.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 57.9%

      \[\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-lowering-neg.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}{\mathsf{neg}\left(\left(1 - ux\right)\right)}, 1\right)} \]
      10. --lowering--.f3257.1

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{ux} \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)}\right) \cdot \sqrt{2} \]
    10. Step-by-step derivation
      1. *-lowering-*.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)}\right) \cdot \sqrt{2} \]
      2. accelerator-lowering-fma.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      3. *-lowering-*.f32N/A

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

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      5. *-lowering-*.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      6. cube-multN/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      7. *-lowering-*.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      8. PI-lowering-PI.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      9. *-lowering-*.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      10. PI-lowering-PI.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      11. PI-lowering-PI.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      12. *-lowering-*.f32N/A

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
      13. PI-lowering-PI.f3262.3

        \[\leadsto \left(\sqrt{ux} \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)\right) \cdot \sqrt{2} \]
    11. Simplified62.3%

      \[\leadsto \left(\sqrt{ux} \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)}\right) \cdot \sqrt{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;uy \cdot 2 \leq 0.0024999999441206455:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \cdot \left(2 \cdot \left(uy \cdot \pi\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\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}\right) \cdot \sqrt{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 88.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 - ux\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 (fma maxCos (* ux (fma 2.0 ux -2.0)) (* ux (- 2.0 ux))))
  (* uy (fma -1.3333333333333333 (* (* uy uy) (* PI (* PI PI))) (* 2.0 PI)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(fmaf(maxCos, (ux * fmaf(2.0f, ux, -2.0f)), (ux * (2.0f - ux)))) * (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(fma(maxCos, Float32(ux * fma(Float32(2.0), ux, Float32(-2.0))), Float32(ux * Float32(Float32(2.0) - ux)))) * 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{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 - ux\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 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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Taylor expanded in maxCos around 0

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \color{blue}{\left(2 + -1 \cdot ux\right)}\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(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)\right)} \]
    9. neg-lowering-neg.f3297.8

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

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

    \[\leadsto \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)} \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
  10. Step-by-step derivation
    1. *-lowering-*.f32N/A

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

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
    3. *-lowering-*.f32N/A

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

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
    5. *-lowering-*.f32N/A

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

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

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
    8. PI-lowering-PI.f32N/A

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
    9. *-lowering-*.f32N/A

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
    10. PI-lowering-PI.f32N/A

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
    11. PI-lowering-PI.f32N/A

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
    12. *-lowering-*.f32N/A

      \[\leadsto \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) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)} \]
    13. PI-lowering-PI.f3291.3

      \[\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 \color{blue}{\pi}\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(-ux\right)\right)\right)} \]
  11. Simplified91.3%

    \[\leadsto \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)} \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \left(-ux\right)\right)\right)} \]
  12. Final simplification91.3%

    \[\leadsto \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 - ux\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) \]
  13. Add Preprocessing

Alternative 10: 81.3% accurate, 2.6× speedup?

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

\\
\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, \left(maxCos + -1\right) \cdot \left(1 - maxCos\right), maxCos \cdot -2\right), ux, 2 \cdot ux\right)} \cdot \left(2 \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Step-by-step derivation
    1. associate-+r+N/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2\right) \cdot ux + 2 \cdot ux}} \]
    3. 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(ux \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + maxCos \cdot -2, ux, 2 \cdot ux\right)}} \]
    4. accelerator-lowering-fma.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 81.3% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(ux, -maxCos, ux\right)\\
2 \cdot \left(\pi \cdot \left(uy \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos, 1 - ux\right), t\_0, t\_0\right)}\right)\right)
\end{array}
\end{array}
Derivation
  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 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. *-lowering-*.f32N/A

      \[\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)} \]
    2. *-lowering-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 81.3% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \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 \pi\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sqrt
   (* ux (fma ux (* (+ maxCos -1.0) (- 1.0 maxCos)) (fma maxCos -2.0 2.0))))
  (* 2.0 (* uy PI))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux * fmaf(ux, ((maxCos + -1.0f) * (1.0f - maxCos)), fmaf(maxCos, -2.0f, 2.0f)))) * (2.0f * (uy * ((float) M_PI)));
}
function code(ux, uy, maxCos)
	return Float32(sqrt(Float32(ux * fma(ux, Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos)), fma(maxCos, Float32(-2.0), Float32(2.0))))) * Float32(Float32(2.0) * Float32(uy * Float32(pi))))
end
\begin{array}{l}

\\
\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 \pi\right)\right)
\end{array}
Derivation
  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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Taylor expanded in uy around 0

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\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)} \]
    2. *-lowering-*.f32N/A

      \[\leadsto \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\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)} \]
    3. PI-lowering-PI.f3283.9

      \[\leadsto \left(2 \cdot \left(uy \cdot \color{blue}{\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)} \]
  8. Simplified83.9%

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

Alternative 13: 80.8% accurate, 3.1× speedup?

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

\\
\sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 - ux\right)\right)} \cdot \left(2 \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Taylor expanded in maxCos around 0

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \color{blue}{\left(2 + -1 \cdot ux\right)}\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(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)\right)} \]
    9. neg-lowering-neg.f3297.8

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

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

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

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

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

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

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

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

Alternative 14: 80.8% accurate, 3.1× speedup?

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

\\
\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 2 - ux, maxCos \cdot \left(ux \cdot \mathsf{fma}\left(2, ux, -2\right)\right)\right)}
\end{array}
Derivation
  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 0

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\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 \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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)}} \]
  6. Taylor expanded in maxCos around 0

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \color{blue}{\left(2 + -1 \cdot ux\right)}\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(maxCos, ux \cdot \mathsf{fma}\left(2, ux, -2\right), ux \cdot \left(2 + \color{blue}{\left(\mathsf{neg}\left(ux\right)\right)}\right)\right)} \]
    9. neg-lowering-neg.f3297.8

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

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

    \[\leadsto \color{blue}{2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right) + ux \cdot \left(2 - ux\right)}\right)} \]
  10. 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{maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right) + ux \cdot \left(2 - ux\right)}} \]
    2. *-lowering-*.f32N/A

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

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

      \[\leadsto \left(2 \cdot \color{blue}{\left(uy \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \sqrt{maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right) + ux \cdot \left(2 - 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{maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right) + ux \cdot \left(2 - 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{maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right) + ux \cdot \left(2 - 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(2 - ux\right) + maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right)}} \]
    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, 2 - ux, maxCos \cdot \left(ux \cdot \left(2 \cdot ux - 2\right)\right)\right)}} \]
    9. --lowering--.f32N/A

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

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

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

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

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

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

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

Alternative 15: 77.3% accurate, 3.2× speedup?

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

\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, -ux, ux\right), \mathsf{fma}\left(ux, maxCos, 1\right) - ux, ux\right)}\right)
\end{array}
Derivation
  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 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. *-lowering-*.f32N/A

      \[\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)} \]
    2. *-lowering-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(maxCos, \mathsf{neg}\left(ux\right), ux\right), \mathsf{fma}\left(ux, maxCos, 1\right) - ux, \color{blue}{ux}\right)}\right) \]
  11. Step-by-step derivation
    1. Simplified79.3%

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

    Alternative 16: 76.9% accurate, 4.5× speedup?

    \[\begin{array}{l} \\ \pi \cdot \left(\left(uy \cdot 2\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - ux, ux\right)}\right) \end{array} \]
    (FPCore (ux uy maxCos)
     :precision binary32
     (* PI (* (* uy 2.0) (sqrt (fma ux (- 1.0 ux) ux)))))
    float code(float ux, float uy, float maxCos) {
    	return ((float) M_PI) * ((uy * 2.0f) * sqrtf(fmaf(ux, (1.0f - ux), ux)));
    }
    
    function code(ux, uy, maxCos)
    	return Float32(Float32(pi) * Float32(Float32(uy * Float32(2.0)) * sqrt(fma(ux, Float32(Float32(1.0) - ux), ux))))
    end
    
    \begin{array}{l}
    
    \\
    \pi \cdot \left(\left(uy \cdot 2\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - ux, ux\right)}\right)
    \end{array}
    
    Derivation
    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 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. *-lowering-*.f32N/A

        \[\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)} \]
      2. *-lowering-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 + \mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \mathsf{fma}\left(maxCos, -ux, ux\right)\right) + \left(-\mathsf{fma}\left(ux, maxCos, 1 - ux\right)\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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - ux, ux\right)}} \]
      9. --lowering--.f3278.9

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\mathsf{fma}\left(ux, 1 - ux, ux\right)} \cdot \left(2 \cdot uy\right)\right) \cdot \color{blue}{\pi} \]
    12. Applied egg-rr79.0%

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

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

    Alternative 17: 76.9% 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 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 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. *-lowering-*.f32N/A

        \[\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)} \]
      2. *-lowering-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 + \mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \mathsf{fma}\left(maxCos, -ux, ux\right)\right) + \left(-\mathsf{fma}\left(ux, maxCos, 1 - ux\right)\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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - ux, ux\right)}} \]
      9. --lowering--.f3278.9

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

      \[\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: 76.9% accurate, 4.6× speedup?

    \[\begin{array}{l} \\ \sqrt{ux \cdot \left(2 - ux\right)} \cdot \left(2 \cdot \left(uy \cdot \pi\right)\right) \end{array} \]
    (FPCore (ux uy maxCos)
     :precision binary32
     (* (sqrt (* ux (- 2.0 ux))) (* 2.0 (* uy PI))))
    float code(float ux, float uy, float maxCos) {
    	return sqrtf((ux * (2.0f - ux))) * (2.0f * (uy * ((float) M_PI)));
    }
    
    function code(ux, uy, maxCos)
    	return Float32(sqrt(Float32(ux * Float32(Float32(2.0) - ux))) * Float32(Float32(2.0) * Float32(uy * Float32(pi))))
    end
    
    function tmp = code(ux, uy, maxCos)
    	tmp = sqrt((ux * (single(2.0) - ux))) * (single(2.0) * (uy * single(pi)));
    end
    
    \begin{array}{l}
    
    \\
    \sqrt{ux \cdot \left(2 - ux\right)} \cdot \left(2 \cdot \left(uy \cdot \pi\right)\right)
    \end{array}
    
    Derivation
    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 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. *-lowering-*.f32N/A

        \[\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)} \]
      2. *-lowering-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 + \mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \mathsf{fma}\left(maxCos, -ux, ux\right)\right) + \left(-\mathsf{fma}\left(ux, maxCos, 1 - ux\right)\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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - ux, ux\right)}} \]
      9. --lowering--.f3278.9

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
    13. Simplified78.9%

      \[\leadsto \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \]
    14. Final simplification78.9%

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

    Alternative 19: 63.5% accurate, 5.0× speedup?

    \[\begin{array}{l} \\ \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{2 \cdot ux} \end{array} \]
    (FPCore (ux uy maxCos)
     :precision binary32
     (* (* 2.0 (* uy PI)) (sqrt (* 2.0 ux))))
    float code(float ux, float uy, float maxCos) {
    	return (2.0f * (uy * ((float) M_PI))) * sqrtf((2.0f * ux));
    }
    
    function code(ux, uy, maxCos)
    	return Float32(Float32(Float32(2.0) * Float32(uy * Float32(pi))) * sqrt(Float32(Float32(2.0) * ux)))
    end
    
    function tmp = code(ux, uy, maxCos)
    	tmp = (single(2.0) * (uy * single(pi))) * sqrt((single(2.0) * ux));
    end
    
    \begin{array}{l}
    
    \\
    \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{2 \cdot ux}
    \end{array}
    
    Derivation
    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 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. *-lowering-*.f32N/A

        \[\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)} \]
      2. *-lowering-*.f32N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(1 + \mathsf{fma}\left(ux, maxCos, 1 - ux\right) \cdot \mathsf{fma}\left(maxCos, -ux, ux\right)\right) + \left(-\mathsf{fma}\left(ux, maxCos, 1 - ux\right)\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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - ux, ux\right)}} \]
      9. --lowering--.f3278.9

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

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

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

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

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

    Reproduce

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