UniformSampleCone, x

?

Percentage Accurate: 57.9% → 98.9%
Time: 13.4s
Precision: binary32
Cost: 16576

?

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

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

Herbie found 10 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Derivation?

  1. Initial program 53.8%

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

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

    [Start]53.8%

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

    associate-*l* [=>]53.8%

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

    sub-neg [=>]53.8%

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

    +-commutative [=>]53.8%

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

    distribute-rgt-neg-in [=>]53.8%

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

    fma-def [=>]53.9%

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

    +-commutative [=>]53.9%

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

    associate-+r- [=>]54.0%

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

    fma-def [=>]54.0%

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

    neg-sub0 [=>]54.0%

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

    +-commutative [=>]54.0%

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

    associate-+r- [=>]53.9%

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

    associate--r- [=>]53.9%

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

    neg-sub0 [<=]53.9%

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

    +-commutative [=>]53.9%

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

    sub-neg [<=]53.9%

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

    fma-def [=>]53.9%

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

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

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

    [Start]99.1%

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

    fma-def [=>]99.1%

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

    sub-neg [=>]99.1%

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

    metadata-eval [=>]99.1%

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

    *-commutative [=>]99.1%

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

    unpow2 [=>]99.1%

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

    +-commutative [=>]99.1%

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

    mul-1-neg [=>]99.1%

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

    sub-neg [=>]99.1%

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

    metadata-eval [=>]99.1%

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

    distribute-neg-in [=>]99.1%

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

    metadata-eval [=>]99.1%

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

    +-commutative [<=]99.1%

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

    mul-1-neg [<=]99.1%

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

    associate--l+ [=>]99.1%

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

    mul-1-neg [=>]99.1%

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

    sub-neg [<=]99.1%

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

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

    [Start]99.1%

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

    pow1 [=>]99.1%

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

    count-2 [=>]99.1%

    \[ {\left(\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos + -1, \left(ux \cdot ux\right) \cdot \left(1 - maxCos\right), ux \cdot \color{blue}{\left(2 \cdot \left(1 - maxCos\right)\right)}\right)}\right)}^{1} \]
  6. Simplified99.1%

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

    [Start]99.1%

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

    unpow1 [=>]99.1%

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

    *-commutative [=>]99.1%

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

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

    [Start]99.1%

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

    sqrt-prod [=>]99.1%

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

    fma-def [=>]99.1%

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

    *-commutative [=>]99.1%

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

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

Alternatives

Alternative 1
Accuracy98.9%
Cost16576
\[\left(\sqrt{1 - maxCos} \cdot \sqrt{\mathsf{fma}\left(maxCos + -1, ux \cdot ux, ux \cdot 2\right)}\right) \cdot \cos \left(\left(2 \cdot uy\right) \cdot \pi\right) \]
Alternative 2
Accuracy99.0%
Cost13568
\[\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(maxCos + -1, \left(1 - maxCos\right) \cdot \left(ux \cdot ux\right), ux \cdot \left(\left(1 - maxCos\right) + \left(1 - maxCos\right)\right)\right)} \]
Alternative 3
Accuracy99.0%
Cost10240
\[\cos \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(ux \cdot ux\right) + ux \cdot 2\right)} \]
Alternative 4
Accuracy96.5%
Cost10052
\[\begin{array}{l} \mathbf{if}\;2 \cdot uy \leq 0.0001500000071246177:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(ux, \left(1 - maxCos\right) + \left(1 - maxCos\right), \left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(ux \cdot ux\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\left(2 \cdot uy\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\ \end{array} \]
Alternative 5
Accuracy89.5%
Cost9924
\[\begin{array}{l} \mathbf{if}\;uy \leq 0.0008800000068731606:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(ux, \left(1 - maxCos\right) + \left(1 - maxCos\right), \left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(ux \cdot ux\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot 2}\\ \end{array} \]
Alternative 6
Accuracy80.0%
Cost7008
\[\sqrt{\mathsf{fma}\left(ux, \left(1 - maxCos\right) + \left(1 - maxCos\right), \left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(ux \cdot ux\right)\right)\right)} \]
Alternative 7
Accuracy80.0%
Cost6976
\[\sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot {ux}^{2}\right) + ux \cdot \left(2 - maxCos \cdot 2\right)} \]
Alternative 8
Accuracy80.0%
Cost3680
\[\sqrt{\left(1 - maxCos\right) \cdot \left(\left(maxCos + -1\right) \cdot \left(ux \cdot ux\right) + ux \cdot 2\right)} \]
Alternative 9
Accuracy75.9%
Cost3424
\[\sqrt{ux \cdot 2 - ux \cdot ux} \]
Alternative 10
Accuracy62.0%
Cost3296
\[\sqrt{ux \cdot 2} \]

Reproduce?

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