| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 16352 |
\[\sin \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(u1 \cdot \left(-u1\right)\right)}
\]
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (- (log (- 1.0 u1)))) (sin (* (* 2.0 PI) u2))))
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (- (log1p (- u1)))) (sin (* 2.0 (cbrt (pow (* PI u2) 3.0))))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf(-logf((1.0f - u1))) * sinf(((2.0f * ((float) M_PI)) * u2));
}
float code(float cosTheta_i, float u1, float u2) {
return sqrtf(-log1pf(-u1)) * sinf((2.0f * cbrtf(powf((((float) M_PI) * u2), 3.0f))));
}
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * sin(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) end
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * sin(Float32(Float32(2.0) * cbrt((Float32(Float32(pi) * u2) ^ Float32(3.0)))))) end
\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right)
\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \sqrt[3]{{\left(\pi \cdot u2\right)}^{3}}\right)
Results
Initial program 13.5
Simplified0.5
[Start]13.5 | \[ \sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right)
\] |
|---|---|
sub-neg [=>]13.5 | \[ \sqrt{-\log \color{blue}{\left(1 + \left(-u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right)
\] |
log1p-def [=>]0.5 | \[ \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right)
\] |
associate-*l* [=>]0.5 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \color{blue}{\left(2 \cdot \left(\pi \cdot u2\right)\right)}
\] |
Applied egg-rr0.5
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 16352 |
| Alternative 2 | |
|---|---|
| Error | 1.8 |
| Cost | 13348 |
| Alternative 3 | |
|---|---|
| Error | 3.0 |
| Cost | 13284 |
| Alternative 4 | |
|---|---|
| Error | 3.0 |
| Cost | 13220 |
| Alternative 5 | |
|---|---|
| Error | 0.5 |
| Cost | 13056 |
| Alternative 6 | |
|---|---|
| Error | 2.7 |
| Cost | 10112 |
| Alternative 7 | |
|---|---|
| Error | 5.2 |
| Cost | 9860 |
| Alternative 8 | |
|---|---|
| Error | 8.3 |
| Cost | 6784 |
| Alternative 9 | |
|---|---|
| Error | 10.9 |
| Cost | 6592 |
herbie shell --seed 2022356
(FPCore (cosTheta_i u1 u2)
:name "Beckmann Sample, near normal, slope_y"
:precision binary32
:pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 1.0))) (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
(* (sqrt (- (log (- 1.0 u1)))) (sin (* (* 2.0 PI) u2))))