UniformSampleCone, x

Percentage Accurate: 57.3% → 99.0%
Time: 18.6s
Alternatives: 17
Speedup: 2.2×

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\\ \cos \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))))
   (* (cos (* (* uy 2.0) PI)) (sqrt (- 1.0 (* t_0 t_0))))))
float code(float ux, float uy, float maxCos) {
	float t_0 = (1.0f - ux) + (ux * maxCos);
	return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos)
	t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos))
	return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))))
end
function tmp = code(ux, uy, maxCos)
	t_0 = (single(1.0) - ux) + (ux * maxCos);
	tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0)));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\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 17 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ {\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (pow (* ux (* (+ (* ux (+ maxCos -1.0)) 2.0) (- 1.0 maxCos))) 0.5)
  (cos (* 2.0 (* uy PI)))))
float code(float ux, float uy, float maxCos) {
	return powf((ux * (((ux * (maxCos + -1.0f)) + 2.0f) * (1.0f - maxCos))), 0.5f) * cosf((2.0f * (uy * ((float) M_PI))));
}
function code(ux, uy, maxCos)
	return Float32((Float32(ux * Float32(Float32(Float32(ux * Float32(maxCos + Float32(-1.0))) + Float32(2.0)) * Float32(Float32(1.0) - maxCos))) ^ Float32(0.5)) * cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))))
end
function tmp = code(ux, uy, maxCos)
	tmp = ((ux * (((ux * (maxCos + single(-1.0))) + single(2.0)) * (single(1.0) - maxCos))) ^ single(0.5)) * cos((single(2.0) * (uy * single(pi))));
end
\begin{array}{l}

\\
{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 55.7%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

    \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
  5. Applied egg-rr99.1%

    \[\leadsto \color{blue}{{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  6. Add Preprocessing

Alternative 2: 97.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 54.0%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Simplified99.4%

      \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    5. Applied egg-rr99.5%

      \[\leadsto \color{blue}{{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
    6. Taylor expanded in uy around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right)\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right)\right)\right)\right)\right) \]
      17. +-lowering-+.f3299.4%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified99.4%

      \[\leadsto \color{blue}{\cos \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    9. Step-by-step derivation
      1. metadata-evalN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) + 1\right)\right)\right)\right) \]
      5. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right) + 1 \cdot \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right)\right) \]
      6. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right)\right) \]
      16. --lowering--.f3299.5%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
    10. Applied egg-rr99.5%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
      7. unpow2N/A

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(\color{blue}{1}, maxCos\right)\right)\right)\right)\right) \]
      10. PI-lowering-PI.f3299.5%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, \color{blue}{maxCos}\right)\right)\right)\right)\right) \]
    13. Simplified99.5%

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

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

    1. Initial program 60.8%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Simplified97.8%

      \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    5. Applied egg-rr97.9%

      \[\leadsto \color{blue}{{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
    6. Taylor expanded in uy around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right)\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right)\right)\right)\right)\right) \]
      17. +-lowering-+.f3297.9%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified97.9%

      \[\leadsto \color{blue}{\cos \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    9. Step-by-step derivation
      1. metadata-evalN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) + 1\right)\right)\right)\right) \]
      5. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right) + 1 \cdot \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right)\right) \]
      6. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right)\right) \]
      16. --lowering--.f3297.9%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
    10. Applied egg-rr97.9%

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(ux, \mathsf{*.f32}\left(ux, \left(1 + -1 \cdot ux\right)\right)\right)\right)\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(ux, \mathsf{*.f32}\left(ux, \left(1 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right)\right)\right) \]
      4. unsub-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(ux, \mathsf{*.f32}\left(ux, \left(1 - ux\right)\right)\right)\right)\right) \]
      5. --lowering--.f3292.5%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(ux, \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, ux\right)\right)\right)\right)\right) \]
    13. Simplified92.5%

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

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

Alternative 3: 99.0% accurate, 1.0× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

    \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-*l*N/A

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\left(\left(1 + 1\right) + ux \cdot \left(maxCos + -1\right)\right), \left(1 - maxCos\right)\right), ux\right)\right)\right) \]
    7. metadata-evalN/A

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right), \left(1 - maxCos\right)\right), ux\right)\right)\right) \]
    12. --lowering--.f3299.0%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right), \mathsf{\_.f32}\left(1, maxCos\right)\right), ux\right)\right)\right) \]
  5. Applied egg-rr99.0%

    \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right) \cdot ux}} \]
  6. Final simplification99.0%

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

