| Alternative 1 | |
|---|---|
| Error | 2.6 |
| Cost | 30984 |
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))
(FPCore (ux uy maxCos)
:precision binary32
(*
(sin (* (* uy 2.0) PI))
(sqrt
(+
(* (+ maxCos (- (* -1.0 (+ (* maxCos 2.0) (- maxCos 3.0))) 1.0)) ux)
(* (+ (* 2.0 maxCos) (- -1.0 (pow maxCos 2.0))) (pow ux 2.0))))))float code(float ux, float uy, float maxCos) {
return sinf(((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 sinf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((((maxCos + ((-1.0f * ((maxCos * 2.0f) + (maxCos - 3.0f))) - 1.0f)) * ux) + (((2.0f * maxCos) + (-1.0f - powf(maxCos, 2.0f))) * powf(ux, 2.0f))));
}
function code(ux, uy, maxCos) return Float32(sin(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(sin(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(Float32(maxCos + Float32(Float32(Float32(-1.0) * Float32(Float32(maxCos * Float32(2.0)) + Float32(maxCos - Float32(3.0)))) - Float32(1.0))) * ux) + Float32(Float32(Float32(Float32(2.0) * maxCos) + Float32(Float32(-1.0) - (maxCos ^ Float32(2.0)))) * (ux ^ Float32(2.0)))))) end
function tmp = code(ux, uy, maxCos) tmp = sin(((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 = sin(((uy * single(2.0)) * single(pi))) * sqrt((((maxCos + ((single(-1.0) * ((maxCos * single(2.0)) + (maxCos - single(3.0)))) - single(1.0))) * ux) + (((single(2.0) * maxCos) + (single(-1.0) - (maxCos ^ single(2.0)))) * (ux ^ single(2.0))))); end
\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)}
\sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(2 \cdot maxCos + \left(-1 - {maxCos}^{2}\right)\right) \cdot {ux}^{2}}
Results
Initial program 13.4
Applied egg-rr13.6
Simplified14.1
[Start]13.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \frac{\frac{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}}{\frac{-1}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}}
\] |
|---|---|
rational.json-simplify-47 [=>]13.5 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \color{blue}{\frac{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \frac{-1}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}}}
\] |
rational.json-simplify-2 [=>]13.5 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \frac{\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \frac{-1}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}}
\] |
rational.json-simplify-2 [=>]13.5 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \frac{\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}\right)}{\left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \frac{-1}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}}
\] |
rational.json-simplify-2 [=>]13.5 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \frac{\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)}{\left(\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}\right) \cdot \left(-\left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)\right) \cdot \frac{-1}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}}
\] |
rational.json-simplify-2 [=>]13.5 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \frac{\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)}{\left(\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(-\left(\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}\right)\right)\right) \cdot \frac{-1}{\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}}
\] |
rational.json-simplify-46 [=>]14.1 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \frac{\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)}{\left(\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(-\left(\left(1 - ux\right) + maxCos \cdot ux\right)\right)\right) \cdot \color{blue}{\frac{\frac{-1}{\left(1 - ux\right) + ux \cdot maxCos}}{\left(1 - ux\right) + ux \cdot maxCos}}}}
\] |
rational.json-simplify-2 [=>]14.1 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \frac{\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)}{\left(\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(-\left(\left(1 - ux\right) + maxCos \cdot ux\right)\right)\right) \cdot \frac{\frac{-1}{\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}}}{\left(1 - ux\right) + ux \cdot maxCos}}}
\] |
rational.json-simplify-2 [=>]14.1 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - \frac{\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)}{\left(\left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(-\left(\left(1 - ux\right) + maxCos \cdot ux\right)\right)\right) \cdot \frac{\frac{-1}{\left(1 - ux\right) + maxCos \cdot ux}}{\left(1 - ux\right) + \color{blue}{maxCos \cdot ux}}}}
\] |
Taylor expanded in ux around 0 0.6
Simplified0.6
[Start]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(-1 \cdot \left({\left(maxCos - 1\right)}^{2} + \left(maxCos - 1\right) \cdot \left(2 \cdot maxCos - 2\right)\right) - -1 \cdot \left(\left(1 - maxCos\right) \cdot \left(\left(-1 \cdot \left(\left(maxCos + 2 \cdot maxCos\right) - 3\right) + maxCos\right) - 1\right)\right)\right) \cdot {ux}^{2} + \left(\left(-1 \cdot \left(\left(maxCos + 2 \cdot maxCos\right) - 3\right) + maxCos\right) - 1\right) \cdot ux}
\] |
|---|---|
rational.json-simplify-1 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(\left(-1 \cdot \left(\left(maxCos + 2 \cdot maxCos\right) - 3\right) + maxCos\right) - 1\right) \cdot ux + \left(-1 \cdot \left({\left(maxCos - 1\right)}^{2} + \left(maxCos - 1\right) \cdot \left(2 \cdot maxCos - 2\right)\right) - -1 \cdot \left(\left(1 - maxCos\right) \cdot \left(\left(-1 \cdot \left(\left(maxCos + 2 \cdot maxCos\right) - 3\right) + maxCos\right) - 1\right)\right)\right) \cdot {ux}^{2}}}
\] |
rational.json-simplify-48 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\color{blue}{\left(maxCos + \left(-1 \cdot \left(\left(maxCos + 2 \cdot maxCos\right) - 3\right) - 1\right)\right)} \cdot ux + \left(-1 \cdot \left({\left(maxCos - 1\right)}^{2} + \left(maxCos - 1\right) \cdot \left(2 \cdot maxCos - 2\right)\right) - -1 \cdot \left(\left(1 - maxCos\right) \cdot \left(\left(-1 \cdot \left(\left(maxCos + 2 \cdot maxCos\right) - 3\right) + maxCos\right) - 1\right)\right)\right) \cdot {ux}^{2}}
\] |
rational.json-simplify-48 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \color{blue}{\left(2 \cdot maxCos + \left(maxCos - 3\right)\right)} - 1\right)\right) \cdot ux + \left(-1 \cdot \left({\left(maxCos - 1\right)}^{2} + \left(maxCos - 1\right) \cdot \left(2 \cdot maxCos - 2\right)\right) - -1 \cdot \left(\left(1 - maxCos\right) \cdot \left(\left(-1 \cdot \left(\left(maxCos + 2 \cdot maxCos\right) - 3\right) + maxCos\right) - 1\right)\right)\right) \cdot {ux}^{2}}
\] |
rational.json-simplify-2 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(\color{blue}{maxCos \cdot 2} + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(-1 \cdot \left({\left(maxCos - 1\right)}^{2} + \left(maxCos - 1\right) \cdot \left(2 \cdot maxCos - 2\right)\right) - -1 \cdot \left(\left(1 - maxCos\right) \cdot \left(\left(-1 \cdot \left(\left(maxCos + 2 \cdot maxCos\right) - 3\right) + maxCos\right) - 1\right)\right)\right) \cdot {ux}^{2}}
\] |
Taylor expanded in maxCos around 0 0.6
Simplified0.6
[Start]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(\left(2 \cdot maxCos + -1 \cdot {maxCos}^{2}\right) - 1\right) \cdot {ux}^{2}}
\] |
|---|---|
rational.json-simplify-1 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(\color{blue}{\left(-1 \cdot {maxCos}^{2} + 2 \cdot maxCos\right)} - 1\right) \cdot {ux}^{2}}
\] |
rational.json-simplify-48 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \color{blue}{\left(2 \cdot maxCos + \left(-1 \cdot {maxCos}^{2} - 1\right)\right)} \cdot {ux}^{2}}
\] |
rational.json-simplify-2 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(2 \cdot maxCos + \left(\color{blue}{{maxCos}^{2} \cdot -1} - 1\right)\right) \cdot {ux}^{2}}
\] |
rational.json-simplify-9 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(2 \cdot maxCos + \left(\color{blue}{\left(-{maxCos}^{2}\right)} - 1\right)\right) \cdot {ux}^{2}}
\] |
rational.json-simplify-12 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(2 \cdot maxCos + \left(\color{blue}{\left(0 - {maxCos}^{2}\right)} - 1\right)\right) \cdot {ux}^{2}}
\] |
rational.json-simplify-42 [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(2 \cdot maxCos + \color{blue}{\left(\left(0 - 1\right) - {maxCos}^{2}\right)}\right) \cdot {ux}^{2}}
\] |
metadata-eval [=>]0.6 | \[ \sin \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{\left(maxCos + \left(-1 \cdot \left(maxCos \cdot 2 + \left(maxCos - 3\right)\right) - 1\right)\right) \cdot ux + \left(2 \cdot maxCos + \left(\color{blue}{-1} - {maxCos}^{2}\right)\right) \cdot {ux}^{2}}
\] |
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 2.6 |
| Cost | 30984 |
| Alternative 2 | |
|---|---|
| Error | 3.1 |
| Cost | 23336 |
| Alternative 3 | |
|---|---|
| Error | 3.1 |
| Cost | 23336 |
| Alternative 4 | |
|---|---|
| Error | 3.4 |
| Cost | 23208 |
| Alternative 5 | |
|---|---|
| Error | 3.4 |
| Cost | 23208 |
| Alternative 6 | |
|---|---|
| Error | 3.4 |
| Cost | 23208 |
| Alternative 7 | |
|---|---|
| Error | 4.3 |
| Cost | 23176 |
| Alternative 8 | |
|---|---|
| Error | 0.5 |
| Cost | 16960 |
| Alternative 9 | |
|---|---|
| Error | 0.5 |
| Cost | 13408 |
| Alternative 10 | |
|---|---|
| Error | 1.4 |
| Cost | 13220 |
| Alternative 11 | |
|---|---|
| Error | 1.4 |
| Cost | 13220 |
| Alternative 12 | |
|---|---|
| Error | 4.2 |
| Cost | 10116 |
| Alternative 13 | |
|---|---|
| Error | 4.5 |
| Cost | 10084 |
| Alternative 14 | |
|---|---|
| Error | 8.6 |
| Cost | 9856 |
| Alternative 15 | |
|---|---|
| Error | 11.0 |
| Cost | 6784 |
| Alternative 16 | |
|---|---|
| Error | 11.8 |
| Cost | 6656 |
herbie shell --seed 2023074
(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)))))))