| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 3680 |
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}}
\]
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (- (log (- 1.0 u0))) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (- (log1p (- u0))) (+ (/ (/ cos2phi alphax) alphax) (/ sin2phi (* alphay alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return -logf((1.0f - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
}
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return -log1pf(-u0) / (((cos2phi / alphax) / alphax) + (sin2phi / (alphay * alphay)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(-log(Float32(Float32(1.0) - u0))) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay)))) end
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(-log1p(Float32(-u0))) / Float32(Float32(Float32(cos2phi / alphax) / alphax) + Float32(sin2phi / Float32(alphay * alphay)))) end
\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{alphax} + \frac{sin2phi}{alphay \cdot alphay}}
Results
Initial program 12.6
Simplified0.5
[Start]12.6 | \[ \frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
|---|---|
sub-neg [=>]12.6 | \[ \frac{-\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
log1p-def [=>]0.5 | \[ \frac{-\color{blue}{\mathsf{log1p}\left(-u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
Applied egg-rr0.5
Simplified0.5
[Start]0.5 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax} \cdot \frac{1}{alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
|---|---|
*-commutative [=>]0.5 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{1}{alphax} \cdot \frac{cos2phi}{alphax}} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
associate-*r/ [=>]0.5 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{1}{alphax} \cdot cos2phi}{alphax}} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
Taylor expanded in alphax around 0 0.5
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 3680 |
| Alternative 2 | |
|---|---|
| Error | 5.0 |
| Cost | 3556 |
| Alternative 3 | |
|---|---|
| Error | 5.9 |
| Cost | 932 |
| Alternative 4 | |
|---|---|
| Error | 5.4 |
| Cost | 900 |
| Alternative 5 | |
|---|---|
| Error | 5.8 |
| Cost | 612 |
| Alternative 6 | |
|---|---|
| Error | 7.7 |
| Cost | 416 |
| Alternative 7 | |
|---|---|
| Error | 10.7 |
| Cost | 292 |
| Alternative 8 | |
|---|---|
| Error | 10.7 |
| Cost | 292 |
| Alternative 9 | |
|---|---|
| Error | 24.3 |
| Cost | 224 |
| Alternative 10 | |
|---|---|
| Error | 24.3 |
| Cost | 224 |
herbie shell --seed 2023066
(FPCore (alphax alphay u0 cos2phi sin2phi)
:name "Beckmann Distribution sample, tan2theta, alphax != alphay, u1 <= 0.5"
:precision binary32
:pre (and (and (and (and (and (<= 0.0001 alphax) (<= alphax 1.0)) (and (<= 0.0001 alphay) (<= alphay 1.0))) (and (<= 2.328306437e-10 u0) (<= u0 1.0))) (and (<= 0.0 cos2phi) (<= cos2phi 1.0))) (<= 0.0 sin2phi))
(/ (- (log (- 1.0 u0))) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))