Alternative 4: 97.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 0.00520000001

    1. Initial program 54.0%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Simplified99.4%

      \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    5. Applied egg-rr99.5%

      \[\leadsto \color{blue}{{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
    6. Taylor expanded in uy around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right)\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right)\right)\right)\right)\right) \]
      17. +-lowering-+.f3299.4%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified99.4%

      \[\leadsto \color{blue}{\cos \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    9. Step-by-step derivation
      1. metadata-evalN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) + 1\right)\right)\right)\right) \]
      5. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right) + 1 \cdot \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right)\right) \]
      6. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right)\right) \]
      16. --lowering--.f3299.5%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
    10. Applied egg-rr99.5%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
      7. unpow2N/A

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(\color{blue}{1}, maxCos\right)\right)\right)\right)\right) \]
      10. PI-lowering-PI.f3299.5%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, \color{blue}{maxCos}\right)\right)\right)\right)\right) \]
    13. Simplified99.5%

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

    if 0.00520000001 < uy

    1. Initial program 60.8%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Simplified97.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right)\right) \]
      10. unsub-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \left(2 - ux\right)\right)\right)\right) \]
      11. --lowering--.f3292.4%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right)\right) \]
    6. Simplified92.4%

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

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

Alternative 5: 97.8% accurate, 1.0× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \color{blue}{\left(2 + -1 \cdot ux\right)}\right)\right)\right) \]
  5. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right)\right) \]
    2. unsub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \left(2 - ux\right)\right)\right)\right) \]
    3. --lowering--.f3298.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{\_.f32}\left(2, ux\right)\right)\right)\right) \]
  6. Simplified98.2%

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\left(ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 - ux\right)\right)\right)\right)\right) \]
    2. *-commutativeN/A

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\left(1 - maxCos\right), \left(2 - ux\right)\right), ux\right)\right)\right) \]
    5. --lowering--.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \left(2 - ux\right)\right), ux\right)\right)\right) \]
    6. --lowering--.f3298.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{\_.f32}\left(2, ux\right)\right), ux\right)\right)\right) \]
  8. Applied egg-rr98.2%

    \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\color{blue}{\left(\left(1 - maxCos\right) \cdot \left(2 - ux\right)\right) \cdot ux}} \]
  9. Final simplification98.2%

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

Alternative 6: 97.8% accurate, 1.0× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \color{blue}{\left(2 + -1 \cdot ux\right)}\right)\right)\right) \]
  5. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right)\right) \]
    2. unsub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \left(2 - ux\right)\right)\right)\right) \]
    3. --lowering--.f3298.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{\_.f32}\left(2, ux\right)\right)\right)\right) \]
  6. Simplified98.2%

    \[\leadsto \cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \color{blue}{\left(2 - ux\right)}} \]
  7. Final simplification98.2%

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

Alternative 7: 94.0% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if uy < 0.0350000001

    1. Initial program 54.8%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Simplified99.4%

      \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    5. Applied egg-rr99.4%

      \[\leadsto \color{blue}{{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
    6. Taylor expanded in uy around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right)\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right)\right)\right)\right)\right) \]
      17. +-lowering-+.f3299.4%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified99.4%

      \[\leadsto \color{blue}{\cos \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    9. Step-by-step derivation
      1. metadata-evalN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) + 1\right)\right)\right)\right) \]
      5. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right) + 1 \cdot \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right)\right) \]
      6. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right)\right) \]
      16. --lowering--.f3299.4%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
    10. Applied egg-rr99.4%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
      7. unpow2N/A

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(\color{blue}{1}, maxCos\right)\right)\right)\right)\right) \]
      10. PI-lowering-PI.f3297.9%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, \color{blue}{maxCos}\right)\right)\right)\right)\right) \]
    13. Simplified97.9%

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

    if 0.0350000001 < uy

    1. Initial program 60.4%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Simplified97.3%

      \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    5. Applied egg-rr97.3%

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

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)}\right), \mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
      2. sub-negN/A

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \left(2 - ux\right)\right)\right), \mathsf{cos.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
      5. --lowering--.f3292.0%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right), \mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
    8. Simplified92.0%

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\left(ux \cdot 2\right)\right), \mathsf{cos.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f3269.5%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, 2\right)\right), \mathsf{cos.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
    11. Simplified69.5%

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

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

Alternative 8: 88.4% accurate, 1.7× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

    \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
  5. Applied egg-rr99.1%

    \[\leadsto \color{blue}{{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  6. Taylor expanded in uy around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right)\right)\right)\right)\right) \]
    15. sub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    16. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right)\right)\right)\right)\right) \]
    17. +-lowering-+.f3299.0%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right)\right)\right)\right) \]
  8. Simplified99.0%

    \[\leadsto \color{blue}{\cos \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
  9. Step-by-step derivation
    1. metadata-evalN/A

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) + 1\right)\right)\right)\right) \]
    5. distribute-rgt-inN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\left(\left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right) + 1 \cdot \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right)\right) \]
    6. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right)\right) \]
    16. --lowering--.f3299.0%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
  10. Applied egg-rr99.0%

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right)\right) \]
    7. unpow2N/A

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(\color{blue}{1}, maxCos\right)\right)\right)\right)\right) \]
    10. PI-lowering-PI.f3286.5%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, \color{blue}{maxCos}\right)\right)\right)\right)\right) \]
  13. Simplified86.5%

    \[\leadsto \color{blue}{\left(1 + \left(-2 \cdot \left(uy \cdot uy\right)\right) \cdot \left(\pi \cdot \pi\right)\right)} \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + ux \cdot \left(maxCos + -1\right)\right) + ux \cdot \left(1 - maxCos\right)} \]
  14. Final simplification86.5%

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

