UniformSampleCone, y

Percentage Accurate: 57.4% → 98.3%
Time: 7.7s
Alternatives: 18
Speedup: 4.5×

Specification

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

Initial Program: 57.4% accurate, 1.0× speedup?

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

Alternative 1: 98.3% accurate, 1.1× speedup?

\[\sin \left(\left(\pi + \pi\right) \cdot uy\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(maxCos \cdot ux - ux\right) - -2\right)} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (sin (* (+ PI PI) uy))
 (sqrt (* (- ux (* maxCos ux)) (- (- (* maxCos ux) ux) -2.0)))))
float code(float ux, float uy, float maxCos) {
	return sinf(((((float) M_PI) + ((float) M_PI)) * uy)) * sqrtf(((ux - (maxCos * ux)) * (((maxCos * ux) - ux) - -2.0f)));
}
function code(ux, uy, maxCos)
	return Float32(sin(Float32(Float32(Float32(pi) + Float32(pi)) * uy)) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(Float32(Float32(maxCos * ux) - ux) - Float32(-2.0)))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sin(((single(pi) + single(pi)) * uy)) * sqrt(((ux - (maxCos * ux)) * (((maxCos * ux) - ux) - single(-2.0))));
end
\sin \left(\left(\pi + \pi\right) \cdot uy\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(maxCos \cdot ux - ux\right) - -2\right)}
Derivation
  1. Initial program 57.4%

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(ux - maxCos \cdot ux\right) - 2\right)}\right)\right)} \]
    3. sub-negateN/A

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(2 + \left(\mathsf{neg}\left(\color{blue}{\left(ux - maxCos \cdot ux\right)}\right)\right)\right)} \]
    6. sub-negate-revN/A

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(\left(maxCos \cdot ux - ux\right) + 2\right)}} \]
    9. add-flip-revN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(\left(maxCos \cdot ux - ux\right) - \left(\mathsf{neg}\left(2\right)\right)\right)}} \]
    11. metadata-eval98.3%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.3% accurate, 1.1× speedup?

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\left(ux - maxCos \cdot ux\right) - 2\right)}\right)\right)} \]
    3. sub-negateN/A

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(2 + \left(\mathsf{neg}\left(\color{blue}{\left(ux - maxCos \cdot ux\right)}\right)\right)\right)} \]
    6. sub-negate-revN/A

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(\left(maxCos \cdot ux - ux\right) + 2\right)}} \]
    9. add-flip-revN/A

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(\left(maxCos \cdot ux - ux\right) - \left(\mathsf{neg}\left(2\right)\right)\right)}} \]
    11. metadata-eval98.3%

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

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

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux + \left(\mathsf{neg}\left(\left(ux - \color{blue}{2}\right)\right)\right)\right)} \]
    7. sub-negate-revN/A

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

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

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

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

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

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

Alternative 3: 98.3% accurate, 1.1× speedup?

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

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

Alternative 4: 97.2% accurate, 1.2× speedup?

\[\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(2 - ux\right)} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (* (sin (* (* uy 2.0) PI)) (sqrt (* (- ux (* maxCos ux)) (- 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
	return sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((ux - (maxCos * ux)) * (2.0f - ux)));
}
function code(ux, uy, maxCos)
	return Float32(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(ux - Float32(maxCos * ux)) * Float32(Float32(2.0) - ux))))
end
function tmp = code(ux, uy, maxCos)
	tmp = sin(((uy * single(2.0)) * single(pi))) * sqrt(((ux - (maxCos * ux)) * (single(2.0) - ux)));
end
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(2 - ux\right)}
Derivation
  1. Initial program 57.4%

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

    \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \color{blue}{\left(2 - ux\right)}} \]
  7. Step-by-step derivation
    1. lower--.f3297.2%

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

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

Alternative 5: 96.5% accurate, 1.2× speedup?

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

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


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

    1. Initial program 57.4%

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
      5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

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

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

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

    if 9.50000016e-4 < uy

    1. Initial program 57.4%

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

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

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

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

        \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
      5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

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

Alternative 6: 89.3% accurate, 1.5× speedup?

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

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

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

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

Alternative 7: 89.3% accurate, 1.5× speedup?

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

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

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

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

Alternative 8: 81.7% accurate, 2.2× speedup?

\[\left(\left(uy + uy\right) \cdot \sqrt{0 - \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right) \cdot \left(ux - maxCos \cdot ux\right)}\right) \cdot \pi \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (*
  (+ uy uy)
  (sqrt (- 0.0 (* (- ux (fma maxCos ux 2.0)) (- ux (* maxCos ux))))))
 PI))
float code(float ux, float uy, float maxCos) {
	return ((uy + uy) * sqrtf((0.0f - ((ux - fmaf(maxCos, ux, 2.0f)) * (ux - (maxCos * ux)))))) * ((float) M_PI);
}
function code(ux, uy, maxCos)
	return Float32(Float32(Float32(uy + uy) * sqrt(Float32(Float32(0.0) - Float32(Float32(ux - fma(maxCos, ux, Float32(2.0))) * Float32(ux - Float32(maxCos * ux)))))) * Float32(pi))
