UniformSampleCone, y

Percentage Accurate: 57.9% → 98.4%
Time: 18.8s
Alternatives: 20
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 20 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.9% 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.4% accurate, 1.0× speedup?

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

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

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 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.3%

    \[\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. 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)\right) \cdot ux + \left(maxCos \cdot -2 + 2\right) \cdot ux}} \]
    2. *-commutativeN/A

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

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

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

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

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

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

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

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

Alternative 2: 84.5% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 52.2%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    8. 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(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    9. 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(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
      2. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999995e-4 < (*.f32 (sin.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))))

    1. Initial program 84.2%

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

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

      \[\leadsto \color{blue}{uy \cdot \left(\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(ux, maxCos + -1, 1\right), \mathsf{fma}\left(-ux, maxCos + -1, -1\right), 1\right)} \cdot \left(\pi \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(uy \cdot uy\right), \pi \cdot \pi, 2\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.8%

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

Alternative 3: 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.4%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 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.3%

    \[\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 4: 97.5% accurate, 1.0× speedup?

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(2 \cdot \left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right) + {\left(1 - ux\right)}^{2}\right)}} \]
  4. 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{1 - \left(\color{blue}{\left(2 \cdot maxCos\right) \cdot \left(ux \cdot \left(1 - ux\right)\right)} + {\left(1 - ux\right)}^{2}\right)} \]
    2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 96.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 1.0000000116860974 \cdot 10^{-7}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(ux, -ux, 2 \cdot ux\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if maxCos < 1.00000001e-7

    1. Initial program 59.1%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in ux around 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.3%

      \[\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. 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)\right) \cdot ux + \left(maxCos \cdot -2 + 2\right) \cdot ux}} \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)}} \]
    8. 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 \cdot {ux}^{2} + 2 \cdot ux}} \]
    9. Step-by-step derivation
      1. mul-1-negN/A

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(-1 \cdot ux\right)} + 2 \cdot ux} \]
      5. 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, -1 \cdot ux, 2 \cdot ux\right)}} \]
      6. neg-mul-1N/A

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

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

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

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

    if 1.00000001e-7 < maxCos

    1. Initial program 60.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.1%

      \[\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. 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)\right) \cdot ux + \left(maxCos \cdot -2 + 2\right) \cdot ux}} \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\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(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\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(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
      2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.1% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 59.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.4%

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

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

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

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

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

    1. Initial program 56.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{1 - \color{blue}{\left(1 + ux \cdot \left(2 \cdot maxCos - 2\right)\right)}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 96.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 1.0000000116860974 \cdot 10^{-7}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if maxCos < 1.00000001e-7

    1. Initial program 59.1%

      \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in ux around 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.3%

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

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

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

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

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

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

    if 1.00000001e-7 < maxCos

    1. Initial program 60.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.1%

      \[\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. 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)\right) \cdot ux + \left(maxCos \cdot -2 + 2\right) \cdot ux}} \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\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(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\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(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
      2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 89.5% accurate, 1.2× speedup?

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

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

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 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.3%

    \[\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. 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)\right) \cdot ux + \left(maxCos \cdot -2 + 2\right) \cdot ux}} \]
    2. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 89.5% accurate, 1.2× speedup?

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

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

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 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.3%

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

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

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

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

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

Alternative 10: 77.3% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 35.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. Step-by-step derivation
      1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    8. 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 - 2 \cdot maxCos\right)}} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.49999988e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 89.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{fma}\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(uy \cdot uy\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \pi\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sqrt
   (fma
    (* (+ maxCos -1.0) (- 1.0 maxCos))
    (* ux ux)
    (* ux (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(fmaf(((maxCos + -1.0f) * (1.0f - maxCos)), (ux * ux), (ux * 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(fma(Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos)), Float32(ux * ux), Float32(ux * fma(maxCos, Float32(-2.0), Float32(2.0))))) * Float32(uy * fma(Float32(Float32(-1.3333333333333333) * 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(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \cdot \left(uy \cdot \mathsf{fma}\left(-1.3333333333333333 \cdot \left(uy \cdot uy\right), \pi \cdot \left(\pi \cdot \pi\right), 2 \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 59.4%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 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.3%

    \[\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. 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)\right) \cdot ux + \left(maxCos \cdot -2 + 2\right) \cdot ux}} \]
    2. *-commutativeN/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\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(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\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(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right), ux \cdot ux, ux \cdot \mathsf{fma}\left(maxCos, -2, 2\right)\right)} \]
    2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 75.9% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 35.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. Step-by-step derivation
      1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    8. 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 - 2 \cdot maxCos\right)}} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-invN/A

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

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

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

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

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

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

    if 3.49999988e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 89.6% 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.4%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 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.3%

    \[\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.f3289.7

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

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

    \[\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 14: 75.7% accurate, 2.1× speedup?

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

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

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


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

    1. Initial program 35.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. Step-by-step derivation
      1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    8. 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 - 2 \cdot maxCos\right)}} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-invN/A

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

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

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

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

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

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

    if 3.49999988e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))))

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 77.3% accurate, 2.3× speedup?

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

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

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


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

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 35.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. Step-by-step derivation
      1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    8. 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 - 2 \cdot maxCos\right)}} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 75.9% accurate, 2.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt{ux} \cdot \left(t\_0 \cdot \sqrt{\mathsf{fma}\left(maxCos, -2, 2\right)}\right)\\


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

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 35.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. Step-by-step derivation
      1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
    8. 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 - 2 \cdot maxCos\right)}} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 81.8% accurate, 2.7× speedup?

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

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

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(\left(uy \cdot \left(2 \cdot \sqrt{\pi}\right)\right) \cdot \sqrt{\sqrt{\pi}}\right) \cdot \sqrt{\sqrt{\color{blue}{\pi}}}\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  4. Applied egg-rr59.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  8. 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(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
  9. 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(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    2. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 81.8% 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.4%

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in ux around 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.3%

    \[\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.f3281.1

      \[\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. Simplified81.1%

    \[\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 simplification81.1%

    \[\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 19: 65.9% accurate, 4.2× speedup?

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

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

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(\left(uy \cdot \left(2 \cdot \sqrt{\pi}\right)\right) \cdot \sqrt{\sqrt{\pi}}\right) \cdot \sqrt{\sqrt{\color{blue}{\pi}}}\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  4. Applied egg-rr59.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  8. 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 - 2 \cdot maxCos\right)}} \]
  9. Step-by-step derivation
    1. cancel-sign-sub-invN/A

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

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

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

      \[\leadsto \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(-2 \cdot maxCos + 2\right)}} \]
    5. accelerator-lowering-fma.f3264.6

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

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

Alternative 20: 63.2% accurate, 5.0× speedup?

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

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

    \[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrtN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(\left(uy \cdot \left(2 \cdot \sqrt{\pi}\right)\right) \cdot \sqrt{\sqrt{\pi}}\right) \cdot \sqrt{\sqrt{\color{blue}{\pi}}}\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  4. Applied egg-rr59.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right)}} \]
  8. 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 - 2 \cdot maxCos\right)}} \]
  9. Step-by-step derivation
    1. cancel-sign-sub-invN/A

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

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

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

      \[\leadsto \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(-2 \cdot maxCos + 2\right)}} \]
    5. accelerator-lowering-fma.f3264.6

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

    \[\leadsto \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \mathsf{fma}\left(-2, maxCos, 2\right)}} \]
  11. Taylor expanded in maxCos 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. *-commutativeN/A

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

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

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

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

Reproduce

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