| Alternative 1 | |
|---|---|
| Error | 98.4% |
| Cost | 3680.00 |
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\]
(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(Float32(sin2phi / 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{\frac{sin2phi}{alphay}}{alphay}}
Results
Initial program 60.8
Simplified98.4
[Start]60.8 | \[ \frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
|---|---|
sub-neg [=>]60.8 | \[ \frac{-\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
log1p-def [=>]98.4 | \[ \frac{-\color{blue}{\mathsf{log1p}\left(-u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
Applied egg-rr98.4
[Start]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
|---|---|
div-inv [=>]98.3 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\color{blue}{cos2phi \cdot \frac{1}{alphax \cdot alphax}} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
*-commutative [=>]98.3 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{1}{alphax \cdot alphax} \cdot cos2phi} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
pow2 [=>]98.3 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{1}{\color{blue}{{alphax}^{2}}} \cdot cos2phi + \frac{sin2phi}{alphay \cdot alphay}}
\] |
pow-flip [=>]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\color{blue}{{alphax}^{\left(-2\right)}} \cdot cos2phi + \frac{sin2phi}{alphay \cdot alphay}}
\] |
metadata-eval [=>]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{{alphax}^{\color{blue}{-2}} \cdot cos2phi + \frac{sin2phi}{alphay \cdot alphay}}
\] |
Taylor expanded in alphax around 0 98.4
Simplified98.4
[Start]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}}
\] |
|---|---|
unpow2 [=>]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{\color{blue}{alphax \cdot alphax}} + \frac{sin2phi}{{alphay}^{2}}}
\] |
unpow2 [=>]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{\color{blue}{alphay \cdot alphay}}}
\] |
associate-/r* [=>]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{\frac{sin2phi}{alphay}}{alphay}}}
\] |
Applied egg-rr98.3
[Start]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}
\] |
|---|---|
associate-/r* [=>]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}} + \frac{\frac{sin2phi}{alphay}}{alphay}}
\] |
div-inv [=>]98.3 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{cos2phi}{alphax} \cdot \frac{1}{alphax}} + \frac{\frac{sin2phi}{alphay}}{alphay}}
\] |
Applied egg-rr98.4
[Start]98.3 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax} \cdot \frac{1}{alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}
\] |
|---|---|
un-div-inv [=>]98.4 | \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}} + \frac{\frac{sin2phi}{alphay}}{alphay}}
\] |
Final simplification98.4
| Alternative 1 | |
|---|---|
| Error | 98.4% |
| Cost | 3680.00 |
| Alternative 2 | |
|---|---|
| Error | 98.4% |
| Cost | 3680.00 |
| Alternative 3 | |
|---|---|
| Error | 92.2% |
| Cost | 3556.00 |
| Alternative 4 | |
|---|---|
| Error | 92.2% |
| Cost | 3556.00 |
| Alternative 5 | |
|---|---|
| Error | 92.7% |
| Cost | 3556.00 |
| Alternative 6 | |
|---|---|
| Error | 87.4% |
| Cost | 800.00 |
| Alternative 7 | |
|---|---|
| Error | 83.5% |
| Cost | 644.00 |
| Alternative 8 | |
|---|---|
| Error | 87.6% |
| Cost | 608.00 |
| Alternative 9 | |
|---|---|
| Error | 81.8% |
| Cost | 548.00 |
| Alternative 10 | |
|---|---|
| Error | 77.1% |
| Cost | 484.00 |
| Alternative 11 | |
|---|---|
| Error | 81.8% |
| Cost | 484.00 |
| Alternative 12 | |
|---|---|
| Error | 81.8% |
| Cost | 484.00 |
| Alternative 13 | |
|---|---|
| Error | 75.2% |
| Cost | 452.00 |
| Alternative 14 | |
|---|---|
| Error | 67.1% |
| Cost | 292.00 |
| Alternative 15 | |
|---|---|
| Error | 67.1% |
| Cost | 292.00 |
| Alternative 16 | |
|---|---|
| Error | 67.1% |
| Cost | 292.00 |
| Alternative 17 | |
|---|---|
| Error | 67.1% |
| Cost | 292.00 |
| Alternative 18 | |
|---|---|
| Error | 67.1% |
| Cost | 292.00 |
| Alternative 19 | |
|---|---|
| Error | 67.1% |
| Cost | 292.00 |
| Alternative 20 | |
|---|---|
| Error | 23.6% |
| Cost | 224.00 |
herbie shell --seed 2023121
(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)))))