Alternative 9: 88.4% accurate, 1.8× speedup?

\[\begin{array}{l} \\ {\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \left(1 + \left(-2 \cdot \left(uy \cdot uy\right)\right) \cdot \left(\pi \cdot \pi\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (pow (* ux (* (+ (* ux (+ maxCos -1.0)) 2.0) (- 1.0 maxCos))) 0.5)
  (+ 1.0 (* (* -2.0 (* uy uy)) (* PI PI)))))
float code(float ux, float uy, float maxCos) {
	return powf((ux * (((ux * (maxCos + -1.0f)) + 2.0f) * (1.0f - maxCos))), 0.5f) * (1.0f + ((-2.0f * (uy * uy)) * (((float) M_PI) * ((float) M_PI))));
}
function code(ux, uy, maxCos)
	return Float32((Float32(ux * Float32(Float32(Float32(ux * Float32(maxCos + Float32(-1.0))) + Float32(2.0)) * Float32(Float32(1.0) - maxCos))) ^ Float32(0.5)) * Float32(Float32(1.0) + Float32(Float32(Float32(-2.0) * Float32(uy * uy)) * Float32(Float32(pi) * Float32(pi)))))
end
function tmp = code(ux, uy, maxCos)
	tmp = ((ux * (((ux * (maxCos + single(-1.0))) + single(2.0)) * (single(1.0) - maxCos))) ^ single(0.5)) * (single(1.0) + ((single(-2.0) * (uy * uy)) * (single(pi) * single(pi))));
end
\begin{array}{l}

\\
{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \left(1 + \left(-2 \cdot \left(uy \cdot uy\right)\right) \cdot \left(\pi \cdot \pi\right)\right)
\end{array}
Derivation
  1. Initial program 55.7%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

    \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
  5. Applied egg-rr99.1%

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right), \mathsf{\_.f32}\left(1, maxCos\right)\right)\right), \frac{1}{2}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \left({uy}^{2}\right)\right), \left({\color{blue}{\mathsf{PI}\left(\right)}}^{2}\right)\right)\right)\right) \]
    5. unpow2N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right), \mathsf{\_.f32}\left(1, maxCos\right)\right)\right), \frac{1}{2}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \left(uy \cdot uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right) \]
    6. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right), \mathsf{\_.f32}\left(1, maxCos\right)\right)\right), \frac{1}{2}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right) \]
    7. unpow2N/A

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right), \mathsf{\_.f32}\left(1, maxCos\right)\right)\right), \frac{1}{2}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    10. PI-lowering-PI.f3286.5%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{pow.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right), \mathsf{\_.f32}\left(1, maxCos\right)\right)\right), \frac{1}{2}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
  8. Simplified86.5%

    \[\leadsto {\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \color{blue}{\left(1 + \left(-2 \cdot \left(uy \cdot uy\right)\right) \cdot \left(\pi \cdot \pi\right)\right)} \]
  9. Add Preprocessing

Alternative 10: 88.4% accurate, 1.8× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

    \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
  5. Applied egg-rr99.1%

    \[\leadsto \color{blue}{{\left(ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)\right)}^{0.5} \cdot \cos \left(2 \cdot \left(uy \cdot \pi\right)\right)} \]
  6. Taylor expanded in uy around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right)\right)\right)\right)\right) \]
    15. sub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    16. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right)\right)\right)\right)\right) \]
    17. +-lowering-+.f3299.0%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(2, uy\right), \mathsf{PI.f32}\left(\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right)\right)\right)\right) \]
  8. Simplified99.0%

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \color{blue}{maxCos}\right), \mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right)\right)\right)\right) \]
    7. unpow2N/A

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(\color{blue}{2}, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right)\right)\right)\right)\right) \]
    10. PI-lowering-PI.f3286.5%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(2, \color{blue}{\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)}\right)\right)\right)\right)\right) \]
  11. Simplified86.5%

    \[\leadsto \color{blue}{\left(1 + \left(-2 \cdot \left(uy \cdot uy\right)\right) \cdot \left(\pi \cdot \pi\right)\right)} \cdot \sqrt{ux \cdot \left(\left(1 - maxCos\right) \cdot \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right)} \]
  12. Final simplification86.5%

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

