| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 13408 |
(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 (* (- (cos (* 2.0 (* uy PI))) (* (cos (/ PI 2.0)) (cos (/ (* PI (- 1.0 (* uy 4.0))) 2.0)))) (sqrt (+ (* (- 2.0 (* 2.0 maxCos)) ux) (- (pow (* ux (+ maxCos -1.0)) 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 (cosf((2.0f * (uy * ((float) M_PI)))) - (cosf((((float) M_PI) / 2.0f)) * cosf(((((float) M_PI) * (1.0f - (uy * 4.0f))) / 2.0f)))) * sqrtf((((2.0f - (2.0f * maxCos)) * ux) + -powf((ux * (maxCos + -1.0f)), 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(Float32(cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) - Float32(cos(Float32(Float32(pi) / Float32(2.0))) * cos(Float32(Float32(Float32(pi) * Float32(Float32(1.0) - Float32(uy * Float32(4.0)))) / Float32(2.0))))) * sqrt(Float32(Float32(Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)) * ux) + Float32(-(Float32(ux * Float32(maxCos + Float32(-1.0))) ^ 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 = (cos((single(2.0) * (uy * single(pi)))) - (cos((single(pi) / single(2.0))) * cos(((single(pi) * (single(1.0) - (uy * single(4.0)))) / single(2.0))))) * sqrt((((single(2.0) - (single(2.0) * maxCos)) * ux) + -((ux * (maxCos + single(-1.0))) ^ 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)}
\left(\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) - \cos \left(\frac{\pi}{2}\right) \cdot \cos \left(\frac{\pi \cdot \left(1 - uy \cdot 4\right)}{2}\right)\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + \left(-{\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}\right)}
Results
Initial program 13.6
Simplified13.6
[Start]13.6 | \[ \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)}
\] |
|---|---|
rational_best-simplify-59 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}
\] |
rational_best-simplify-59 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right) \cdot \color{blue}{\left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)}}
\] |
rational_best-simplify-14 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(ux \cdot maxCos - \color{blue}{\left(0 - \left(1 - ux\right)\right)}\right) \cdot \left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)}
\] |
rational_best-simplify-51 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(ux \cdot maxCos - \color{blue}{\left(ux - \left(1 - 0\right)\right)}\right) \cdot \left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)}
\] |
metadata-eval [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(ux \cdot maxCos - \left(ux - \color{blue}{1}\right)\right) \cdot \left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)}
\] |
rational_best-simplify-18 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(ux \cdot maxCos - \color{blue}{\left(ux + -1\right)}\right) \cdot \left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)}
\] |
rational_best-simplify-57 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(\left(ux \cdot maxCos - ux\right) + \left(--1\right)\right)} \cdot \left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)}
\] |
metadata-eval [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(\left(ux \cdot maxCos - ux\right) + \color{blue}{1}\right) \cdot \left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)}
\] |
rational_best-simplify-3 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\left(1 + \left(ux \cdot maxCos - ux\right)\right)} \cdot \left(ux \cdot maxCos - \left(-\left(1 - ux\right)\right)\right)}
\] |
rational_best-simplify-14 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(1 + \left(ux \cdot maxCos - ux\right)\right) \cdot \left(ux \cdot maxCos - \color{blue}{\left(0 - \left(1 - ux\right)\right)}\right)}
\] |
rational_best-simplify-51 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(1 + \left(ux \cdot maxCos - ux\right)\right) \cdot \left(ux \cdot maxCos - \color{blue}{\left(ux - \left(1 - 0\right)\right)}\right)}
\] |
metadata-eval [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(1 + \left(ux \cdot maxCos - ux\right)\right) \cdot \left(ux \cdot maxCos - \left(ux - \color{blue}{1}\right)\right)}
\] |
rational_best-simplify-18 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(1 + \left(ux \cdot maxCos - ux\right)\right) \cdot \left(ux \cdot maxCos - \color{blue}{\left(ux + -1\right)}\right)}
\] |
rational_best-simplify-57 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(1 + \left(ux \cdot maxCos - ux\right)\right) \cdot \color{blue}{\left(\left(ux \cdot maxCos - ux\right) + \left(--1\right)\right)}}
\] |
metadata-eval [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(1 + \left(ux \cdot maxCos - ux\right)\right) \cdot \left(\left(ux \cdot maxCos - ux\right) + \color{blue}{1}\right)}
\] |
rational_best-simplify-3 [=>]13.6 | \[ \cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \left(1 + \left(ux \cdot maxCos - ux\right)\right) \cdot \color{blue}{\left(1 + \left(ux \cdot maxCos - ux\right)\right)}}
\] |
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_best-simplify-1 [=>]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_best-simplify-10 [=>]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-simplify-28 [=>]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_best-simplify-1 [=>]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_best-simplify-18 [=>]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
Simplified0.3
[Start]0.3 | \[ \frac{2 \cdot \cos \left(uy \cdot \left(2 \cdot \pi\right)\right) - \left(\cos \left(\frac{\pi}{2} + \frac{\pi \cdot \left(1 - uy \cdot 4\right)}{2}\right) + \cos \left(\frac{\pi - \pi \cdot \left(1 - uy \cdot 4\right)}{2}\right)\right)}{2} \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + \left(-{\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}\right)}
\] |
|---|---|
rational_best-simplify-67 [=>]0.3 | \[ \color{blue}{\left(\frac{2 \cdot \cos \left(uy \cdot \left(2 \cdot \pi\right)\right)}{2} - \frac{\cos \left(\frac{\pi}{2} + \frac{\pi \cdot \left(1 - uy \cdot 4\right)}{2}\right) + \cos \left(\frac{\pi - \pi \cdot \left(1 - uy \cdot 4\right)}{2}\right)}{2}\right)} \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux + \left(-{\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}\right)}
\] |
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 13408 |
| Alternative 2 | |
|---|---|
| Error | 1.1 |
| Cost | 13284 |
| Alternative 3 | |
|---|---|
| Error | 0.8 |
| Cost | 13280 |
| Alternative 4 | |
|---|---|
| Error | 2.8 |
| Cost | 10628 |
| Alternative 5 | |
|---|---|
| Error | 2.8 |
| Cost | 10372 |
| Alternative 6 | |
|---|---|
| Error | 2.8 |
| Cost | 10116 |
| Alternative 7 | |
|---|---|
| Error | 3.2 |
| Cost | 9988 |
| Alternative 8 | |
|---|---|
| Error | 6.2 |
| Cost | 6848 |
| Alternative 9 | |
|---|---|
| Error | 7.6 |
| Cost | 6592 |
| Alternative 10 | |
|---|---|
| Error | 7.8 |
| Cost | 3812 |
| Alternative 11 | |
|---|---|
| Error | 11.2 |
| Cost | 3488 |
| Alternative 12 | |
|---|---|
| Error | 11.2 |
| Cost | 3424 |
| Alternative 13 | |
|---|---|
| Error | 12.0 |
| Cost | 3296 |
herbie shell --seed 2023099
(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)))))))