| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 13408 |
\[\sqrt{\left(2 - \left(maxCos + maxCos\right)\right) \cdot ux - {\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}} \cdot \cos \left(\left(uy \cdot \pi\right) \cdot -2\right)
\]
(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 (- (* (- 2.0 (* 2.0 maxCos)) ux) (pow (* ux (+ maxCos -1.0)) 2.0))) (sin (* PI (- 0.5 (* uy 2.0))))))
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((((2.0f - (2.0f * maxCos)) * ux) - powf((ux * (maxCos + -1.0f)), 2.0f))) * sinf((((float) M_PI) * (0.5f - (uy * 2.0f))));
}
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(sqrt(Float32(Float32(Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)) * ux) - (Float32(ux * Float32(maxCos + Float32(-1.0))) ^ Float32(2.0)))) * sin(Float32(Float32(pi) * Float32(Float32(0.5) - Float32(uy * Float32(2.0)))))) end
function tmp = code(ux, uy, maxCos) tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (((single(1.0) - ux) + (ux * maxCos)) * ((single(1.0) - ux) + (ux * maxCos))))); end
function tmp = code(ux, uy, maxCos) tmp = sqrt((((single(2.0) - (single(2.0) * maxCos)) * ux) - ((ux * (maxCos + single(-1.0))) ^ single(2.0)))) * sin((single(pi) * (single(0.5) - (uy * single(2.0))))); 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)}
\sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}} \cdot \sin \left(\pi \cdot \left(0.5 - uy \cdot 2\right)\right)
Results
Initial program 13.6
Taylor expanded in ux around 0 0.3
Simplified0.3
[Start]0.3 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + -1 \cdot \left({\left(maxCos - 1\right)}^{2} \cdot {ux}^{2}\right)}
\] |
|---|---|
rational.json-simplify-2 [=>]0.3 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + \color{blue}{\left({\left(maxCos - 1\right)}^{2} \cdot {ux}^{2}\right) \cdot -1}}
\] |
rational.json-simplify-9 [=>]0.3 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + \color{blue}{\left(-{\left(maxCos - 1\right)}^{2} \cdot {ux}^{2}\right)}}
\] |
exponential.json-simplify-27 [=>]0.3 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + \left(-\color{blue}{{\left(\left(maxCos - 1\right) \cdot ux\right)}^{2}}\right)}
\] |
rational.json-simplify-2 [=>]0.3 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + \left(-{\color{blue}{\left(ux \cdot \left(maxCos - 1\right)\right)}}^{2}\right)}
\] |
rational.json-simplify-16 [=>]0.3 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + \left(-{\left(ux \cdot \color{blue}{\left(maxCos + -1\right)}\right)}^{2}\right)}
\] |
Applied egg-rr0.3
Taylor expanded in uy around inf 0.3
Simplified0.3
[Start]0.3 | \[ \sin \left(0.5 \cdot \pi - 2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(maxCos - 1\right)}^{2} \cdot {ux}^{2}}
\] |
|---|---|
rational.json-simplify-2 [=>]0.3 | \[ \color{blue}{\sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(maxCos - 1\right)}^{2} \cdot {ux}^{2}} \cdot \sin \left(0.5 \cdot \pi - 2 \cdot \left(uy \cdot \pi\right)\right)}
\] |
exponential.json-simplify-27 [=>]0.3 | \[ \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - \color{blue}{{\left(\left(maxCos - 1\right) \cdot ux\right)}^{2}}} \cdot \sin \left(0.5 \cdot \pi - 2 \cdot \left(uy \cdot \pi\right)\right)
\] |
rational.json-simplify-15 [<=]0.3 | \[ \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(\color{blue}{\left(maxCos + -1\right)} \cdot ux\right)}^{2}} \cdot \sin \left(0.5 \cdot \pi - 2 \cdot \left(uy \cdot \pi\right)\right)
\] |
rational.json-simplify-2 [<=]0.3 | \[ \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\color{blue}{\left(ux \cdot \left(maxCos + -1\right)\right)}}^{2}} \cdot \sin \left(0.5 \cdot \pi - 2 \cdot \left(uy \cdot \pi\right)\right)
\] |
rational.json-simplify-2 [=>]0.3 | \[ \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}} \cdot \sin \left(\color{blue}{\pi \cdot 0.5} - 2 \cdot \left(uy \cdot \pi\right)\right)
\] |
rational.json-simplify-2 [=>]0.3 | \[ \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}} \cdot \sin \left(\pi \cdot 0.5 - 2 \cdot \color{blue}{\left(\pi \cdot uy\right)}\right)
\] |
rational.json-simplify-43 [=>]0.3 | \[ \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}} \cdot \sin \left(\pi \cdot 0.5 - \color{blue}{\pi \cdot \left(uy \cdot 2\right)}\right)
\] |
rational.json-simplify-2 [=>]0.3 | \[ \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}} \cdot \sin \left(\pi \cdot 0.5 - \color{blue}{\left(uy \cdot 2\right) \cdot \pi}\right)
\] |
rational.json-simplify-48 [=>]0.3 | \[ \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux - {\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}} \cdot \sin \color{blue}{\left(\pi \cdot \left(0.5 - uy \cdot 2\right)\right)}
\] |
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 13408 |
| Alternative 2 | |
|---|---|
| Error | 1.1 |
| Cost | 13348 |
| Alternative 3 | |
|---|---|
| Error | 0.8 |
| Cost | 13344 |
| Alternative 4 | |
|---|---|
| Error | 1.1 |
| Cost | 13284 |
| Alternative 5 | |
|---|---|
| Error | 2.8 |
| Cost | 10564 |
| Alternative 6 | |
|---|---|
| Error | 2.8 |
| Cost | 10500 |
| Alternative 7 | |
|---|---|
| Error | 2.7 |
| Cost | 10372 |
| Alternative 8 | |
|---|---|
| Error | 3.0 |
| Cost | 10180 |
| Alternative 9 | |
|---|---|
| Error | 3.0 |
| Cost | 10116 |
| Alternative 10 | |
|---|---|
| Error | 3.3 |
| Cost | 10052 |
| Alternative 11 | |
|---|---|
| Error | 3.4 |
| Cost | 9988 |
| Alternative 12 | |
|---|---|
| Error | 6.4 |
| Cost | 6848 |
| Alternative 13 | |
|---|---|
| Error | 7.9 |
| Cost | 6788 |
| Alternative 14 | |
|---|---|
| Error | 8.4 |
| Cost | 6660 |
| Alternative 15 | |
|---|---|
| Error | 11.3 |
| Cost | 3424 |
| Alternative 16 | |
|---|---|
| Error | 11.3 |
| Cost | 3424 |
| Alternative 17 | |
|---|---|
| Error | 12.2 |
| Cost | 3296 |
herbie shell --seed 2023077
(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)))))))