Alternative 11: 86.7% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 55.0%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Simplified99.5%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
      8. sub-negN/A

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
      10. +-lowering-+.f32N/A

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

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right) \]
      12. --lowering--.f3299.0%

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
    6. Simplified99.0%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right), ux\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \left(ux \cdot \left(maxCos + -1\right) + 2\right)\right), ux\right)\right) \]
      10. +-lowering-+.f32N/A

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(\left(ux \cdot \left(maxCos + -1\right)\right), 2\right)\right), ux\right)\right) \]
      11. *-lowering-*.f32N/A

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right), 2\right)\right), ux\right)\right) \]
      12. +-lowering-+.f3299.1%

        \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right)\right), ux\right)\right) \]
    8. Applied egg-rr99.1%

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

    if 2.35e-4 < uy

    1. Initial program 56.8%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Simplified98.2%

      \[\leadsto \color{blue}{\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{\left(ux \cdot \left(1 - maxCos\right)\right) \cdot \left(1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right)\right)}\right), \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)}\right) \]
    5. Applied egg-rr98.3%

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

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

        \[\leadsto \mathsf{*.f32}\left(\left(\sqrt{ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)}\right), \mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
      2. sub-negN/A

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \left(2 - ux\right)\right)\right), \mathsf{cos.f32}\left(\mathsf{*.f32}\left(\color{blue}{2}, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
      5. --lowering--.f3292.2%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right), \mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
    8. Simplified92.2%

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

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

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

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \left({uy}^{2}\right)\right), \left({\color{blue}{\mathsf{PI}\left(\right)}}^{2}\right)\right)\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \left(uy \cdot uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right) \]
      6. *-lowering-*.f32N/A

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right)\right) \]
      7. unpow2N/A

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

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

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      10. PI-lowering-PI.f3263.3%

        \[\leadsto \mathsf{*.f32}\left(\mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right)\right) \]
    11. Simplified63.3%

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

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

Alternative 12: 87.4% accurate, 1.8× speedup?

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

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

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

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

    \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \color{blue}{\left(2 + -1 \cdot ux\right)}\right)\right)\right) \]
  5. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right)\right) \]
    2. unsub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \left(2 - ux\right)\right)\right)\right) \]
    3. --lowering--.f3298.2%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{cos.f32}\left(\mathsf{*.f32}\left(2, \mathsf{*.f32}\left(uy, \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{\_.f32}\left(2, ux\right)\right)\right)\right) \]
  6. Simplified98.2%

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \left({\mathsf{PI}\left(\right)}^{2}\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{\_.f32}\left(2, ux\right)\right)\right)\right) \]
    7. unpow2N/A

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

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

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{\_.f32}\left(2, ux\right)\right)\right)\right) \]
    10. PI-lowering-PI.f3285.8%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{*.f32}\left(uy, uy\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{PI.f32}\left(\right)\right)\right)\right), \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right), \mathsf{\_.f32}\left(2, ux\right)\right)\right)\right) \]
  9. Simplified85.8%

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

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