end
\left(\left(uy + uy\right) \cdot \sqrt{0 - \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right) \cdot \left(ux - maxCos \cdot ux\right)}\right) \cdot \pi
Derivation
  1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 81.6% accurate, 2.2× speedup?

\[\left(\pi \cdot \left(uy + uy\right)\right) \cdot \sqrt{0 - \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right) \cdot \left(ux - maxCos \cdot ux\right)} \]
(FPCore (ux uy maxCos)
  :precision binary32
  (*
 (* PI (+ uy uy))
 (sqrt (- 0.0 (* (- ux (fma maxCos ux 2.0)) (- ux (* maxCos ux)))))))
float code(float ux, float uy, float maxCos) {
	return (((float) M_PI) * (uy + uy)) * sqrtf((0.0f - ((ux - fmaf(maxCos, ux, 2.0f)) * (ux - (maxCos * ux)))));
}
function code(ux, uy, maxCos)
	return Float32(Float32(Float32(pi) * Float32(uy + uy)) * sqrt(Float32(Float32(0.0) - Float32(Float32(ux - fma(maxCos, ux, Float32(2.0))) * Float32(ux - Float32(maxCos * ux))))))
end
\left(\pi \cdot \left(uy + uy\right)\right) \cdot \sqrt{0 - \left(ux - \mathsf{fma}\left(maxCos, ux, 2\right)\right) \cdot \left(ux - maxCos \cdot ux\right)}
Derivation
  1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 81.6% accurate, 2.4× speedup?

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

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

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

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

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

      \[\leadsto \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\mathsf{neg}\left(\left(\color{blue}{\left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right)} - 1\right)\right)} \]
    5. difference-of-sqr-1N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)}\right)\right) \]
    11. lower-*.f3281.6%

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\left(ux - maxCos \cdot ux\right) \cdot \left(\left(2 + maxCos \cdot ux\right) - ux\right)}\right)\right) \]
  6. Applied rewrites81.6%

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

Alternative 11: 76.0% accurate, 2.2× speedup?

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

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


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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\left(\pi \cdot \sqrt{\left|ux\right|}\right) \cdot \sqrt{\left|\mathsf{fma}\left(maxCos, 2, \mathsf{neg}\left(2\right)\right)\right|}\right)\right) \]
      18. metadata-eval66.2%

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

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

    if 1.74999994e-4 < ux

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
      4. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 75.8% accurate, 1.4× speedup?

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

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


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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\left(\pi \cdot \sqrt{\left|ux\right|}\right) \cdot \sqrt{\left|\mathsf{fma}\left(maxCos, 2, \mathsf{neg}\left(2\right)\right)\right|}\right)\right) \]
      18. metadata-eval66.2%

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

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

Alternative 13: 75.8% accurate, 2.4× speedup?

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

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


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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \left(\sqrt{\left|ux\right|} \cdot \left(\sqrt{\left|\mathsf{fma}\left(maxCos, 2, \mathsf{neg}\left(2\right)\right)\right|} \cdot \pi\right)\right)\right) \]
      19. metadata-eval66.2%

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

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

    if 3.19999992e-4 < ux

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 75.8% accurate, 1.4× speedup?

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

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


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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 75.8% accurate, 1.5× speedup?

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

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


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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 66.2% accurate, 3.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 63.5% accurate, 4.5× speedup?

\[2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right) \]
(FPCore (ux uy maxCos)
  :precision binary32
  (* 2.0 (* uy (* PI (sqrt (* 2.0 ux))))))
float code(float ux, float uy, float maxCos) {
	return 2.0f * (uy * (((float) M_PI) * sqrtf((2.0f * ux))));
}
function code(ux, uy, maxCos)
	return Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(2.0) * ux)))))
end
function tmp = code(ux, uy, maxCos)
	tmp = single(2.0) * (uy * (single(pi) * sqrt((single(2.0) * ux))));
end
2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux}\right)\right)
Derivation
  1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 7.1% accurate, 4.8× speedup?

\[\left(uy + uy\right) \cdot \left(\sqrt{1 - 1} \cdot \pi\right) \]
(FPCore (ux uy maxCos)
  :precision binary32
  (* (+ uy uy) (* (sqrt (- 1.0 1.0)) PI)))
float code(float ux, float uy, float maxCos) {
	return (uy + uy) * (sqrtf((1.0f - 1.0f)) * ((float) M_PI));
}
function code(ux, uy, maxCos)
	return Float32(Float32(uy + uy) * Float32(sqrt(Float32(Float32(1.0) - Float32(1.0))) * Float32(pi)))
end
function tmp = code(ux, uy, maxCos)
	tmp = (uy + uy) * (sqrt((single(1.0) - single(1.0))) * single(pi));
end
\left(uy + uy\right) \cdot \left(\sqrt{1 - 1} \cdot \pi\right)
Derivation
  1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}\right)\right) \]
    4. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{1 - 1}\right)\right) \]
  8. Step-by-step derivation
    1. Applied rewrites7.1%

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

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

        \[\leadsto 2 \cdot \left(uy \cdot \color{blue}{\left(\pi \cdot \sqrt{1 - 1}\right)}\right) \]
    3. Applied rewrites7.1%

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

    Reproduce

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