Alternative 13: 80.3% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \sqrt{ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt (* ux (* (+ (* ux (+ maxCos -1.0)) 2.0) (- 1.0 maxCos)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux * (((ux * (maxCos + -1.0f)) + 2.0f) * (1.0f - maxCos))));
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt((ux * (((ux * (maxcos + (-1.0e0))) + 2.0e0) * (1.0e0 - maxcos))))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(ux * Float32(Float32(Float32(ux * Float32(maxCos + Float32(-1.0))) + Float32(2.0)) * Float32(Float32(1.0) - maxCos))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((ux * (((ux * (maxCos + single(-1.0))) + single(2.0)) * (single(1.0) - maxCos))));
end
\begin{array}{l}

\\
\sqrt{ux \cdot \left(\left(ux \cdot \left(maxCos + -1\right) + 2\right) \cdot \left(1 - maxCos\right)\right)}
\end{array}
Derivation
  1. Initial program 55.7%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    8. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    9. metadata-evalN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    10. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right) \]
    12. --lowering--.f3279.1%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
  6. Simplified79.1%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \left(2 + ux \cdot \left(maxCos + -1\right)\right)\right), ux\right)\right) \]
    9. +-commutativeN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \left(ux \cdot \left(maxCos + -1\right) + 2\right)\right), ux\right)\right) \]
    10. +-lowering-+.f32N/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(\left(ux \cdot \left(maxCos + -1\right)\right), 2\right)\right), ux\right)\right) \]
    11. *-lowering-*.f32N/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right), 2\right)\right), ux\right)\right) \]
    12. +-lowering-+.f3279.1%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, maxCos\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right), 2\right)\right), ux\right)\right) \]
  8. Applied egg-rr79.1%

    \[\leadsto \sqrt{\color{blue}{\left(\left(1 - maxCos\right) \cdot \left(ux \cdot \left(maxCos + -1\right) + 2\right)\right) \cdot ux}} \]
  9. Final simplification79.1%

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

Alternative 14: 79.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \sqrt{\left(2 - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right)} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (sqrt (* (- 2.0 ux) (* ux (- 1.0 maxCos)))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(((2.0f - ux) * (ux * (1.0f - maxCos))));
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt(((2.0e0 - ux) * (ux * (1.0e0 - maxcos))))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(Float32(2.0) - ux) * Float32(ux * Float32(Float32(1.0) - maxCos))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt(((single(2.0) - ux) * (ux * (single(1.0) - maxCos))));
end
\begin{array}{l}

\\
\sqrt{\left(2 - ux\right) \cdot \left(ux \cdot \left(1 - maxCos\right)\right)}
\end{array}
Derivation
  1. Initial program 55.7%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    8. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    9. metadata-evalN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    10. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right) \]
    12. --lowering--.f3279.1%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
  6. Simplified79.1%

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

    \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\color{blue}{\left(2 + -1 \cdot ux\right)}, \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
  8. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\left(2 - ux\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
    3. --lowering--.f3278.5%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(2, ux\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
  9. Simplified78.5%

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

Alternative 15: 76.1% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \sqrt{ux \cdot 2 - ux \cdot ux} \end{array} \]
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* ux 2.0) (* ux ux))))
float code(float ux, float uy, float maxCos) {
	return sqrtf(((ux * 2.0f) - (ux * ux)));
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt(((ux * 2.0e0) - (ux * ux)))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(Float32(ux * Float32(2.0)) - Float32(ux * ux)))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt(((ux * single(2.0)) - (ux * ux)));
end
\begin{array}{l}

\\
\sqrt{ux \cdot 2 - ux \cdot ux}
\end{array}
Derivation
  1. Initial program 55.7%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    8. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    9. metadata-evalN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    10. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right) \]
    12. --lowering--.f3279.1%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
  6. Simplified79.1%

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

    \[\leadsto \mathsf{sqrt.f32}\left(\color{blue}{\left(ux \cdot \left(2 + -1 \cdot ux\right)\right)}\right) \]
  8. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\left(ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\left(ux \cdot \left(2 - ux\right)\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \left(2 - ux\right)\right)\right) \]
    4. --lowering--.f3274.5%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right) \]
  9. Simplified74.5%

    \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \]
  10. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\left(ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right) \]
    2. distribute-rgt-inN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\left(2 \cdot ux + \left(\mathsf{neg}\left(ux\right)\right) \cdot ux\right)\right) \]
    3. +-lowering-+.f32N/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\left(2 \cdot ux\right), \left(\left(\mathsf{neg}\left(ux\right)\right) \cdot ux\right)\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(2, ux\right), \left(\left(\mathsf{neg}\left(ux\right)\right) \cdot ux\right)\right)\right) \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(2, ux\right), \mathsf{*.f32}\left(\left(\mathsf{neg}\left(ux\right)\right), ux\right)\right)\right) \]
    6. neg-lowering-neg.f3274.6%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(2, ux\right), \mathsf{*.f32}\left(\mathsf{neg.f32}\left(ux\right), ux\right)\right)\right) \]
  11. Applied egg-rr74.6%

    \[\leadsto \sqrt{\color{blue}{2 \cdot ux + \left(-ux\right) \cdot ux}} \]
  12. Final simplification74.6%

    \[\leadsto \sqrt{ux \cdot 2 - ux \cdot ux} \]
  13. Add Preprocessing

Alternative 16: 76.1% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \sqrt{ux \cdot \left(2 - ux\right)} \end{array} \]
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (- 2.0 ux))))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux * (2.0f - ux)));
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt((ux * (2.0e0 - ux)))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(ux * Float32(Float32(2.0) - ux)))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((ux * (single(2.0) - ux)));
end
\begin{array}{l}

\\
\sqrt{ux \cdot \left(2 - ux\right)}
\end{array}
Derivation
  1. Initial program 55.7%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    8. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    9. metadata-evalN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    10. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right) \]
    12. --lowering--.f3279.1%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
  6. Simplified79.1%

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

    \[\leadsto \mathsf{sqrt.f32}\left(\color{blue}{\left(ux \cdot \left(2 + -1 \cdot ux\right)\right)}\right) \]
  8. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\left(ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\left(ux \cdot \left(2 - ux\right)\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \left(2 - ux\right)\right)\right) \]
    4. --lowering--.f3274.5%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right) \]
  9. Simplified74.5%

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

Alternative 17: 62.3% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \sqrt{ux \cdot 2} \end{array} \]
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux 2.0)))
float code(float ux, float uy, float maxCos) {
	return sqrtf((ux * 2.0f));
}
real(4) function code(ux, uy, maxcos)
    real(4), intent (in) :: ux
    real(4), intent (in) :: uy
    real(4), intent (in) :: maxcos
    code = sqrt((ux * 2.0e0))
end function
function code(ux, uy, maxCos)
	return sqrt(Float32(ux * Float32(2.0)))
end
function tmp = code(ux, uy, maxCos)
	tmp = sqrt((ux * single(2.0)));
end
\begin{array}{l}

\\
\sqrt{ux \cdot 2}
\end{array}
Derivation
  1. Initial program 55.7%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Simplified99.0%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos - 1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    8. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + \left(\mathsf{neg}\left(1\right)\right)\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    9. metadata-evalN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \left(maxCos + -1\right)\right)\right), \left(ux \cdot \left(1 - maxCos\right)\right)\right)\right) \]
    10. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \left(1 - maxCos\right)\right)\right)\right) \]
    12. --lowering--.f3279.1%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(2, \mathsf{*.f32}\left(ux, \mathsf{+.f32}\left(maxCos, -1\right)\right)\right), \mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(1, maxCos\right)\right)\right)\right) \]
  6. Simplified79.1%

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

    \[\leadsto \mathsf{sqrt.f32}\left(\color{blue}{\left(ux \cdot \left(2 + -1 \cdot ux\right)\right)}\right) \]
  8. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\left(ux \cdot \left(2 + \left(\mathsf{neg}\left(ux\right)\right)\right)\right)\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{sqrt.f32}\left(\left(ux \cdot \left(2 - ux\right)\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \left(2 - ux\right)\right)\right) \]
    4. --lowering--.f3274.5%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, \mathsf{\_.f32}\left(2, ux\right)\right)\right) \]
  9. Simplified74.5%

    \[\leadsto \sqrt{\color{blue}{ux \cdot \left(2 - ux\right)}} \]
  10. Taylor expanded in ux around 0

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

      \[\leadsto \mathsf{sqrt.f32}\left(\left(ux \cdot 2\right)\right) \]
    2. *-lowering-*.f3261.5%

      \[\leadsto \mathsf{sqrt.f32}\left(\mathsf{*.f32}\left(ux, 2\right)\right) \]
  12. Simplified61.5%

    \[\leadsto \sqrt{\color{blue}{ux \cdot 2}} \]
  13. Add Preprocessing

Reproduce

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